Summary: In this exercise, the objective is to control the digital I/O lines on the DAQ device. Complete the following steps to complete a VI that turns on the LEDs of Port 0 on the DAQ Signal Accessory based on the digital value set on the front panel. Each LED is wired to a digital line on the DAQ device. The lines are numbered 0, 1, 2, and 3, starting with the LED on the right.
EXERCISE 1
NOTE:
The LEDs use negative logic. That is, writing a1 to the LED digital line turns off the LED. Writing a 0 to the LED digital line turns on the LED.- Open the
Digital ExampleVI, located in theC:\Exercises\LabVIEW Basics Idirectory, and modify the block diagram as shown in Figure 1.Figure 1 Place the
DAQ AssistantExpress VI, located on theFunctions>>Inputpalette, in theWhile Loop. Complete the following steps to configure the counter to perform event counting.- Select
Digital I/O>>Port Outputfor the measurement to make. - Select
Dev1>>port0for the physical channel and click theFinishbutton. - In the
Digital Output Port Task Configurationdialog box that appears, selectInvert All Lines In Portbecause the LEDs use negative logic. - Click the
OKbutton to close the configuration dialog box. All of the settings specified for the task are saved internally in theDAQ AssistantVI.
Place the
Build Arrayfunction, located on theFunctions>>All Functions>>Arraypalette, on the block diagram. Wire theBuild Arrayfunction to theDAQ Assistant. Complete the wiring of the block diagram. The Boolean buttons on the front panel are stored in an array to simplify the code. TheArray Subsetfunction extracts only the first four elements in the array. The output of the array subset needs to be reversed because element 0 of the array is the most significant bit. The array is then converted to a number with theBoolean Array to Numberfunction, and converted into an array of one element. This value is passed to theDAQ AssistantExpress VI to write that value to the port. - Select
- Save the VI.
- Display the front panel and run the VI. Turn the Boolean LEDs on and off and observe the changes on the DAQ Signal Accessory.
- Stop and close the VI.
No comments:
Post a Comment