Example Overview:
The USB-845x devices have 8 general purpose DIO lines as well as the needed lines for I2C and SPI communication. For an application where more digital output is needed and SPI communication is not being used, the Chip Select (CS) lines can be programmed to behave as digital outputs using this subVI.
This is implemented using the SPI Scripting API, which allows us to explicitly set the digital value high or low for each of the 6 CS lines.
Required Software and Hardware:
LabVIEW Base 2010 or newer
845x Driver 1.1.4 or newer
NI-8451 or 8452
Execution Instructions:
This VI is designed to be used as a subVI in a basic DIO application and included inside a while loop or for loop. Each time it executes it will create a script that sets a specific CS line to a specific logic level and run the script.
For a loopback test to verify this VI's functionality:
1. After plugging in your USB-845x device, open the NI Example Finder (LabVIEW > Help > Find Examples...) and browse to Hardware Input and Output > I2C and SPI > DIO Basic > Digital Line Read.vi example.
2. Choose the USB resource from the dropdown on the front panel and run the VI.
3. Connect a wire from CS0 terminal (pin 13) to the PO.0 terminal (pin 17). For a more complete pinout look here.
4. Open this VI and select the USB resource from the drop down on the front panel and run the VI.
5. Change the boolean value on the front panel of SPI_Scripting_CS_DO.vi and watch the indicator change on Digital Line Read.vi
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.