Example Code

Basic FSAE In-Vehicle Data Acquisition Template

Code and Documents

Attachment

Introduction:

As beginning to code an entire vehicle template can be time consuming, we’ve provided an example template to help you get started with basic DAQ measurements using CompactRIO.  While this template provides coding techniques for many sensors and measurements, you can customize and simplify if you only want parts of the code functionality that is provided here.

In the near future, this example template will include additional functionality such as CAN, sensor calibration, Dyno control, and more advanced coding for sensors used on your FSAE vehicle.  Currently the template is designed to help you better understand and begin utilizing functions such as basic sensor inputs and outputs, writing data to a Host VI using FIFOs and read/ write controls, saving data on the controller for post-acquisition analysis, and general FPGA programming.

This code is designed to be able to run wirelessly on a vehicle using a router, however, for testing purposes, the easiest way to test the code is to run it while connected to the controller via PC.  The data from the controller is sent back to a Host PC via network-published shared variables.  More information about shared variables can be found at the link below:

http://zone.ni.com/devzone/cda/tut/p/id/4679

Instructions:

  1. Using the guidelines in the Getting Started guides for detecting your CompactRIO controller and FPGA Target in a project, you can add your cRIO to the existing project template here. 
  2. Drag the Host1 VI, RT Version 1 VI, Variables.lvlib, and the items in the FPGA Items to Move folder to the corresponding locations on your new target.
  3. Open both the RT Version 1 VI and the Host VI .
  4. On the Host VI, make sure that all sample rates in the File Control section are set correctly.
  5. Click the Run Arrow on the RT Version 1 VI.
  6. Click the Run Arrow on the Host VI.
  7. When you are ready to begin acquisition from your sensor, click Start Acquisition.
  8. View the incoming data on the various tabs on the Host VI.

Note:  Currently, the code reads raw voltage values and will not correspond to the appropriate parameter that you are measuring. Additional functionality can be added to the VI to calibrate this data to the correct units of measurement.

Hardware:

cRIO 9022 controller

cRIO 9013 chassis with FPGA

NI 9205 Analog Input module

NI 9403 Digital Input/ Output module

Software:

LabVIEW 2011

RT Module

FPGA Module

Ni-RIO 4.0

Screenshot.png

Regards,
Austin S.

National Instruments
Academic Field Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors