Embedded Control Redefined: New C/C++ Options on NI Linux Real-Time Anna Kozminski Software Product Manager
Agenda NI Embedded Software Architecture Communicating between C/C++ and LabVIEW Development practices for C/C++ on NI CompactRIO 2
NI Embedded Software Architecture Real-Time Processor FPGA Modular I/O Deterministic OS Reuse existing applications and libraries Program in LabVIEW, C, C++ or.m Interoperate with LabVIEWprogrammed FPGA Programmable Hardware Offload critical, decision-making code to the FPGA Use graphical programming to leverage FPGA technology without HDL expertise 3
NI Embedded Software Architecture 1 LabVIEW 34 2 C/C++ FPGA Interface C API LabVIEW FPGA Real-Time Processor FPGA 1 LabVIEW RT and FPGA 2 LabVIEW RT app for I/O, with C/C++ app or library 3 C/C++ RT app for I/O, with LabVIEW app or library 4 C/C++ on RT, LabVIEW FPGA 4
Communicating between C/C++ and LabVIEW LabVIEW C/C++ LabVIEW FPGA Real-Time Processor FPGA 5
Communicating between C/C++ and LabVIEW LabVIEW Call Library Function Node Call a DLL or Linux shared library from LabVIEW 6
Communicating between C/C++ and LabVIEW Import Shared Library wizard Create a LabVIEW project library of wrapper Vis for functions in a.dll or.so file using the header file Uses the Call Library Function Node 7
Communicating between C/C++ and LabVIEW System Exec VI Launch another application from your LabVIEW VI Provide any parameters supported by the application 8
Communicating between C/C++ and LabVIEW Localhost communication Pass data between applications using TCP sockets int getaddrinfo(const char *node, const char *service, const struct addrinfo *host_info, struct addrinfo **res); 9
Communicating between C/C++ and LabVIEW C/C++ FPGA Interface C API LabVIEW FPGA Real-Time Processor FPGA 10
Communicating between C/C++ and LabVIEW C/C++ FPGA Interface C API LabVIEW FPGA Real-Time Processor FPGA 11
FPGA Interface C API Enables C/C++ applications to interact directly with compiled LabVIEW FPGA VIs on RIO devices Must be downloaded in addition to C/C++ toolchain Supports Reading/writing to named controls and indicators DMA data transfers Wait on and acknowledge interrupts Is NOT an interface for RSI or Scan Engine. 12
Known Limitations of the FPGA Interface C API Limited data type support, no support for Floating point Fixed point Clusters Arrays of any data type other than supported scalar types To use a different FPGA VI, user must regenerate the header and recompile the application Challenging to create application that works with multiple bitfiles 13
Programmer Workflow Remote Development And Debug Deploy (Windows) LabVIEW FPGA development C/C++ development in Eclipse CompactRIO 1. Develop LabVIEW FPGA VI, compile bitfile & generate C API. 2. Build and deploy C/C++ application with generated C API & debug. 3. Deploy built application and bitfile and run. 14
Communicating between C/C++ and LabVIEW LabVIEW C/C++ FPGA Interface C API LabVIEW FPGA Real-Time Processor FPGA 15
Elements to the C/C++ Development Option Software Required LabVIEW + LabVIEW FPGA FPGA Interface C API (free) C/C++ cross-compiler for CompactRIO RTOS (free) Optional Software C/C++ IDE o Develop, debug, deploy o Eclipse (free), WindRiver, Vim, Emacs etc. 16
NI CompactRIO Technology Evolution crio-9002 crio-9004 crio-9072 crio-9074 crio-9075 crio-9076 crio-9012 crio-9014 crio-9024 crio-9025 crio-9081 crio-9082 crio-9068 17
NI Embedded Real-Time OSs VxWorks NI Linux Real-Time 18
VxWorks
VxWorks Development Process Obtain Code Configure Build Port Code Build Code Debug/Run Code Our mature VxWorks platform already has good process documentation The Definitive Guide: Programming NI VxWorks Real-Time Controllers in C/C++ This presentation is limited to the highlights 20
Build Environments for VxWorks Two options: WindRiver toolchain o Proprietary IDE GCC toolchain o Free command-line method o Requires a Make file for compiler instructions 21
Porting Code for VxWorks VxWorks has limited OS support for some core libraries Porting code can be time consuming Some libraries exist, but they exist in different headers 22
Building Code for VxWorks: GCC Toolchain From the command prompt, GCC provides standard errors Because this is not an IDE, it does not link directly to the code 23
NI Linux Real-Time
The Redesigned CompactRIO System NI LabVIEW System Design Program with LabVIEW Real-Time and LabVIEW FPGA modules Quickly port existing LabVIEW applications Ultra Rugged -40 to 70 C operating temperature range 50 g shock and 5 g vibration tolerance 26 High Performance and Throughput Dual-Core ARM 667 MHz processor Xilinx 7 Series FPGA fabric with 85k logic cells 16 DMA FIFO channels for data streaming Community and Code Reuse NI Linux Real-Time Operating System Integrate existing applications and libraries Develop, debug, and deploy C/C++ code
New: NI CompactRIO 9068 C/C++ Community Applications and Libraries NI Linux Linux Real-Time Operating Operating System System 27
NI Linux Real-Time Development Process Locate Code Configure Build Port Code Build Code Debug Code Download Library Learn Code Run Code 28
Accessing the Linux Community: Package Manager What is a package manager? Set of software tools for installing, updating, configuring and removing applications Think of the App Store, VIPM, etc. CompactRIO-9068 shipping with a package manger preinstalled called opkg Does not take the place of MAX Access to hundreds of applications in the Linux community 29
Leveraging the Linux Community Enable OPKG access to repositories Download and configure applications as necessary Rely on the System Execution VI, Call Library Function Node, or localhost communication to interact Databases Security Code Reuse Connectivity Raima IPTables C/C++ NTP MySQL OpenVPN Shell Scripts SNMP PostgreSQL fail2ban Python IPv6 30
Configuring Builds for NI Linux Real-Time Eclipse IDE for C and C++ Download Eclipse and compiler from Set-up instructions on Once configured, can build and debug code for NI Linux Real- Time Any other code editor NI Provides: Mentor Graphics Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux (GCC 4.4.1) armv7a compatible cross-compiler 32
What is Eclipse? Free IDE Framework, originally for Java development De facto Standard IDE for Embedded Development Updated with tools for C/C++ development and debugging Eclipse C/C++ Development Toolkit (CDT) Target Management/Remote System Explorer Note: NI Provided Installer is for Windows It is not necessary to use Eclipse 33
Porting to NI Linux Real-Time Open source code can frequently be compiled for Linux without issue Replace Win32 functions with equivalent Linux calls 34
DEMO
NI Linux Real-Time: Flexible Software Integration Code Reuse Real-Time Processor Integrate existing applications and libraries Develop, debug and deploy C/C++ code Use Eclipse or IDE of choice Leverage the Linux ecosystem Interoperate with LabVIEW-programmed FPGA FPGA Programmable Hardware Modular I/O Offload critical, decision-making code to the FPGA Reliable, precision timing for control or processing Achieve high-speed, high-accuracy I/O Use graphical programming to leverage FPGA technology without HDL expertise 36
Key Resources Ni.com/EmbeddedSystems/Csupport Download Eclipse and compiler toolchain Setup and getting started instructions Download FPGA Interface C API Linux Real-Time Community Tutorials Documentation Forum for discussions /linux Links to whitepapers Embedded and Desktop uses 37
Thank you! Questions?