ni.com checkout is currently experiencing issues.

Support teams are actively working on the resolution.

Example Code

NI 9870 - Continuous Serial Read - On-Demand Write

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • NI-9870

Code and Documents

Attachment

Description

Overview


The NI 9870, 4-port serial C-Series Module, was made to work with the cRIO in FPGA Interface Mode. The programming required for this module is a little more advanced than some of its analog and digital cousins. This is an example of an easily scalable and modifiable program, originally designed to stream data from all 4 ports simultaneously and write to any of the 4 (one at a time) on demand. The initial design was created to stream data back from GPS and other serial devices simultaneously while allowing for intermittent writing to any of the ports.

This example code was written to simultaneously read from the 4 ports on a single NI 9870 in slot one of a cRIO chassis.  However, it can be easily modified to read fewer or more ports on one or more modules. 

Another part of the original code is to write to one, user-selectable port at a time when the write button is pressed.  This portion of the code can also be modified to allow programmatic sending of strings or streaming in both directions.

This code can also run loopback tests, as is, with the appropriate wiring in place. 


Figure 1. Front Panel of Host VI.

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