Professional Documents
Culture Documents
Lab UsbDigitalInputOutput082107
Lab UsbDigitalInputOutput082107
Photo: USB-6211 turns LED on or off Step 1: Place an array control on the empty VI. First, right click and then select Array, Matrix and Cluster control (see Figure 1-1A). Next drag and drop this control on the front panel (gray area).
Copyright Paul Oh
Step 2: Drag a toggle switch into the Array control. Right click, select the Boolean control, and select the Vertical Toggle switch (see Figure 1-2A). Drag this switch into the Array control (see Figure 1-2B).
Step 3: Wire up the block diagram. Invoke the DAQ Assist. In the block diagram window, right click and select Measurement I/O NI-DAQmx DAQ Assist (see Figure 1-3A). This will bring up the pop up box.
Copyright Paul Oh
In the pop up box (Figure 1-3B), click on Digital Output and select Line Output. The pop up box will refresh (Figure 1-3C). Select port1/line 0. This selection refers to the USB6211s first digital output line (recall, digital systems often start counting with 0). One will notice the USB-6211 has four digital lines (line0 to line3). Click Finish. The pop up box will refresh (Figure 1-3D). Make sure the Generation Mode reads 1 Sample (On Demand) and click OK. Save your program as usb6211DigitalOutput1_0.vi
Copyright Paul Oh
The pop up box will disappear and one can now drag the DAQ Assistant element into the block diagram. Select the wire tool and connect the Array elements output into the DAQ Assistants data input (see Figure 1-3E)
Figure 1-3E: Wire up the Array to the DAQ Assistant (digital output) Step 4: Physically wire up the LED circuit and run the program. Use a screwdriver to secure jumpers between the USB-6211 and solderless breadboard. Hook up the resistor and LED as shown in Figure 1-4 and refer to the schematic. Make sure LEDs cathode (short leg and flat end of the colored plastic housing) is hooked up to ground
Figure 1-4: Wiring photo and schematic. NB: LEDs negative end (cathode) goes to ground Execute the VI by clicking the Continuous Play (arrows in a circle) button on the Front end. Toggle the switch and note the LED turning on and off.
Copyright Paul Oh
+'ve COM
1.1. Set a multimeter to read current (up to 400 mA). Hook up the meters leads as shown in the figure. Toggle the switch from your Digital Output program usb6211DigitalOutput1_0.vi). What current does the multimeter read? This is called a source current. 1.2. If the digital output voltage is 5 Volts and the LED voltage is 0.7 Volts, what value resistor should one use? Hint: Use the source current value with Ohms Law. What value resistor was used in the experiment? 1.3. Search for sink current. Sketch a schematic where the USB-6211 digital line acts to sink current for the LED circuit. What are the advantages of sinking vs. sourcing current?
Copyright Paul Oh
Figure 2-1A: Create an array of integers Figure 2-1B: Select unsigned 32-bit integers
Step 2: Create the Block Diagram. Select the DAQ Assistant (recall Concept 1 Step 3). This time, select Port Output.
Copyright Paul Oh
Make sure the Generation Mode is set to 1 Sample (On Demand). See Figure 2-2C. Finish by wiring the Arrays output to the DAQ Assists data input (see Figure 2-2D). Save your program as usb6211DigitalOutputPort1_0.vi
Figure 2-2C: Select 1 Sample (On Demand) Step 3: Breadboard all 4 LEDs using the USB-6211s 4 digital output lines. Connect Ports P1.0 (pin 6) through P1.3 (pin 9) to resistors and LEDs as shown in Figure 2-3. Click the continuous play button. Cycle the numeric control from 0 to 15 to light LEDs.
Copyright Paul Oh
Exercise 2:
2-1. For usb6211DigitalOutputPort1_0.vi what happens over the numeric control is set to 16? What is this? 2-2. To light LED #0 and LED #3, what is the numeric control number? Hint: binary to decimal conversion. 2-3. Write a LabVIEW program with a For-Next structure that runs from 0 to 15 and lights up the LEDs in binary fashion. Hint: Use the Build Array element in the block diagram. Save as usb6211DigitalOutputPortWhileLoop1_0.vi
Copyright Paul Oh
Step 2: Wire a +5V digital input The USB-6211 has a built-in +5 Volt supply (on Pin 10). Refer to Figure 3-2 and execute the program. When Pin 10 is brought to Pin 1 (digital input P0.0), the front panel LED will light.
Exercise 3
3-1. Write and demonstrate a LabVIEW program that tells the user the state of all 4 digital input lines. Build upon usb6211DigitalInput1_0.vi to include 4 LEDs. 3-2. Consider the following schematic. Why is this the preferred method to set a digital input line HI or LO? Hint: a non-connected digital line does not mean GND.
Copyright Paul Oh