Skip to content

Abstaraction layer to program any NI cRIO with a arduino-like syntax

Notifications You must be signed in to change notification settings

Hunajpu/arduRIO

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduRIO: CompactRIO with C/C++ Arduino-like Syntax

Description

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.

Table of Contents

  1. Important Usage Limitations and Clarifications
  2. Requirments
  3. Installation
  4. Usage

Important Usage Limitations and Clarifications

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.

Current supported functions

  • analogRead
  • analogWrite
  • digitalWrite
  • digitalRead
  • millis
  • micros
  • delay

Requirments

  1. LabVIEW 32-bit Full or Professional. Version 2024Q1 or newer with Real-Time Module and FPGA Module
  2. Any CompactRIO controller and its respective driver
  3. One of each digital I/O and analog I/O C Series digital or analog module.

Installation

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:

  1. Project configuration.
  2. Bitfile generation.
  3. C FPGA code generation.
  4. Coping files to the target CompactRIO

1. Project configuration

  1. Open the scriptFPGAioSelectors LabVIEW project inside the LabVIEW folder
  2. Right-click the Project icon and create a new Target New project target
  3. Expand the Real-Time CompactRIO folder to discover all the cRIO remote devices available. Select your device and click on OK. Add Existing Target
  4. Expand the recently added cRIO and Chassis
  5. Right-click on the Chassis item and add a new FPGA target Add FPGA target
  6. Expand the RT CompactRIO Target, Chassis and FPGA Target
  7. Copy the Counters folder and all the VIs and LabVIEW controls Copy VIs
  8. Paste the elements under the FPGA target of the recently added cRIO Paste VIs
  9. Now you can remove the RT CompactRIO Target from the project. Right-click->Remove from Project
  10. If you already have modules under Real-Time Scan Resources or Real-Time Resources remove them from the project.
  11. Right-click on the FPGA Target->New->C Series Modules... New C modules
  12. 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. Select Modules
  13. Open the MainScriptCreateAllIOselectors.vi that is under My Computer
  14. Run the VI. This process may take a few minutes to complete

2. Bitfile generation

  1. Right-click on the FPGA Build Specifications and create a new compilation
  2. Under Source Files select fpga_main.vi. The rest of the configurations can be left with the default values
  3. Click on build.

3. C FPGA code generation

These files need to be generated by running the LabVIEW C API generator

  1. Right-click the fpga_main.vi on the project and Launch the C API generator C API generator
  2. Make sure that the generated files are save to arduRIO/generated
  3. Set the Prefix Override to f and the target Platform to Linux RT C API generator options

4. Coping files to the target CompactRIO

Usage

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

About

Abstaraction layer to program any NI cRIO with a arduino-like syntax

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • LabVIEW 48.7%
  • C++ 27.4%
  • C 23.7%
  • Makefile 0.2%