This repository provides an abstraction layer to program any NI CompactRIO in C/C++ with an Arduino-like syntax. It allows for the dynamic creation of FPGA I/O nodes accessors based on the C Series Modules you have in your cRIO.
- Important Usage Limitations and Clarifications
- Requirments
- Installation
- Usage
This software is primarily intended for demonstration purposes. It's important to understand that the cRIO is not a microcontroller. It is a powerful embedded computer that is programmed on its own and runs Linux RT. While this software provides an Arduino-like syntax for ease of use, it does not fully utilize the extensive capabilities of the cRIO. For instance, this software is designed to work only with analog and digital C Series Modules.
LabVIEW is needed to generate the bitfile but as long as you don't change hardware there is no need to go back to LabVIEW. No knowledge of G code programming is required.
- analogRead
- analogWrite
- digitalWrite
- digitalRead
- millis
- micros
- delay
- LabVIEW 32-bit Full or Professional. Version 2024Q1 or newer with Real-Time Module and FPGA Module
- Any CompactRIO controller and its respective driver
- One of each digital I/O and analog I/O C Series digital or analog module.
Fist you will need to copy this repository to your development computer
git clone https://github.com/Hunajpu/arduRIO
To start programing the cRIO with C/C++ Arduino syntax, we need to generate an FPGA bitfile and then the C FPGA interface files. Inside the LabVIEW folder there is a project with the necesary tools for this. To create new files there is a four steps cycle tha you will need to run every time you change the hardware on the cRIO:
- Project configuration.
- Bitfile generation.
- C FPGA code generation.
- Coping files to the target CompactRIO
- Open the scriptFPGAioSelectors LabVIEW project inside the LabVIEW folder
- Right-click the Project icon and create a new Target
- Expand the Real-Time CompactRIO folder to discover all the cRIO remote devices available. Select your device and click on OK.
- Expand the recently added cRIO and Chassis
- Right-click on the Chassis item and add a new FPGA target
- Expand the RT CompactRIO Target, Chassis and FPGA Target
- Copy the Counters folder and all the VIs and LabVIEW controls
- Paste the elements under the FPGA target of the recently added cRIO
- Now you can remove the RT CompactRIO Target from the project. Right-click->Remove from Project
- If you already have modules under Real-Time Scan Resources or Real-Time Resources remove them from the project.
- Right-click on the FPGA Target->New->C Series Modules...
- Expand the C Series Module folder on the pop-up window and select all the modules you want. This project only works with Digital or Analog modules.
- Open the MainScriptCreateAllIOselectors.vi that is under My Computer
- Run the VI. This process may take a few minutes to complete
- Right-click on the FPGA Build Specifications and create a new compilation
- Under Source Files select fpga_main.vi. The rest of the configurations can be left with the default values
- Click on build.
These files need to be generated by running the LabVIEW C API generator
- Right-click the fpga_main.vi on the project and Launch the C API generator
- Make sure that the generated files are save to arduRIO/generated
- Set the Prefix Override to f and the target Platform to Linux RT
- Copy all the files from the arduRIO folder to the target cRIO. Tools Available for File Transfer/Access on NI Linux Real-Time Targets
- You can use scp command to send the folder from Windows to the cRIO
scp -r \path\to\arduRIO admin@cRIO_IP:/home/admin/arduRIO
Once you hace the folder in the cRIO you can remote access it and modify the Blink.ino file to program whatever you want, then compile it running the make command
$ make
This will generate an executable with the same name
$ ./Blink