MEM 639 Real World Microcomputer Control 1 Hands-on Lab LabVIEW – NI-DAQ Analog Input and Output The USB-6211 provides eight differential 16-bit analog input channels and two 16-bit analog output channels. These serve to introduce data acquisition and signal generation concepts. Concept 1: Use an analog output VI to create a virtual variable DC power supply. Step 1: Create the front panel and block diagram From the Numeric Controls category, drag Knob and Meter controls into an empty VI front panel (see Figure 1-1A). Change their range to read -10 to +10 as follows. Right click over the knob and choose Properties – Scale and change the Minimum and Maximum ranges. Do the same for the meter. The block diagram, shown in Figure 1-1B uses a While loop. Figure 1-1B: Corresponding Block Diagram Figure 1-1A: DC Power Supply Front Panel Step 2: Configure DAQ Assistant for Analog Output Launch DAQ Assist. Choose Generate Signal, Voltage and ao0 (analog output channel 0) as shown in Figures 1-2A and 1-2B. Figure 1-2A: Select Analog Output - Voltage Figure 1-2B: Select analog output channel 0 1 © Copyright Paul Oh MEM 639 Real World Microcomputer Control 1 Configure the next pop up box to look like Figure 1-2C. The Signal Output Range has Max and Min values of 10 and -10 respectively. Also, set the Generation Mode to “1 Sample (On Demand)”. Figure 1-2C: Generation Mode set for 1 Sample (On Demand) Step 3: Attach a voltmeter and test program. Save program as usb6211AnalogOutput1_0.vi. Attach a voltmeter’s anode (positive lead) to the DAQ Pin 12 (AO0) and cathode (negative lead) to the DAQ Pin 11 (DGND). From the front panel, click the Play button (white arrow). Drag the knob to set various voltages. Observe that the panel’s meter reading corresponds to the same value displayed by the voltmeter. Exercise 1: In LabVIEW create programs for the following: 1.1. Create a sine wave function generator. Use two knobs to set the frequency in Hz and amplitude (0 to 10 Volts). Use a Waveform Graph control to display the sine wave. Hint: for the block diagram, employ the Sine Wfm element (click Signal Processing – Wfm Generation). Save file as usb6211FunctionGenerator1_0.vi. 2 © Copyright Paul Oh MEM 639 Real World Microcomputer Control 1 Concept 2: Employ an analog input channel to read a voltage divider circuit A potentiometer is a variable resistor. Audio systems often use pots for volume knobs. Reading the voltage drop across the pot’s wiper enables one to calculate resistance and thus determine the pot’s knob position. Such a setup is often used to build rotary and linear encoder circuits. The photo below shows that a pot is a 3legged device and can be used for a voltage divider. Recall that VB = RB VA RA + RB B Photo: A pot to sense knob position Step 1: Create a front panel and block diagram Figure 2-1A shows that two Numeric Indicators are used in the front panel to display the measured voltage VB and the calculated resistance RB . Note, these indicators are represented by DBL (doubles). The block diagram in Figure 2-1B is wired up accordingly. Figure 2-1A: Two numeric indicators Figure 2-1B: Block diagram displays voltage 3 © Copyright Paul Oh MEM 639 Real World Microcomputer Control 1 Step 2: Set up DAQ Assistant Figure 2-2B: Select ai0 Figure 2-2A: Select Analog Input Make sure the Acquisition Mode is set to “N Samples” as shown in Figure 2-2C. Also set the Sample Input Range to -10 to 10. Save file as usb6211VoltageDividor1_0.vi Figure 2-2C: Select “N Samples” 4 © Copyright Paul Oh MEM 639 Real World Microcomputer Control 1 Step 3: Breadboard the voltage divider Measure the pot’s total resistance by connecting an ohmmeter to the left and right leads (see Figure 2-3A). Use this value in the block diagram to represent RA + RB . Figure 2-3A: Pot max value (left and right leads) To measure resistance RA , connect one of the ohmmeter’s leads to the wiper. Verify that rotating the pot’s knob changes RA . Also measure RB and verify that RA + RB always equals the pot’s total resistance value. Step 4: Acquire the voltage divider reading and display. Figure 2-4A: Voltage drop measured on analog channel 0 5 © Copyright Paul Oh MEM 639 Real World Microcomputer Control 1 Refer to Figure 2-4A for the hookup. Attach the DAQ Pins 15 (+AI0) and 16 (-AI0) to the pot’s wiper and rightmost lead (furthest from the pot’s knob) to measure the voltage drop VB . Connect the DAQ Pin 10 (+5V) to the pot’s leftmost lead (closest to the pot’s knob). Connect the DAQ Pin 11 (DGND) to the pot’s rightmost lead. Execute the program by clicking the Continuous Play button on the front panel. Verify that changing the pot’s value changes the measured voltage and updates the calculated resistance value. Exercise 2: 2-1. Modify usb6211VoltageDivider1_0.vi to also measure the voltage drop VAB across resistor RA . Do this with analog input channel 1 (AI1). Display both acquired voltages ( VAB and VB ) and the calculated resistances ( RA , RB , RA + RB ). 6 © Copyright Paul Oh