From the course: Data Acquisition with LabVIEW

Digital input with DAQ Assistant - LabVIEW Tutorial

From the course: Data Acquisition with LabVIEW

Digital input with DAQ Assistant

- [Instructor] To demonstrate digital input with a DAC device, I'll use a button switch and a resistor as my digital signal source similar to the circuit I used previously to implement a digital edge start trigger. When the switch is open, the voltage at the input terminal will be raised to five volts, representing digital high. And when I press the button to close the switch the terminal will be tied to ground, representing digital low. I repeated this little switch circuit four times, connected to each of the four digital IO lines that are part of port one on my USB 6001. Now starting from a blank VI, I'll go to the measurement IO DAC MX palette and select the DAC assistant. I'll configure it to acquire signals and I'll choose digital input. I have the option to either acquire input on individual lines or using the entire digital port. For this demonstration, I'll select port input and then choose port one. If my DAC device supports hardware time digital acquisition then I could use finite or continuous sample modes. However, my USB 6001 only supports on-demand software timing for digital IO so I'll leave the acquisition mode as one sample on demand. I can check that the digital inputs are connected and working correctly from within the DAC assistant by clicking the continuous run arrow. The display here shows several different ways to view and interpret the input signals including as a hex value, as a binary value, or as a array of boolean indicators. I see that because of the way I wired the switches by default all of the digital inputs are high or true. Then when I press the buttons, they're connected to ground and become false. If I need the orientation of the inputs to be reversed for my application, I can select this little checkbox to invert all lines in the port. And now, all of the inputs are false by default and then turn true when I press the button. I'll click okay to save those changes. I'll right-click on the data output terminal and create an indicator. And I see that the indicator created is an array of integer values. It's an array because when configuring this task to use ports, I could have selected to use multiple ports. In that case, each port would be an element of the array. However, since I'm only using port one, this array will only have one element, which is a 32-bit integer representing the value of those input lines. Since there are only four lines on port one those four bits can represent values between zero and 15. I can convert the numeric representation of the port data into an array of booleans by going to the functions palette, boolean menu, and then selecting the number to boolean array function. If I try to connect that to my output I get a broken wire. I can't directly connect it to the data output because this function only takes a single numeric input, not an array. So I'll clear that broken wire. And then from the array palette, I'll use the index array function. I'll add a constant here to select the first element of that array. And I can pass that into the number to boolean array function. Now I'll right-click on the output from that converter function and create an indicator. I can see here that it created an array of boolean LEDs. And I'll stretch that out to expose more LEDs. And I'll make them a little bit bigger. Finally, I'll wrap this code in a while loop so it'll execute continuously. Right-click to create a stop button. And add a millisecond wait VI to limit the loop rate. Now when I run this program, as I press the buttons on my bread board, I see those input values displayed as both a number and the boolean LEDs on my front panel.

Contents