NI 9870 (FPGA Interface)

NI CompactRIO Device Drivers Help

Edition Date: December 2017

Part Number: 373197L-01

»View Product Info
Download Help (Windows Only)

CompactRIO Serial 4-Port, RS232 Module (DTE interface)

Programming Overview

Serial Port Information

FPGA I/O Node

This device does not support the FPGA I/O Node.

Terminals in Software

You can select the following terminals for this device.

Terminal Description
Port x Port x of the module, where x is the number of the port. The NI 9870 has ports 1 to 4.

Arbitration

This device does not support arbitration options. All port-specific property and method nodes have equal priority and will execute using fair, round-robin arbitration. Module-specific property nodes (Serial #, Module ID#, Vendor ID#) are given a lower priority in the arbitration scheme.

Although arbitration options are not supported, arbitration is used only when nodes are placed without dependence on each other. Using error clusters, sequence structures, and other forms of dependence is recommended when explicit program flow control is needed. Refer to labview\examples\CompactRIO\Module Specific\NI 987x\Serial Loopback\NI-987x Serial Loopback.lvproj for an example of how to control program flow in this way.

I/O Methods

Use the FPGA I/O Method Node to configure the following methods with this device. This device does not support any module methods.

Method Description
Clear Rx FIFO Clears the 64-byte UART Receive FIFO (Rx) for the desired port.
Note Note  There are no wires into or out of this method in LabVIEW. This action is executed when the method is placed on the block diagram and the VI is run. To execute this method in a sequence, place the method within a Flat Sequence structure, or wire error handlers into and out of the FPGA I/O Method Node itself.
Read Byte Reads a single byte from the 64-byte UART Receive (Rx) FIFO for the desired port. The method returns any data errors, such as parity or overrun.
  • Data: Returns the 8-bit unsigned value.
  • Timeout (ms): Specifies the amount of time in milliseconds to keep retrying the read if no data is available. A value of 0 indicates a single try, and –1 indicates an infinite number of tries.
    Caution Caution  Setting –1 as a timeout value can make the program appear to hang while the node waits indefinitely to complete and pass on program control.
  • Timed Out: Returns TRUE if the method times out before receiving data.

Refer to labview\examples\CompactRIO\Module Specific\NI 987x\Serial Loopback\NI-987x Serial Loopback.lvproj for an example that illustrates using DMA and interrupts in conjunction with LabVIEW FPGA loops and this FPGA I/O Method Node to read blocks of data.

Write Byte Writes a single byte to the 64-byte UART Transmit (Tx) FIFO for the desired port. If flow control allows, the byte is transmitted immediately upon reaching the top of the FIFO.
  • Data: Specifies the 8-bit unsigned value to write.
  • Timeout (ms): Specifies the amount of time in milliseconds to keep retrying the write if no data is available. A value of 0 indicates a single try, and –1 indicates an infinite number of tries.
    Caution Caution  Setting –1 as a timeout value while using flow control can make the program appear to hang while the node waits indefinitely to complete and pass on program control.
  • Timed Out: Returns TRUE if the method times out before data can be written to the Tx FIFO (the FIFO is full).

Refer to labview\examples\CompactRIO\Module Specific\NI 987x\Serial Loopback\NI-987x Serial Loopback.lvproj for an example that illustrates using DMA and interrupts in conjunction with LabVIEW FPGA loops and this FPGA I/O Method Node to read blocks of data.

I/O Properties

Use the FPGA I/O Property Node to access the following properties with this device.

Property Description
Baud Rate (write only) Sets the target baud rate for the port. If you set the baud rate, the appropriate Baud Rate Prescaler and Baud Rate Divider are set automatically, and are calculated according to this formula:

BaudRate = 3.6864 Mbps / (Prescaler * Divider)

Note Note  The maximum Baud Rate for the NI 9870 is 921.6 Kbps.
Baud Rate Divider (read/write) Specifies the divider for the baud rate as defined by the baud rate equation above. This property is useful for setting a custom baud rate programmatically. Use the C Series Module Properties dialog box as a calculator to find the appropriate divider for the desired custom baud rate. This value is an unsigned 16-bit value within the range 4–65535.
Note Note  Any values outside of the valid range will be coerced into the range.
Baud Rate Prescaler (read/write) Specifies the prescaler for the baud rate as defined by the baud rate equation above. This property is useful for setting a custom baud rate programmatically. Use the C Series Module Properties dialog box as a calculator to find the appropriate prescaler for the desired custom baud rate. This value is defined as a type def, either 1 or 4. A value of 4 is normally used only for very low baud rates.
Break State (write only)Sets the break state of the port to Unasserted (logic high) or Asserted (logic low). If you set the break state to Asserted, the property suspends byte transmission and places the transmission line in a break state until you set the break state to Unasserted.
Bytes at Port (read only)Returns the number of bytes currently available in the UART Receive FIFO for the desired port. The number of bytes will be within the range 0–64.
CTS State (read only)Returns the current state of the Clear To Send (CTS) input signal, either Unasserted (logic high) or Asserted (logic low).
Data Bits (read/write)Specifies the number of data bits contained in each frame. Valid values are 5, 6, 7, and 8. If you select 5 data bits, you can select only 1 or 1.5 stop bits. If you select 6, 7, or 8 data bits, you can select only 1 or 2 stop bits.
DCD State (read only)Returns the current state of the Data Carrier Detect (DCD) input signal, either Unasserted (logic high) or Asserted (logic low). The DCD signal is also known as the Receive Line Signal Detect (RLSD). Modems often use the DCD signal to indicate the detection of a carrier, or modem, on the phone line.
DSR State (read only)Returns the current state of the Data Set Ready (DSR) input signal, either Unasserted (logic high) or Asserted (logic low).
DTR State (write only)Sets the Data Terminal Ready (DTR) output signal to Unasserted (logic high) or Asserted (logic low).
Flow Control (read/write)Specifies the flow control method used for transmitting and receiving data. Valid values are None, Software XON/XOFF, Hardware RTS/CTS. DTR/DSR flow control is not available, but can be implemented using the DTR State and DSR State properties. Note that if Hardware (RTS/CTS) flow control is used, the RTS State write property cannot control the RTS state. The default is None.
Is Connected (read only)Returns TRUE if the port is properly connected to a valid RS232 signal on another port or device.
Parity (read/write)Specifies the parity used with every frame that is transmitted or received. Valid values are None (0), Odd (1), Even (2), Mark (3), and Space (4). The default parity is None.
RI State (read only)Returns the current state of the Ring Indicator (RI) input signal, either Unasserted (logic high) or Asserted (logic low). Modems often use the RI signal to indicate that the phone line is ringing.
RTS State (write only)Sets the Request To Send (RTS) output signal to Unasserted (logic high) or Asserted (logic low). This property cannot be changed when you set the Flow Control property to Hardware (RTS/CTS) or the Transceiver Mode property to 2 Wire Auto.
Stop Bits (read/write)Specifies the number of stop bits used to indicate the end of a frame. Valid values are 1, 1.5, and 2. You can select 1.5 only if you set Data Bits to 5, and you can select 2 only if you set Data Bits to 6, 7, or 8.
Note Note  Because a setting of 1.5 stop bits is invalid with any Data Bits setting other than 5, care must be taken to successfully transition to or from 1.5 stop bits. For example, if you have 8 data bits and 2 stop bits, and want to transition to 5 data bits and 1.5 stop bits, you will not be able to write either of the desired properties directly without getting an invalid property combinations error. Instead, move through a sequence of valid combinations to get to the desired settings. For this example, you would first set Stop Bits to 1, then set Data Bits to 5. At that point, Stop Bits may be reset to 1.5.
XOFF Character (read/write)Specifies the value of the XOFF character used for Software (XON/XOFF) flow control. The character is 1 byte wide, and may be passed as either a hexadecimal (0–FF) or decimal value (0–255).
Note Note  This property will only work if Flow Control is defined as Software XON/XOFF.
XON Character (read/write)Specifies the value of the XON character used for Software (XON/XOFF) flow control. The character is 1 byte wide, and may be passed as either a hexadecimal (0–FF) or decimal value (0–255).
Note Note  This property will only work if Flow Control is defined as Software XON/XOFF.

Module Properties

Use the FPGA I/O Property Node to access the following properties with this device. These properties have lower priority than port-specific methods or properties. In arbitration, the port-specific methods and properties will be executed before these properties.

Property Description
Module ID Returns the module ID. The module ID for the NI 9870 is 0x7305.
Serial Number Returns the unique serial number of the module.
Vendor ID Returns the National Instruments vendor ID, 0x1093.

Single-Cycle Timed Loop

This device does not support the single-cycle Timed Loop.

WAS THIS ARTICLE HELPFUL?

Not Helpful