Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-12ni.comDigital I/O DevicesTo program digital I/O devices, you need to use both the NXTInput and NXTSyscall interfaces. You need both interfaces because digital and analog devices share the same physical ports.Digital I/O devices includes ultrasonic and temperature sensors.Digital I/O Port SetupFirst, use an NXTInput Property Node, to set the SensorType property of the port to a value compatible with the sensor. The NXT firmware supports the following two SensorType values for use with digital devices:•LOWSPEED—Use this type if the sensor does not require 9V power.•LOWSPEED_9V—Use this type if the sensor requires 9V power. These low-speed sensor types are for use with sensors using the I2C protocol to communicate with the NXT brick. The ultrasonic sensor included with NXT bricks requires 9V power, so use LOWSPEED_9V when you connect to this sensor.Remember that you also need to set the InvalidData property to TRUE after setting a new SensorType, then wait, using a While Loop, for the NXT firmware to set it back to FALSE. This process ensures that the firmware has time to initialize the port properly, including the 9V power lines, if applicable. Some digital devices might need additional time to initialize after power up.Low Speed Communication MethodsAfter the port is initialized, you need to access the I2C communication subsystem of the NXT firmware to communicate with the device.Use NXTSyscall refnums with invoke nodes to expose the interface to this communication system. The module provides the following three methods for low speed digital communication: NXTCommLSWrite, NXTCommLSCheckStatus, and NXTCommLSRead.The firmware uses a master/slave setup in which the NXT brick is always the master device. That is, the NXT firmware is responsible for controlling the write and read operations. The firmware maintains write and read buffers for each port, and the three system call methods provided enable you to access these buffers.