SPI and I2C Communication Using a CompactRIO or Industrial Controller

Updated May 2, 2023

Reported In

Hardware

  • NI-9401
  • NI-9402
  • CompactRIO Single-Board Controller
  • CompactRIO Controller
  • IC-3173

Issue Details

Is it possible to implement SPI or I2C communication using a CompactRIO or Industrial Controller?

Solution

CompactRIO

It is possible indeed. NI provides a free SPI and I2C driver API which uses the FPGA digital I/O lines to communicate with SPI or I2C devices.

When selecting the digital hardware there are three options to consider:
  • NI Single-Board RIO hardware works with both SPI and I2C drivers.
  • NI 9401 C Series module works best with SPI drivers.
  • NI 9402 C Series module works best with I2C drivers.

Industrial Controllers

The only option available is connecting an Ethernet RIO Expansion Chassis such as the NI-914x devices in order to have access to use C Series modules compatible with the protocol, for example, the options mentioned above.

Additional Information

I2C communication requires the device to tri-state the DIO lines on the fly. The NI-9401 is unable to do this without external hardware. NI thus recommends the NI-9402 for I2C communication.

This library is installed using VIPM. If you are using LabVIEW 2010 or later, ensure to disable Mass Compile before installing the driver. Otherwise, a broken VI will appear in the library VIs.
Complete the following steps to disable Mass Compile:
  1. Open VI Package Manager.
  2. Select Tools and then Options.
  3. Remove the checkmark from the Mass Compile VIs After Package Installation checkbox.
Note: Support for this product is provided on the NI Developer Forums at forums.ni.com