Writing and Reading to the DIO Port on USB-8451/8452

Updated Apr 25, 2023

Reported In

Hardware

  • USB-8451
  • USB-8452

Issue Details

I would like to read and write to the DIO port on the USB-8451/8452, but right now I can only read or write to one DIO line at a time. How do I read and write to the entire port?

Solution

This can be done by using the NI-845x Property Node:
Device reference is a reference to an NI 845x device that you are using.  

The DIO.ActivePort property sets the active DIO port for further DIO port configuration. The format for this property is a decimal string. For example, the string "0" represents DIO Port 0. For NI 845x devices with one DIO port, the port value must be set to zero.

The DIO.DriverType property configures the active DIO port with the desired driver type characteristics. DIO.DriverType uses the following values:
  • Open-Drain - Configures the port for an open-drain driver type.
  • Push-Pull - Configures the port for a push-pull driver type.
The IoVoltLevel property node sets the board voltage. The available options for the USB-8452 are as follows (USB-8451 only supports 3.3V):
  • 3.3V (Default)
  • 2.5V
  • 1.8V
  • 1.5V
  • 1.2V
The DIO.LineDirectionMap property sets the line direction map for the active DIO Port. The value is a bitmap that specifies the function of each individual line within the port. If bit x = 1, line x is an output. If bit x = 0, line x is an input. 

The default value of this property is zero (all lines configured for input). 

You can use the DIO.LineDirectionMap to specify writing or reading from a port. To perform this input, a binary segment of eight ones to write to the port or eight zeroes to read a port. 

Once you have done this, you can connect the Property Node to a read or write port VI as seen below:
 

Additional Information

  • Use NI-845x DIO Port Write VI in LabVIEW and ni845xDioWritePort function in other languages to write an 8-bit pattern to the selected DIO port. 
  • Use NI-845x DIO Port Read VI in LabVIEW and ni845xDioReadPort function in other languages to read an 8-bit pattern from the selected DIO port. 
  • Use NI-845x DIO Line Write VI in LabVIEW and ni845xDioWriteLine function in other languages to write a value to a particular line within the selected DIO port. 
  • Use NI-845x DIO Line Read VI in LabVIEW and ni845xDioReadLine function in other languages to read a value from a particular line within the selected DIO port. 
 
  • For basic reading and writing to DIO Ports on USB-8451/8452, see the NI Example Finder for Digital Line Read.vi and Digital Line Write.vi.