Beruflich Dokumente
Kultur Dokumente
Course Software Version 2.0 January 2009 Edition Part Number 323777D-01
Copyright 20042009 National Instruments Corporation. All rights reserved. Universities, colleges, and other educational institutions may reproduce all or part of this publication for educational use. For all other uses, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation. Trademarks National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section on ni.com/legal for more information about National Instruments trademarks. Other product and company names mentioned herein are trademarks or trade names of their respective companies. Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have no agency, partnership, or joint-venture relationship with National Instruments. Patents For patents covering National Instruments products/technology, refer to the appropriate location: HelpPatents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/legal/patents.
Worldwide Technical Support and Product Information ni.com National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100 Worldwide Offices Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599, Canada 800 433 3488, China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00, Finland 358 (0) 9 725 72511, France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000, Israel 972 3 6393737, Italy 39 02 41309277, Japan 0120-527196, Korea 82 02 3451 3400, Lebanon 961 (0) 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 (0) 348 433 466, New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60, Poland 48 22 328 90 10, Portugal 351 210 311 210, Russia 7 495 783 6851, Singapore 1800 226 5886, Slovenia 386 3 425 42 00, South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151, Taiwan 886 02 2377 2222, Thailand 662 278 6777, Turkey 90 212 279 3031, United Kingdom 44 (0) 1635 523545 For further support information, refer to the Additional Information and Resources appendix. To comment on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter the info code feedback.
Contents
Guide to Preparation for This Course Lesson 1 NI ELVIS II Workspace Environment
Exercise 1-1 Exercise 1-2 Measuring Component Values .........................................................1-3 Building a Voltage Divider Circuit on the NI ELVIS II Protoboard ...................................................................1-5 Exercise 1-3 Using the DMM to Measure Current................................................1-7 Exercise 1-4 Observing the Voltage Development of an RC Transient Circuit....1-8 Exercise 1-5 Visualizing the RC Transient Circuit Voltage..................................1-10 NI ELVIS II Challenge: Design a Burglar Alarm Using Multisim Simulation..........1-12
iii
Introduction to NI ELVIS
Contents
Contents
Introduction to NI ELVIS
vii
Introduction to NI ELVIS
intuitive circuit schematic and capture software into the NI ELVIS environment. Now you can take your design from paper or the blackboard and simulate it within Multisim as a classic schematic diagram on the NI ELVIS or NI ELVIS II breadboard layout. Once the design is mature, you can build the real circuit on an NI ELVIS II protoboard and test it with the same design tools (soft front panel [SFP] instruments) you used to hone the design. The best part is you can flip back and forth from the real circuit to the design circuit until you get it just right. Then you can use it for that special classroom demonstration, for the technician to build, or as a protoboard for production. You can do all of this with a laptop and the new NI ELVIS II system on a footprint about same size as your laptop. This is the way we should be teaching courses with high-quality design tools and lots of hands-on activities. In the classroom, NI ELVIS brings the material alive. In the lab, NI ELVIS shifts the design paradigm from what if to lets try it.
Introduction to NI ELVIS
viii
ni.com
The NI ELVIS II environment consists of the following components: Hardware workspace for building circuits and interfacing experiments NI ELVIS II software (created in NI LabVIEW software), which includes the following: Soft Front Panel (SFP) instruments LabVIEW Application Programmatic Interface (API) Multisim Application Programmatic Interface (API) With the APIs, you can achieve custom control of and access to NI ELVIS II workstation features using LabVIEW programs and simulation programs written within Multisim.
Goal
This lab introduces NI ELVIS II by showing how you can use the workstation to measure electronic component properties. Then you can build circuits on the protoboard and later analyze them with the NI ELVIS II suite of SFP instruments. This lab also shows how you can use Multisim to design and simulate a circuit before building the circuit on the NI ELVIS II workstation and controlling it with a LabVIEW program.
1-1
Introduction to NI ELVIS
Lab 1
Required Components
1.0 k resistor, R1, (brown, black, red) 2.2 k resistor, R2, (red, red, red) 1.0 M resistor, R3, (brown, black, green) 1 F capacitor, C Project resistors 7.5 k, 1 k, 2 k, 4 k, and 8 k nominal values
Introduction to NI ELVIS
1-2
ni.com
Lab 1
Exercise 1-1
3. Connect two banana-type leads to the digital multimeter (DMM) inputs [V ] and [COM] on the left side of the workstation. Connect the other ends to one of the resistors. 4. Click on the DMM icon within the NI ELVISmx Instrument Launcher to select the digital multimeter.
1-3
Introduction to NI ELVIS
Lab 1
You can use the DMM SFP for a variety of operations such as voltage, current, resistance, and capacitance measurements. Use the notation DMM[X] to signify the X operation. The proper lead connections for this measurement are shown on the DMM front panel. 5. Click on the Ohm button [] to use the digital ohmmeter function, DMM[]. Click on the green arrow [Run] box to start the measurement acquisition. Measure the three resistors R1, R2, and R3. Fill in the following data: R1 _______ (1.0 k nominal) R2 ______ (2.2 k nominal) R3 _______ (1.0 M nominal) To stop the acquisition, click on the red square [Stop] box.
Note If you click on the Mode box, you can change the {Auto} ranging to {Specify Range} and select the most appropriate range by clicking on the Range box.
Introduction to NI ELVIS
1-4
ni.com
Lab 1
Exercise 1-2
2. Connect the input voltage, Vo, to the [+5 V] pin socket. 3. Connect the common to the [GROUND] pin socket. 4. Connect the external leads to the DMM voltage inputs [V ] and [COM] on the side of the NI ELVIS workstation and the other ends across the 2.2 k resistor. 5. Check the circuit and then apply power to the protoboard by pushing the prototyping board power switch to the upper position []. The three power indicator LEDs, +15 V, 15 V, and +5 V, should now be lit and green in color.
1-5
Introduction to NI ELVIS
Lab 1
Note If any of these LEDS are yellow while the others are green, the resettable fuse for that power line has flipped off. To reset the fuse, turn off the power to the protoboard. Check your circuit for a short. Turn the power back on to the protoboard. The LED flipped should now be green.
6. Connect the DMM[V] test leads to Vo and measure the input voltage using the DMM[V] function. Press [Run] to acquire the voltage data. V0 (measured) _______________ According to circuit theory, the output voltage, V2 across R2, is as follows: V2 = R2/(R1+R2) * Vo. 7. Using the previous measured values for R1, R2 and Vo, calculate V2. Next, use the DMM[V] to measure the actual voltage V2. V2 (calculated) ________________ V2 (measured) ________________ 8. How well does the measured value match your calculated value?
Introduction to NI ELVIS
1-6
ni.com
Lab 1
Exercise 1-3
3. Select the function DMM[A] and measure the current. I (calculated) ________________ I (measured) ________________ 4. How well does the measured value match your calculated value?
1-7
Introduction to NI ELVIS
Lab 1
Exercise 1-4
5. Select DMM[V] and click on RUN. 6. When you power up the circuit, the voltage across the capacitor rises exponentially. Set the DMM voltage range to {Specify Range} [10 V]. Turn on the protoboard power and watch the voltage change on the digital display and on the %FS linear scale.
Introduction to NI ELVIS
1-8
ni.com
Lab 1
7. It takes about a few seconds to reach the steady-state value of Vo. When you power off the circuit, the voltage across the capacitor falls exponentially to 0 V. Try it! This demonstrates one of the special features of the NI ELVIS II digital multimeter it can still be used even if the power to the protoboard is turned off.
Note
1-9
Introduction to NI ELVIS
Lab 1
Exercise 1-5
Close NI ELVIS II and launch LabVIEW. From the NI ELVIS II program library folder, select RC Transient.vi. This program uses LabVIEW APIs to turn the variable power supply to a set voltage of +5 V for 5 s and then to reset the VPS voltage to 0 V for 5 s while the voltage across the capacitor is measured and displayed in real time on a LabVIEW chart.
Introduction to NI ELVIS
1-10
ni.com
Lab 1
This type of square wave excitation dramatically shows the charging and discharging characteristics of a simple RC circuit. 2. Take a look at the LabVIEW diagram window to see how this program works.
In the first frame of the four-frame sequence, the NI ELVISmx Variable Power Supplies VI (virtual instrument) outputs +5.00 V to the RC circuit on the NI ELVIS II protoboard. The next frame measures 50 sequential voltage readings across the capacitor at 1/10-second intervals. In the for loop, the DAQ Assistant takes 100 readings at a rate of 1000 S/s and passes these values to a cluster array (thick blue/white line). From the cluster, the data array (thick orange line) is passed on to the Mean VI. It returns the average value of the 100 readings. The average is then passed to the chart via a local variable terminal <<RC Charging and Discharging>>. The next frame sets
1-11
Introduction to NI ELVIS
Lab 1
the VPS+ voltage equal to 0 V. The last frame measures another 50 averaged samples for the discharge cycle. This program records one complete cycle of the charging and discharging of a RC circuit. To repeat the cycle, continuously place the above program inside a while loop.
Introduction to NI ELVIS
1-12
ni.com
Lab 1
The ON position of these switches (left side) signals when the door is closed. Click the switch to close or open a door or window. Your design consists of a power supply (+5 V), a digital multimeter, five resistors, and four switches. The four resistors, 1 k, 2 k, 4 k, and 8 k, are placed at the door or window locations with the resistor value as the address of that location. The circuit is a simple loop with the switches placed across the address resistors to simulate the opening and closing of a window or door. Finally, the resistor, R5, limits the current when all the switches are closed. The current limiting resistor value is taken as half of the value of all the address resistor values added in series (7.5 k). To view the circuit operation, click on Run and open (1) and close (0) each switch, one at a time, using the mouse cursor. Fill in the following table: R1 0 1 0 0 0 1 R2 0 0 1 0 0 1 R3 0 0 0 1 0 1 R4 0 0 0 0 1 1 Voltage 0.00
3.33
Each switch when opened generates a unique voltage, which, when read by the voltmeter, reveals which window or door is open. Now that the design is complete, you can transfer the design into the real world as a test circuit built on an NI ELVIS II protoboard. Select five resistors as close to the design values as you have available. Launch NI ELVIS DMM[] and measure the value for each of your chosen resistors. Fill in the following table of Real Resistor values: R1 _____________ (k) R2 _____________ (k) R3 _____________ (k) R4 _____________ (k) R5 _____________ (k)
1-13
Introduction to NI ELVIS
Lab 1
Now go back to Multisim and replace the nominal resistor values with the measured (real-world) resistor values by double-clicking on each resistor in turn and entering the measured value. This becomes your new Alarm Design Version 1.
You can now repeat your measurements of the predicted voltage readings when a window or a door is opened or closed.
Introduction to NI ELVIS
1-14
ni.com
Lab 1
Use these resistors and five jumpers or push button switches to construct a circuit similar to the one shown on a NI ELVIS II protoboard in the following figure.
Use the DMM[V] to verify its operation is similar to your real-world Multisim design, version 1.
LabVIEW Demonstration
LabVIEW is a powerful programming language that you can use for many tasks including the measurement and control of circuits built on an NI ELVIS II protoboard. With one modification to the above circuit, you can route the alarm voltage levels to a LabVIEW program. Connect the voltage + pin (orange wire) to [AI 0+] socket pin and the GROUND to [AI 0] socket pin. You can leave the DMM[V] connected if you wish to monitor the sensor voltage. The digital multimeter uses a different data acquisition card than NI ELVIS II analog inputs use. Imagine running the NI ELVIS suite of SFPs at the same time as a LabVIEW program is running.
1-15
Introduction to NI ELVIS
Lab 1
Launch LabVIEW and open the program House.vi for a unique view of the burglar alarm system.
To operate the program, click on Run. If NI ELVIS II is connected and turned ON and power is applied to the protoboard, actions on the protoboard are signaled on the LabVIEW front panel. Each switch is mapped to a particular window or door. When open, an entry port appears black. Any open door or window sets off a red alarm along the eves trough. To end the program, click on the Alarm Off front panel slide switch
Figure 1-15. The LabVIEW Block Diagram for the Program House.vi
Introduction to NI ELVIS
1-16
ni.com
Lab 1
The DAQ Assistant is programmed to read 100 consecutive voltage values at a rate of 1000 S/s. From the data cluster (blue/white line), select the array of voltages. The Mean.vi calculates the average value of this set of readings and sends it to the voltage trigger ladder. Whenever the voltage level falls between two limiting values (orange boxes), the corresponding condition is signaled on the front panel. The limiting values are picked as halfway between two neighboring trigger levels. The four-input OR function sets off the alarm if any door or window is opened. This design only detects the first occurrence of an open window or door. If you add a few more rungs to the limiting ladder, you can detect multiple openings and closings.
1-17
Introduction to NI ELVIS
Digital Thermometer
A thermistor is a two-wire device manufactured from a semiconductor material. It has a nonlinear response curve and a negative temperature coefficient. Thermistors make ideal sensors for measuring temperature over a wide dynamic range and are useful in temperature alarm circuits.
Goal
This lab introduces the NI ELVIS II variable power supply (VPS). You can use it with the workstation side panel controls or the virtual controls on your computer screen, or you can embed it inside a LabVIEW program. The VPS excites a 10 k thermistor in a voltage divider circuit. The voltage measured across the thermistor is related to its resistance, which, in turn, is related to its temperature. This lab demonstrates how you can use LabVIEW controls and indicators together with NI ELVIS APIs to build a digital thermometer.
2-1
Introduction to NI ELVIS
Lab 2
Digital Thermometer
Required Components
10 k resistor, R1, (red, black, orange) 10 k thermistor, RT
Introduction to NI ELVIS
2-2
ni.com
Lab 2
Digital Thermometer
Exercise 2-1
2-3
Introduction to NI ELVIS
Lab 2
Digital Thermometer
Exercise 2-2
In the default mode, you can control the VPS with the virtual panel shown above. Set the output voltage on the virtual knob and click on the [Run] box. The output voltage is shown (blue in color) in the display area above your chosen power supply. When you click on the stop button, the output voltage is reset to zero on the protoboard. To sweep the output voltage through a range of voltages, make sure that you have clicked the [Stop] button. Select the Supply Source (+ or ), Start Voltage, Stop Voltage, Step Size, and Step Interval, and click on [Sweep].
Note
For manual operation, click on the Manual box and use the knobs on the right side of the NI ELVIS II workstation to set the output voltages. To view the output voltage in the display area, click on the white box now appearing next to the LabVIEW label.
Introduction to NI ELVIS
2-4
ni.com
Lab 2
Digital Thermometer
2. Connect the leads from the protoboard strip connector sockets labeled Variable Power Supplies [Supply +] and [Ground] to the DMM voltage inputs. 3. Select DMM[V] and click on RUN. Select VPS front panel and click on RUN. 4. Rotate the virtual VPS control for Supply + and observe the voltage changes on the DMM[V] display.
Note
You can use the [RESET] button to quickly reset the voltage back to zero. 5. Click on the Manual box to activate the real controls on the right side of the workstation. The virtual controls are grayed out. Observe that the green LED Manual Mode on the NI ELVIS II workstation is now lit. 6. Rotate the + voltage supply knob and observe the changes on the DMM.
Note
2-5
Introduction to NI ELVIS
Lab 2
Digital Thermometer
Exercise 2-3
A Thermistor Circuit
Complete the following steps to build and test the thermistor circuit. 1. On the workstation protoboard, build a voltage divider circuit with the 10 k resistor and a thermistor. The input voltage is wired to [Supply +] and [Ground] sockets. The voltage across the thermistor goes to the DMM[V] leads.
Introduction to NI ELVIS
2-6
ni.com
Lab 2
Digital Thermometer
2. Make sure the Variable Power Supply voltage levels are set to zero. Apply power to the protoboard and observe the voltage levels on the DMM display. Increase the voltage from 0 to +5 V. The measured voltage across the thermistor, VT, should increase to about 2.5 V. 3. Reduce the power supply voltage to +3 V. This ensures that the self-heating (Joule heating) inside the thermistor does not affect the reading of the external temperature. 4. Heat the thermistor with your finger tips and watch the voltage decrease. You can rearrange the voltage divider equation to calculate the thermistor resistance as follows: RT = R1 * VT /(3 VT) At an ambient temperature of 25 C, the thermistor resistance should be about 10 k. With this equation, called a scaling function, you can convert the measured voltage into the thermistor resistance. You can easily measure VT with the NI ELVIS II DMM or within a LabVIEW program (VI). In LabVIEW, the above scaling equation is coded as a subVI and looks like the following block diagram.
The thermistor response curve demonstrates the relationship between device resistance and temperature. It is clear from this curve that a thermistor has the three following characteristics: The temperature coefficient R/T is negative. The response curve is nonlinear (exponential). The resistance varies over many decades (refer to Figure 2-2).
You can produce a calibration curve by fitting a mathematical equation to the response curve (see Appendix at the end of this chapter). LabVIEW has many mathematical tools to fit such a relationship. When you find the
2-7
Introduction to NI ELVIS
Lab 2
Digital Thermometer
correct equation, you can calculate the temperature for any resistance within the calibrated region. The following calibration VI is typical for a thermistor and demonstrates how you can use the LabVIEW formula node to evaluate mathematical equations.
Figure 2-7. For this thermistor, the calibration equation is R = 29.95798 exp(0.04452 T).
Introduction to NI ELVIS
2-8
ni.com
Lab 2
Digital Thermometer
Exercise 2-4
Thermistors like resistors create heat (Joule heating) as a current passes through them. For a thermistor that is trying to report the external temperature, this self-heating can be a problem. The trick is to minimize the current so that the temperature effects outside the thermistor dominate the
2-9
Introduction to NI ELVIS
Lab 2
Digital Thermometer
self-heating. For your 10 k thermistor, a driving voltage of +3 V meets this requirement. With a LabVIEW Express VI, you can program the VPS on the NI ELVIS II workstation. The value 3 in the orange box sets a +3.0 V output on VPS+. One extra line, green in color, connected to the STOP icon ensures the VPS is reset to zero volts when the program ends. Complete the following steps to open and view the components and code in the digital thermometer VI: 1. From the Hands-On NI ELVIS II library folder, open Digital Thermometer.vi. 2. Open the block diagram (WindowShow Block Diagram) and subVIs (double-click on the icons) to view the program flow and see how the subVIs and the Read and Convert functions are coded. With the calibration curve for your thermistor, you can update the subVI (Convert R-T) with the proper equation and use it to achieve a functioning digital thermometer. If you want to write your own program, find the VPS API function in the Functions palette (FunctionsMeasurement I/ONI ELVISmxNI ELVISmx Variable Power Supplies).
Introduction to NI ELVIS
2-10
ni.com
Lab 2
Digital Thermometer
2-11
Introduction to NI ELVIS
Lab 2
Digital Thermometer
Try placing the sensor between your thumb and forefinger for yourself and a group of your friends. You will be surprised at the range of finger temperatures. Have fun!
Introduction to NI ELVIS
2-12
ni.com
Lab 2
Digital Thermometer
2-13
Introduction to NI ELVIS
Lab 2
Digital Thermometer
Fill in the Resistance-Temperature Table from 0 to 100 degrees C in steps of 10 degrees in the following table. Resistance (W) Temperature (C) 0 10 20 30 40 50 60 70 80 90 100
Introduction to NI ELVIS
2-14
ni.com
Lab 2
Digital Thermometer
This program creates a graph of all the input data points (yellow dots) and performs the Least Squares Fit to a straight line (red line) by estimating the slope and intercept of the measured data.
2-15
Introduction to NI ELVIS
Lab 2
Digital Thermometer
Load the LabVIEW program Linear R-T.vi to view a simple subVI to convert your sensor measurement into temperature. This VI can also be used as a sub-VI in a digital thermometer program employing a TD5A sensor to take live temperature radings.
Figure 2-14. Front Panel for calibration VI for Linear RTD Type TD5A Note
For a Thermistor Temperature Sensor, the resistance of a thermistor varies exponentially with the temperature. In step 2 use a LabVIEW Exponential Fit function found in ProgrammingMathematicsFitting palette.
Introduction to NI ELVIS
2-16
ni.com
AC Circuit Tools
Many electronic circuits contain alternating current (AC). Designing good circuits requires tools to measure components, impedance values, and tools to display circuit properties. With good AC tools and minimal circuit knowledge, you can modify any circuit to achieve optimal response.
Goal
This lab introduces the NI ELVIS II tools for AC circuits: a digital multimeter, function generator, oscilloscope, impedance analyzer, and Bode analyzer.
3-1
Introduction to NI ELVIS
Lab 3
AC Circuit Tools
Required Components
1 k resistor, R, (brown, black, red) 1 F capacitor, C
Introduction to NI ELVIS
3-2
ni.com
Lab 3
AC Circuit Tools
Exercise 3-1
3-3
Introduction to NI ELVIS
Lab 3
AC Circuit Tools
Exercise 3-2
Introduction to NI ELVIS
3-4
ni.com
Lab 3
AC Circuit Tools
Complete the following steps to visualize this phasor in real time: 1. Select Impedance Analyzer (Imped) from the NI ELVISmx Instrument Launcher.
2. Place your components on the NI ELVIS II protoboard. 3. Connect jumpers from Impedance Analyzer DUT+ and DUT to the nominal 1 k resistor. 4. Turn on power to the NI ELVIS II protoboard and click on Run. 5. Verify that the resistor phasor is along the real axis and its Phase is zero. 6. Connect the Impedance jumpers to the capacitor. 7. Verify that the capacitor phasor is along the negative imaginary axis and its Phase is 270 or 90 degrees. 8. The default measurement frequency is 1000 Hz. Adjust the frequency value and observe that the reactance (length of the phasor) gets smaller when you increase the frequency and larger when you decrease the frequency. Recall |Xc| = 1/C. 9. Connect the Impedance jumpers across the capacitor and resistor in series. The phasor has now both a real and imaginary component. 10. Change the measurement frequency from 100, to 500, to 1000, to 1500 Hz and watch the phasor move. 11. Adjust the frequency until the magnitude of the reactance |Xc| equals the magnitude of the resistor, R. At this special frequency, the phasor phase reads 315 or 45 degrees. 12. What is the magnitude of the phasor ____________?
National Instruments Corporation 3-5 Introduction to NI ELVIS
Lab 3
AC Circuit Tools
Introduction to NI ELVIS
3-6
ni.com
Lab 3
AC Circuit Tools
Exercise 3-3
The power supply for an AC circuit is often a function generator. Use it to test your RC circuit.
3-7
Introduction to NI ELVIS
Lab 3
AC Circuit Tools
The FGEN SFP has controls, which can do the following: select the waveform type (sine, triangle, or square) set the frequency by rotating the Frequency dial or entering the frequency into a text box [Hz] select the waveform amplitude and any offset using the Amplitude and DC Offset controls
Function Generator real controls (Frequency) and (Amplitude) are also available on the right side of the NI ELVIS II workstation. As with the variable power supply, you can enable manual control by clicking on the Manual Mode box [ ]. A green LED on the right side of the workstation comes on to indicate manual control. The Frequency and Amplitude knobs are now active and the virtual controls are grayed out on the NI ELVISmx Function Generator window.
Note The Function Generator also provides some special operations such as signal modulation (AM or FM) or frequency sweeping. You will use these features in a later lab.
4. Set the Function Generator to Sine wave, 2000 Hz, 2 Vpkpk. Click on Run.
Introduction to NI ELVIS
3-8
ni.com
Lab 3
AC Circuit Tools
You can use the Scope SFP to visualize and analyze the voltage signals of the RC circuit. 5. From the NI ELVISmx Instrument Launcher, select the Scope icon.
The scope instrument SFP is similar to most oscilloscopes, but the NI ELVIS II oscilloscope can automatically connect inputs to a variety of sources, features built-in AC measurements and waveform cursors, and can easily log a waveform pattern. 6. Connect test leads from the CH0 BNC connector on the left side of the NI ELVIS II workstation across the 1 k resistor in your RC circuit. Apply power to the protoboard and click on the oscilloscope [Run] button. 7. You see a sine wave on the oscilloscope. Set the controls as follows: Scale CH0 500 mV/div Coupling CH0 AC Time base 500 s/div Trigger (Edge), Source (Chan 0 Source), Level (V) (0.1)
Check out the Channel 0 measurements RMS, Freq, and Vpkpk at the bottom of the waveform screen. You can activate cursors to measure time-related parameters such as period, duty cycle, and time intervals. 8. Play with the FGEN controls (virtual or real) and observe the changes on the oscilloscope window.
3-9
Introduction to NI ELVIS
Lab 3
AC Circuit Tools
9. Connect another set of test leads from Scope CH1 to the Function Generator SYNC pin socket and GROUND on the protoboard. SYNC is a TTL 5 V signal often used for triggering. 10. Click the Scope CH1 enable box [ ]. You see a new signal (blue in color) and at TTL levels. For reference, see the oscilloscope picture at the start of this lab, Figure 3-1. 11. The RC circuit is a passive highpass filter with a low-frequency cutoff point near 160 Hz. You can visualize the filter parameters using the FGEN Sweep Frequency feature. Set the oscilloscope at the above settings. Set the FGEN controls to the following: Start Frequency 5 Hz Stop Frequency 5 kHz Step 50 Hz
Click on the Function Generator [Stop] button and then click on the [Sweep] button. 12. Observe how the filtered signal CH 0 changes with respect to the SYNC CH 1 signal in both amplitude and phase as the frequency is swept. At low frequencies, the signal CH 0 is smaller in amplitude and not in phase with the SYNC signal. At higher frequencies, the amplitude is close to the function generator amplitude and the two signals are in phase. 13. Close the Function Generator and Oscilloscope windows.
Introduction to NI ELVIS
3-10
ni.com
Lab 3
AC Circuit Tools
Exercise 3-4
3-11
Introduction to NI ELVIS
Lab 3
AC Circuit Tools
3. Verify that your circuit is connected as above. Turn on the protoboard power and click on the [Run] button.
4. Click on the [ ] Cursors On box. You can step through your measured data points and view the magnitude and phase at each frequency measured. 5. Note the frequency where the signal amplitude has fallen to 3 dB. The phase at this point should read approximately 45 degrees. This frequency is called the lowpass cutoff point. 6. Both the oscilloscope and the Bode analyzer SFPs have a Log button. When activated, the data presented on the graphs is written to a spreadsheet file on your hard drive. You can now read this data for further analysis with Excel, LabVIEW, NI DIAdem, or some other analysis or plotting program. 7. Click on the [Log] button and save your data set.
Introduction to NI ELVIS
3-12
ni.com
Lab 3
AC Circuit Tools
View an example data set like the one below when you click the Log button after a frequency scan.
3-13
Introduction to NI ELVIS
Lab 3
AC Circuit Tools
7. On completion, click on the [Save] button. This saves the Multisim Bode plot data as an Excel file. 8. Overlay, in Excel, your data set from Multisim with the data set taken in Exercise 3-4 for the real circuit on NI ELVIS II. This exercise demonstrates how you can compare a circuit designed with Multisim with the real circuit built on NI ELVIS II.
Introduction to NI ELVIS
3-14
ni.com
Op Amp Filters
Adding a few capacitors and resistors to the basic operational amplifier (op amp) circuit can yield many interesting analog circuits such as active filters, integrators, and differentiators. Filters are used to pass specific frequency bands, integrators are used in proportional control, and differentiators are used in noise suppression and waveform generation circuits.
Goal
This lab uses the NI ELVIS II suite of instruments to measure the characteristics of lowpass, highpass, and bandpass filters. Simulate these filters using Multisim with the measured component values. In the lab challenge at the end of this chapter, Multisim is used to design a second order active filter.
4-1
Introduction to NI ELVIS
Lab 4
Op Amp Filters
Required Components
10 k resistor, R1, (brown, black, orange) 100 k resistor, Rf , (brown, black, yellow) 1 F capacitor, C1 0.01 F capacitor, Cf 741 op amp
Introduction to NI ELVIS
4-2
ni.com
Lab 4
Op Amp Filters
Exercise 4-1
4-3
Introduction to NI ELVIS
Lab 4
Op Amp Filters
Exercise 4-2
Figure 4-2. Schematic Diagram of a 741 Inverting Op Amp Circuit with a Gain of 10
Figure 4-3. 741 Inverting Op Amp Circuit with a Gain of 10 on an NI ELVIS protoboard
Introduction to NI ELVIS
4-4
ni.com
Lab 4
Op Amp Filters
Note The op amp uses both the +15 and 15 VDC power supplies. These are found on the protoboard pin sockets labeled as DC Power Supplies +15V, 15V & GROUND.
2. Connect the function generator [FGEN] pin socket to the op amp input V1. 3. Connect the [Ground] pin socket to pin 3 of the op amp. 4. Connect the op amp output voltage, Vout, to the oscilloscope BNC input connector [CH1 & Ground]. 5. From the NI ELVISmx Instrument Launcher, select the function generator (FGEN) icon and the oscilloscope (Scope) icon.
Note By default, on the oscilloscope, the Channel 0 Settings Source is set to Scope Ch 0 and the Channel 1 Settings Source is set to Scope Ch 1. These are your op amp input and output signals, respectively.
6. To view the signals, click on the enable boxes. 7. On the function generator panel, set the following parameters: Waveform: Sine wave Peak Amplitude: 0.2 pp Frequency: 1000 Hz DC Offset: 0.0 V 8. Check your circuit and then apply power to the NI ELVIS II protoboard. 9. Click on [Run] for both the FGEN and Scope SFPs. 10. Set the trigger to Edge, CH 0, Level 0.0 and the Time/Div to 1 ms. 11. Measure the amplitude of the op amp input (CH 0) and output (CH 1) on the oscilloscope window.
4-5
Introduction to NI ELVIS
Lab 4
Op Amp Filters
The output signal is inverted as expected with respect to the input signal. 12. Calculate the voltage gain (the amplitude ratio, CH1/CH0). 13. Try a range of frequencies from 100 Hz to 10 kHz. How do your measurements agree with the theoretical gain of (Rf/R1)? Is the ratio still the same at 100 kHz? 14. Close the FGEN and Scope windows.
Introduction to NI ELVIS
4-6
ni.com
Lab 4
Op Amp Filters
Exercise 4-3
3. On the Bode analyzer, set the scan parameters as follows: Start: 5 (Hz) Stop: 20000 (Hz) Steps: 10 (per decade) 4. Apply power to the protoboard. 5. Click [Run] and observe the Bode plot for the inverting op amp circuit. 6. Take a close look at the phase response.
4-7
Introduction to NI ELVIS
Lab 4
Op Amp Filters
The gain (20 dB) is flat and independent of frequency until approximately 10,000 Hz, where it starts to roll off as shown in Figure 4-5. This Bode plot is typical for a 741 op amp inverting circuit. At high frequencies, the amplifier response depends on its internal circuitry as well as any external components.
Introduction to NI ELVIS
4-8
ni.com
Lab 4
Op Amp Filters
Exercise 4-4
Highpass Filter
A low frequency cutoff point, fL, for a simple RC series circuit is given by the equation: 2fL = 1/(RC) where fL is measured in hertz. The low-frequency cutoff point is the frequency where the gain (dB) has fallen by 3 dB. This (3 dB) point occurs when the impedance of the capacitor equals that of the resistor. 1. Add a 1 F capacitor, Cl, in series with the 1 k input resistor, R1, in the op amp circuit as shown in Figure 4-6.
The highpass op amp filter equation has a low-frequency cutoff point, fL, where the gain has fallen to 3 dB. In other words, when Xc = R: 2fL = 1/ (R1C1)
4-9
Introduction to NI ELVIS
Lab 4
Op Amp Filters
2. Run a second Bode plot using the same scan parameters as in Exercise 4-3. 3. Observe that the low-frequency response is attenuated while the high-frequency response is similar to the basic op amp Bode plot.
Introduction to NI ELVIS
4-10
ni.com
Lab 4
Op Amp Filters
4. Use the cursor function to find the low-frequency cutoff point, that is, the frequency at which the amplitude has fallen by 3 dB or the phase change is 45 degrees. 5. Compare your results with the following theoretical predication: 2fL = 1/ (R1C1)
4-11
Introduction to NI ELVIS
Lab 4
Op Amp Filters
Exercise 4-5
Lowpass Filter
The high-frequency roll-off in the op amp circuit is due to the internal capacitance of the 741 chip being in parallel with the feedback resistor, Rf. If you add an external capacitor, Cf, in parallel with the feedback resistor, Rf, you can reduce the upper frequency cutoff point. It turns out that you can predict this new cutoff point from the following equation: 2fU = 1/(Rf Cf) Complete the following steps to perform an additional frequency measurement on the op amp circuit: 1. Short the input capacitor (do not remove it because you will use it in Exercise 4-6). 2. Add the feedback capacitor, Cf, (0.01 f) in parallel with the 100 k feedback resistor.
Introduction to NI ELVIS
4-12
ni.com
Lab 4
Op Amp Filters
Figure 4-10 shows that the high-frequency response is attenuated much more than the basic op amp response. 4. Use the cursor function to find the high-frequency cutoff point, that is, the frequency at which the amplitude has fallen by 3 dB or the phase change is 45 degrees. 5. Compare your results with the following theoretical prediction: 2fU = 1/ (Rf Cf)
Note Note the 90-degree phase change from the very low-frequency range to the upper-frequency range. This is as expected for a single-pole RC filter stage.
4-13
Introduction to NI ELVIS
Lab 4
Op Amp Filters
Exercise 4-6
Bandpass Filter
If you allow both an input capacitor and a feedback capacitor in the op amp circuit, the response curve has both a low-cutoff frequency, fL, and a high-cutoff frequency, fU. The frequency range (fU f L) is called the bandwidth. For example, a good stereo amplifier has a bandwidth of at least 20,000 Hz. Figure 4-11 shows a bandpass filter on an NI ELVIS II protoboard.
Introduction to NI ELVIS
4-14
ni.com
Lab 4
Op Amp Filters
Using the cursors, draw a line between the 3 dB points. All frequencies with an amplitude above this line are contained within the frequency pass band. How does this bandwidth measurement agree with the theoretical prediction of (fU fL)?
4-15
Introduction to NI ELVIS
Lab 4
Op Amp Filters
Zf R1
Z1 R f /R 1
Gain
R1 + XC1 R1 R1 + XC1
Rf + XCf Rf + XCf
At any frequency, you can use the impedance analyzer (Imped) to measure the impedances Zf and Z1. A LabVIEW program can calculate the ratio of two complex numbers. The magnitude of the ratio |Zf /Z1| is the gain. You could also use the impedance analyzer to find the frequencies where R1 equals XC1 and Rf equals XCf to verify that the lower- and upper-frequency cutoff points from the Bode plot are equal to these frequencies.
Note
Introduction to NI ELVIS
4-16
ni.com
Lab 4
Op Amp Filters
This filter has two cutoff points fc1 = (R1||R2)/(2C1) and fc2 = (2R3C2)1 In the special case when fc1 = fc2 = fc, the gain expression for this filter becomes R3 ( R1 + R2 ) G = -----------------------------------2 1 + (f fc) 2. Pick resistors and capacitors to satisfy the special case requirement that fc1 = fc2 = 1000 Hz
4-17
Introduction to NI ELVIS
Lab 4
Op Amp Filters
3. Launch the Multisim program Two Pole Active Filter. 4. Double-click on the Bode analyzer icon to open a results window. 5. Run this program and view the Bode plot.
6. From the graph of the gain, estimate the slope of the roll-off curve (should be 40 dB/decade). 7. Modify this program with your component values. 8. Compare the slope of the roll-off curve with the previous result in Exercise 4-5 for a single-pole lowpass filter. 9. If you have the time and components, try building a real two-pole circuit on the NI ELVIS II protoboard. How well does the Bode plot of the theoretical design match your real circuit? Refer to the Lab 3 Multisim Challenge to recall how to overlay in Excel a theoretical design curve with a measured real curve.
Introduction to NI ELVIS
4-18
ni.com
Digital I/O
5
Digital electronics is the heart and soul of modern computers. The ability to set and read digital lines is essential to digital circuit diagnostics.
Goal
This lab focuses on NI ELVIS II digital tools, such as a digital clock, digital counter, and a logic state analyzer, to study digital circuits.
5-1
Introduction to NI ELVIS
Lab 5
Digital I/O
Required Components
10 k resistor, RA, (brown, black, orange) 100 k resistor, RB, (brown, black, yellow) 0.1 F capacitor, C 1 F capacitor, C 555 timer chip 7493 4-bit binary counter
Introduction to NI ELVIS
5-2
ni.com
Lab 5
Digital I/O
Exercise 5-1
Note
The digital I/O lines are located on the right side of the protoboard. 2. Launch the NI ELVISmx Instrument Launcher. 3. Select the Digital Writer (DigOut) icon. A new digital logic diagnostic window opens, so you can set/reset any of the digital lines to a HI or LO state. By default, the digital I/O lines <0..7> are selected from the three 8-bit ports in the Lines to Write box.
5-3
Introduction to NI ELVIS
Lab 5
Digital I/O
The digital output lines are labeled 0 to 7 reading right to left in the Manual Pattern box. You can set/reset (HI/LO) any bit by clicking on the top or bottom portion of the virtual switch. Collectively, these 8 bits constitute a byte that can be read in a binary, octal, hexadecimal, or decimal format, or in an SI notation in the display box above the switches. By clicking on the grayed-out portion, you can set the radix (format) of this indicator.
4. After you have set a digital pattern, turn on the power to the protoboard and click Run (green arrow) to send the pattern to the parallel output digital I/O lines <0..7>, which in turn are passed on to the green LEDs. You can set the Generation Mode to output a single pattern or to continuously output the pattern. In continuous operation, the hardware is updated continuously with the current pattern.
Note
The set pattern is echoed on the line states (blue LED indicators) of the Bus State on the SFP. Also, with the Action buttons of the SFP, you can toggle, rotate, or shift the bit pattern right or left. 5. Press the Stop button (red box) to cease updating the port. In testing a digital circuit, you can select from several commonly used patterns for diagnostic checks. 6. Click the Pattern selector on the SFP to view the options available. Manual Ramp (0 255) Alternating 1/0s Walking 1s Load any 8-bit pattern Computer Instruction INC Computer Instruction INVERT Computer Instruction SHIFT LEFT LOGIC
7. Try to output each bit pattern. 8. Close the Digital Writer window.
Introduction to NI ELVIS
5-4
ni.com
Lab 5
Digital I/O
Exercise 5-2
Complete the following steps to build and perform measurements on a 555 digital clock circuit: 1. Using the DMM[] and DMM[ complete the following table. ], measure the component values and
5-5
Introduction to NI ELVIS
Lab 5
Digital I/O
Power (+5 V) goes to pins 8 and 4, and GROUND goes to pin 1. The timing chain of RA, RB, and C straddles the power supply. It has a connection between the resistors going to pin 7 and a connection between RB and C going to pins 2 and 6. 3. Wire the 555 output pin 3 to one of the port pin sockets, DIO <0>. 4. From the NI ELVISmx Instrument Launcher, select the Digital Reader (DigIn) icon. By default the second 8-bit port is set to input (Lines to Read 8-15). 5. Configure Lines to Read to (0-7), enable power to the protoboard, and click Run.
Introduction to NI ELVIS
5-6
ni.com
Lab 5
Digital I/O
The Digital Reader allows the current state of a parallel input port to be read on demand (single shot) or continuously. You should see the state of line 0 flashing. If not, click on the Stop button and use the DMM[V] to check voltage levels on the 555 pins (stop the Digital Reader first). With the clock circuit running, you can now make some useful digital circuit measurements. The 555 timer oscillator circuit has a Period T of T = 0.695 (RA + 2 RB) C (seconds) The 555 timer oscillator frequency is related to the period by F = 1/T (Hz) The 555 timer oscillator circuit has an On time of T = 0.695 (RA + RB) C (seconds) The 555 timer oscillator circuit has a Duty Cycle (On time/period) of DC = (RA+ RB) / (RA + 2 RB) 6. Close all SFPs and launch the Oscilloscope (Scope) icon.
5-7
Introduction to NI ELVIS
Lab 5
Digital I/O
7. Connect the front panel BNC CH 0 input leads to pin 3 of the 555 timer chip and any ground. Click Run. You should now be observing the digital waveform on Channel 0 of the oscilloscope. 8. Select Trigger Type: Edge, Source: Chan 0 Source and Level (V) to 1.0. Your signal should be a TTL signal with an amplitude of 4 V or more, and the signal should be steady. 9. Observe the frequency in the scope window for CH 0. 10. Click on the Cursors On box and note that C1 and C2 are set to CH 0. 11. By clicking and dragging the cursors, measure the period, the on time, and the duty cycle. Calculate the frequency from the period measurement. 12. Fill in the following table: T = __________________ (seconds) Ton = __________________ (seconds) DC = __________________ F = __________________ (Hz) 13. Compare your measurements with the previous theoretical predictions. 14. Close any SFPs.
Introduction to NI ELVIS
5-8
ni.com
Lab 5
Digital I/O
Exercise 5-3
3. On the 7493 binary counter chip, connect +5 V power to pin 5 and ground to pin 10. 4. Ensure that 0set inputs pins 2 and 3 are grounded. 5. Connect the outputs Q1, Q2, Q4, and Q8 to the LED and digital input ports of the NI ELVIS II protoboard using the following mapping scheme: Q1 pin 12 Q2 pin 9 Q4 pin 8 Q8 pin 11 555 pin 3 to to to to to DIO<0> and LED<0> DIO<1> and LED<1> DIO<2> and LED<2> DIO<3> and LED<3> DIO<7> and LED<7>
5-9
Introduction to NI ELVIS
Lab 5
Digital I/O
6. Connect the 555 digital clock output (pin 3) to the 7493 Clock 1 (C1) input (pin 14). For this exercise C = 0.1 F in the circuit above. 7. Power the protoboard and watch the binary counts accumulate on the LEDs. 8. Launch the NI ELVISmx Digital Reader (DigIN) icon. Monitor the binary states on the computer screen, and, at the same time, see the states on the green LEDs on the protoboard. 9. Close the NI ELVISmx Instrument Launcher.
Introduction to NI ELVIS
5-10
ni.com
Lab 5
Digital I/O
Exercise 5-4
Using the LabVIEW APIs for the digital I/O, you can build a simple 4-bit logic state analyzer. The Digital I/O palette is located in Functions ProgrammingMeasurement I/ONI ELVISmxNI ELVISmx Digital Reader.
5-11
Introduction to NI ELVIS
Lab 5
Digital I/O
Launch LabVIEW 8.5 and then open Binary CounterMx.vi from the Hands-On-NI ELVIS II library folder. On the diagram panel, the NI ELVISmx Digital Reader has been initialized to use lines 0 to 7 (blue ring constant) for input from the protoboard.
Note In this example, the NI ELVIS USB communication port is Device 3. Depending on how many DAQ cards you have in you computer, it could be Device 1, 2, or 3. With only the NI ELVIS USB port available, it would be Device 1.
Introduction to NI ELVIS
5-12
ni.com
Lab 5
Digital I/O
The 4-bit logic state analyzer samples NI ELVIS lines <0..7> and presents the line states as a Boolean array (thick green line). The index arrays extract bits <0..3> (Q1, Q2, Q3, Q4) to the respective trace indicators and then into a numeric value (0 or 1) for bundling with the other traces for the timing diagram plot. With the many LabVIEW chart format options, you can present the data in a timing diagram format. A copy of the data also goes to the AND gate, where bits <4..7> are set to zero. The resultant data is converted to a numeric (0 to 15) and presented on the front panel.
5-13
Introduction to NI ELVIS
Lab 5
Digital I/O
2. Double-click on the scope icon XSC2. A 4-channel oscilloscope display appears. 3. Run this simulation by clicking on the green arrow. Observe that the 4-channel display is similar to the real circuit built on an NI ELVIS II protoboard. Stop the simulation by clicking on the red square. 4. Open a second program called Decimal Counter. This program replaces the binary counter with a decimal counter (7490N), adds a 7-segment driver (7447N) IC, and adds a 7-segment display. Note that the current limiting resistors for the 7-segment LEDs are found in the resistor pack.
Introduction to NI ELVIS
5-14
ni.com
Lab 5
Digital I/O
6. Stop the simulation and add a second 7490N, a 7448N, a resistor pack 330 , and a 7-segment display to the Multisim circuit. You can implement this with a simple copy and paste of the components already on the circuit diagram. Alternatively, you can find a list of components by browsing to PlaceComponent. 7. Connect the output QD of the first counter chip (7490N) to the input INA of the second counter chip (7448N). Together these chips form a two-digit counter counting from 00 to 99. 8. Connect the other virtual wires to the added chips to build a two-digit decimal counter. 9. Run the simulation.
5-15
Introduction to NI ELVIS
6
+ X X X X B in X I X X X X X X X X X X q
X I X X X X X
F X X X X X X X X X X Vd
+++++++++++++ I X X
In 1879, Erwin Hall discovered that when a current flows through a block of semiconductor material in the presence of a magnetic field, a voltage is generated across it. He found that this voltage, now named after him, is proportional to the vector cross product of the current flowing through the sensor and the magnetic field. The proportionality constant is a property of the Hall effect sensor. VH = I B This means that you can use a Hall probe to measure current, magnetic field, or the angle between the sensor axis and an external field direction. Today, integrated Hall effect sensors have an internal constant current source and an operational amplifier (op amp) to buffer the output signal. These sensors are inexpensive, robust, and can be interfaced to both analog and digital circuits.
X X X
Goal
This lab focuses on using NI ELVIS tools to study the properties of Hall effect sensors. During the lab, build a simple gaussmeter and a digital counter interface using a linear Hall effect sensor and a Hall effect switch, respectively. Complete the Multisim challenge to learn how to design a tachometer circuit using a Hall effect switch as the sensor.
National Instruments Corporation 6-1 Introduction to NI ELVIS
Lab 6
Required Components
Small magnet Linear magnetic field sensor: Allegro A3240UA or equivalent Hall effect switch: Allegro A3212UA or equivalent
Introduction to NI ELVIS
6-2
ni.com
Lab 6
Exercise 6-1
5. Launch the NI ELVISmx Instrument Launcher and select DMM[V]. 6. Bring a small magnet (field intensity of several hundred gauss) in close proximity to the Hall sensor face. In the absence of a magnetic field, the sensor reads one-half of +Vcc or about +2.5 V. As the magnet is moved closer to the sensor, the Hall voltage either rises greater than 2.5 V or falls to less than 2.5 V, depending on the magnet polarity. The south end of the magnet causes a rise and the north end causes a fall. The sensor saturates near +5 or 0 V in a field in excess of 500 gauss. The Hall voltage is quite nonlinear when measured with respect to the distance between the sensor and the magnet face. 7. To observe this relationship, make distance and voltage measurements and plot your observations. The distance between adjacent pin socket holes is 1/10 of an inch. The protoboard pin sockets make a good ruler. 8. Place the magnet on the protoboard directly in front of the sensor and measure the Hall voltage in 0.1 or 0.05 in. increments over a distance of about 1 inch.
6-3
Introduction to NI ELVIS
Lab 6
9. Record each reading in a table of Hall voltage and distance. 10. Plot the Hall voltage versus distance using data from your table.
The plot should be similar to the graph in Figure 6-3. The response is nonlinear, which demonstrates the importance of knowing the operating distance between the sensor and the magnet.
Introduction to NI ELVIS
6-4
ni.com
Lab 6
Exercise 6-2
Note Some Hall effect switches are Open Collector and require a 1 k pull-up resistor to be connected between the Hall effect switch output and the power supply line.
3. Plot the data for both moving away from and moving toward the sensor on the same set of axes. It should look similar to Figure 6-4.
The Hall switch is a digital sensor whose output is either HI (~ +5 V) or LO (0.8 V). The output is always HI for B greater than a critical field Bmax, and LOW for any field less than a critical field Bmin. A graph of Hall voltage versus distance from the sensor demonstrates hysteresis between approaching the sensor and moving away from the sensor. The difference between the two limits: h = Bmax Bmin is a measure of the noise immunity of the sensor. For example, the Hall switch requires a field B>Bmax to switch from LO to HI. Once in the HI state, the Hall switch requires a field B<Bmin to switch
6-5
Introduction to NI ELVIS
Lab 6
from HI to LO. In your earlier test, these critical fields, Bmax and Bmin, are translated into a distance DLO to HI (3/10 of an inch) and LHI to LO (4/10 of an inch), respectively. 4. Close the digital multimeter.
Introduction to NI ELVIS
6-6
ni.com
Lab 6
Exercise 6-3
6-7
Introduction to NI ELVIS
Lab 6
Exercise 6-4
Building a Tachometer
An angle shaft encoder, a tachometer, and a dwell sensor all use magnetic switches to generate pulses. Counting pulses accumulates events. Counting pulses within a select time interval measures frequency.
Complete the following steps to build a simple tachometer using a DC motor, a CD disk, a small magnet, and a Hall effect switch. 1. Affix an old CD to the rotor of a DC motor. Near the perimeter of the CD, glue a small rare earth magnet to the upper surface. Place your Hall effect switch below the CD so that the magnet passes over the switch as it rotates. 2. Connect the DC motor to the output of the variable power supply (Supply + and Ground) pin sockets on the protoboard. 3. Launch the variable power supply VPS from the NI ELVISmx Instrument Launcher. Click on the box Supply + Manual. It is easier to control the DC motor speed with the real VPS knob on the right side of the NI ELVIS II workstation than with the virtual voltage knob on the VPS front panel. 4. Apply a moderate voltage (1 to 2 V) to your motor. 5. Using the same oscilloscope setting as in Exercise 6-3, observe the pulse stream as the CD spins. 6. Record the pulse frequency from the Scope panel at the bottom of the oscilloscope screen window. This is the tachometer reading.
Introduction to NI ELVIS
6-8
ni.com
Lab 6
7. (Optional) Record a number of tachometer readings at a variety of motor voltages. A plot of the tachometer measurements versus motor drive voltage produces a calibration curve for your motor. 8. Close all SFPs and remove the voltage probe.
6-9
Introduction to NI ELVIS
Lab 6
Exercise 6-5
2. Launch LabVIEW. 3. From the Hands-On NI ELVIS II library folder, select Hall CounterMx.vi. With this simple program, you can accumulate counts as a magnetic field that is passed in and out from the Hall effect switch or over the Hall effect switch using the tachometer circuit. Dividing the accumulated counts by the elapsed (count) time generates the average time per count or the frequency.
Introduction to NI ELVIS
6-10
ni.com
Lab 6
NI ELVIS II has access to the NI data acquisition (DAQ) device counters. This program uses the DAQ Assistant to set up the DAQ for counting pulses on input pin (CTRO_Source). The difference between the two [Tick Count] functions measures the counting interval.
6-11
Introduction to NI ELVIS
Lab 6
Using the program in Figure 6-8 as a guide, design your own tachometer program. Input is the rate of rotation, and the output of the Hall effect switch is counts. Accumulating counts over a fixed period of time (about 1 second) yields counts/second or the frequency of counts.
Introduction to NI ELVIS
6-12
ni.com
Have you ever sat in your car stopped at a city intersection waiting for the stoplight to change and wondering how long the red light will last? Sometimes it seems like forever. Using a stop watch at a simple two-way intersection, you will find red lasts for 30 seconds, green lasts for 25 seconds, and yellow lasts for 5 seconds. In some states, these times may be two, three, or four times as long, but the ratios are always the same. A property of an electronic diode is that in one direction current flows easily (forward biased), while in the other direction current flow is blocked. Light emitting diodes (LEDs) have the same property, but in the forward-biased region light is given off and in the reverse-biased region the LED is dark. Today, LEDs are used as the primary light elements in stoplights, so understanding how they operate is useful.
Goal
This lab focuses on using NI ELVIS II to illuminate diode properties, diode test methods, bit patterns for a two-way stoplight intersection, and the use of NI ELVIS II APIs in a LabVIEW program to run the stoplights automatically. A Multisim challenge encourages the reader to design a two-way stoplight intersection using discrete transistor-transistor logic (TTL) ICs.
7-1
Introduction to NI ELVIS
Lab 7
Required Components
Silicon diode Six LEDs (2 red, 2 yellow, and 2 green) Six 220 resistors
Introduction to NI ELVIS
7-2
ni.com
Lab 7
Exercise 7-1
7-3
Introduction to NI ELVIS
Lab 7
When you apply the positive voltage to the anode, the diode allows current to flow. The display reads a voltage level less than the open circuit value (1.250 V) and shows the word GOOD (see Figure 7-3).
For example, a silicon rectifying diode in the forward-bias direction displays a voltage ~0.6 V and shows the word GOOD. In the reverse-bias direction, the display reads the open circuit value (~1.250 V) and shows the word OPEN.
Note You can use this simple test to determine the polarity of a colored LED. Connect a red LED to your test leads. In one direction, you see light (forward-biased) and, in the other direction, no light (reverse-biased). The DMM display does not change, but there is enough current to produce some light. Check closely the LED is dimly lit and may be difficult to see with bright lights in the room. When the LED is lit, the red lead connection is the anode.
The way this works is that the display shows the voltage required to generate a small current flow of about 1 mA. In the forward-bias region, this voltage level is usually smaller than the open circuit voltage. In the reverse-bias direction, no current flows and the tester displays the open circuit voltage, about 1.250 V. For LEDs, the voltage threshold is often larger than the open circuit voltage. The 1 mA test is not sufficient to discern the forward-bias test (GOOD), but it is enough to generate a low light intensity.
Introduction to NI ELVIS
7-4
ni.com
Lab 7
Exercise 7-2
4. Set the maximum current in either direction to ensure the diode does not operate in a current region where damage may occur. Check the diode specifications. 5. Click on Run and see the I-V curve appear.
7-5
Introduction to NI ELVIS
Lab 7
In the reverse-bias direction, the current should be very small (A) and negative. In the forward-bias direction, you should see that above a threshold voltage, the current rises exponentially to the maximum current limit. 6. Change the Display buttons [Linear/Log] to see the curve plotted on a different scale. 7. Try the Cursor operation. It gives the (I,V) coordinate values as you move the cursor along the trace. The threshold voltage is related to the semiconductor material of the diode. For silicon diodes, the threshold voltage is about 0.6 V, and for germanium diodes, it is about 0.3 V. One way to estimate the threshold voltage is to fit a tangent line in the forward-bias region near the maximum current (refer to Figure 7-5). The point where the tangent intersects the voltage axis defines the threshold voltage. Observe the (I,V) characteristic curve for a light emitting diode. For this LED, the threshold voltage given by the intersection of the tangent with the voltage axis is about 1.56 V.
Introduction to NI ELVIS
7-6
ni.com
Lab 7
8. Using the Two-Wire Current-Voltage Analyzer, determine the threshold voltage for a red, yellow, and green LED, and complete the chart below. Red LED ____________ V Yellow LED ____________ V Green LED ____________ V Do you see a trend?
7-7
Introduction to NI ELVIS
Lab 7
Exercise 7-3
Each LED is controlled by one binary bit on one of the 8-bit parallel ports on the protoboard. Use digital I/O bit sockets DIO <0..7>. 2. Connect the pin socket DIO <0> to the anode of the red LED in the North-South (Up-Down) direction. 3. Connect the other end of the LED through a 220 resistor to digital ground (not pictured).
Note
Introduction to NI ELVIS
7-8
ni.com
Lab 7
4. Connect the remaining colored LEDs in a similar fashion. Here is the complete mapping scheme. DIO <0> Red DIO <1> Yellow DIO <2> Green N-S direction N-S direction N-S direction DIO <4> Red DIO <5> Yellow DIO <6> Green E-W direction E-W direction E-W direction
5. From the NI ELVISmx Instrument Launcher, select Digital Writer (DigOut). 6. Using the vertical slide switches, select any 8-bit pattern and output that pattern to the NI ELVIS II digital lines. Recall that Bit 0 is connected to the pin socket on the protoboard labeled DIO <0>. 7. Set the Generation Mode to (Run Continuous) and Pattern to (Manual), as shown in Figure 7-7. 8. To activate the port, click on the Run button.
When all switches (Bits 0-2 and 4-6) are HI, all the LEDs should be lit. When all these switches are LO, all the LEDs should be off. You can now use these switches to find out which 8-bit codes are necessary to control the various cycles of a stoplight intersection.
7-9
Introduction to NI ELVIS
Lab 7
Here are some clues for an intersection. The basic operation of a stoplight is based on a 60-second time interval with 30 seconds for red, followed by 25 seconds for green, followed by 5 seconds for yellow. For example, in a two-way intersection, the yellow light in the North-South direction is on while the red light in the East-West direction is on. This modifies the 30-second red timing interval to two timing intervals: a 25-second cycle followed by a 5-second cycle. There are four timing periods (T1, T2, T3, and T4) for two-way stoplight intersection operation. 9. Study the following chart to see how a two-way stoplight intersection works. Direction Lights Bit# T1 T2 T3 T4 25 s 5s 25 s 5s N-S RYG 012 001 010 100 100 E-W RYG 456 100 100 001 010 8-Bit Code Decimal Value 00010100 _________ _________ _________ 20 _________ _________ _________
10. Use the Digital Writer to determine which 8-bit codes need to be written to the digital port to control the stoplights in each of the four timing intervals. For example, timing period 1 requires the code 00101000. Computers read the bits in the reverse order (least significant bit on the right). This code then becomes 00010100. In the white box above the Manual Pattern Line switches display, you can read the radix of the switch pattern in binary {00010100}, decimal {20}, or hexadecimal {14}. 11. Click on the black ^ to left of the white display box to change the radix. You can use this feature to determine the numeric codes for the other timing intervals T2, T3, and T4. If you output the 8-bit code for each of the timing intervals in sequence, you can manually operate the stoplights.
Note You can also change the radix in the Line States display by clicking on the white x beside the Numeric Value display.
Introduction to NI ELVIS
7-10
ni.com
Lab 7
Exercise 7-4
Figure 7-8. Block Diagram for Automated Operation of a Two-way Stoplight Intersection
In operation, one of the elements of the Lights Pattern array is selected on the boundary of the for loop (inner loop) and converted into an 8-bit Boolean array. In a similar way, the appropriate time delay is selected at the for loop boundary and passed to the Wait function. The timing intervals are stored in the four elements of the Time Delay array. To speed up operation, the 25-second time interval is reduced to 5 seconds and the 5-second time interval is reduced to 1 second.
Lab 7
Whats Cool!
LEDs are amazing devices. If you multiply the threshold voltage, VT, times the electronic charge, e, the product is energy that is close to the band gap energy of the semiconductor material used to manufacture the semiconductor diode. Further, in the forward-biased region, the light from the LED has an energy of hc/, where h is Plancks constant, c is the speed of light, and is the wavelength of the center of the energy distribution. Conservation of energy yields the equation: eVT ~ hc/ From the LED specifications, you can determine the wavelength or the LED color. For example, red LEDs have a wavelength of about 560 nm. From the I-V characteristic curve of the LED (see Exercise 7-2), you can measure the threshold voltage VT. If you plot VT versus 1/ for the three different colored LEDs, you find a straight line with a slope approximately equal to (hc/e), a mixture of three fundamental constants of nature.
Introduction to NI ELVIS
7-12
ni.com
Many homes today have several remote controllers lying around the house such as those controlling televisions, stereos, and DVD players. Do you know how these controllers work? The secret is an infrared optical data link, which is a type of free space optical communication link.
Goal
This lab uses an infrared optical source to communicate information over free space to a phototransistor detector. Explore several modulation schemes including amplitude modulation and nonreturn-to-zero (NRZ) digital modulation. For the Multisim challenge at the end of this lab, simulate the free space optical link built on the NI ELVIS II protoboard.
8-1
Introduction to NI ELVIS
Lab 8
Required Components
220 resistor (red, red, brown) 470 resistor (yellow, violet, brown) 1 k resistor (brown, black, red) 22 k resistor (red, red, orange) 0.01 F capacitor 0.5 F capacitor IR emitter (LED) IR detector (phototransistor)1 2N3904 NPN transistor 555 timer chip
1.
Introduction to NI ELVIS
8-2
ni.com
Lab 8
Exercise 8-1
A Phototransistor Detector
Understanding how a phototransistor works starts with understanding transistor characteristic curves. A transistor is basically a current-controlled amplifier. A small base current controls the current flowing through the transistor from the collector to the emitter. Complete the following steps to determine the characteristic curve of a transistor. 1. Insert a 2N904 transistor on an NI ELVIS II protoboard. 2. Connect the emitter, base, and collector leads to pin sockets DUT, DUT+, and BASE, as shown in Figure 8-2.
Figure 8-2. Connections for 3-Wire Transistor Curve Tracer Measurements Note
Base
Base, DUT
Collector Leads
3. Launch the NI ELVISmx Instrument Launcher and select the Three-Wire Current-Voltage Analyzer (3-Wire). 4. Power on the protoboard. 5. Set the Base Current and Collector Voltage as shown in Figure 8-3 and click on Run.
8-3
Introduction to NI ELVIS
Lab 8
The graph displays the collector current versus collector voltage for different values of the base current. You can set many parameters for the collector voltage and the base current ranges. When running, this SFP first outputs a base current, then outputs the collector voltage, and finally measures the collector current. Data points (I,V) are plotted as sequential points with the same base current connected with a line. You can see the curves develop as the program proceeds, resulting in a family of [IV] curves with different base currents. Observe that for a given collector voltage, the collector current increases with an increase in base current. A phototransistor has no base lead. Instead, light falling on the transistor generates a base current proportional to the light intensity. For example, with no light, the phototransistor might follow the bottom (yellow) curve. For a low-light level, the middle (red) curve might be generated, and, at a higher-light intensity, the upper (green) curve might be found. For collector voltages greater than 0.4 V, the collector current follows the light intensity falling on the base region in an almost linear fashion. To build an optical detector, all that is needed is a power supply, a current limiting resistor, and a phototransistor, as shown in Figure 8-4.
Introduction to NI ELVIS
8-4
ni.com
Lab 8
8-5
Introduction to NI ELVIS
Lab 8
Exercise 8-2
For voltages greater than about 0.9 V, the IR LED emits light in the forward-bias region. Light is emitted at a wavelength of 950 nm, outside the spectral range of human eyesight and in the near infrared region. The LED
Introduction to NI ELVIS
8-6
ni.com
Lab 8
specs tell you that the maximum allowed current is more than 100 mA, making IR LEDs about 10 times brighter than normal visible LEDs. The intensity of the IR LED gives the remote controllers a great amount of range. Connecting the LED in series with a 220 resistor and a +5 V power supply produces a current of about 11 mA, yielding about 10 mW of invisible optical power. It takes a special detector like your phototransistor to see it. 4. Build the LED transmitter circuit and the phototransistor detector circuit on the protoboard, as shown in Figure 8-6.
5. Connect the output of the function generator pin socket (FGEN) to the IR LED anode pin. 6. Connect the output of the phototransistor to the pin socket [AI 0+] and Ground to [AI 0]. Taken together, these circuits form a simple optical data link. Figure 8-7 shows this circuit on the NI ELVIS II protoboard.
8-7
Introduction to NI ELVIS
Lab 8
Exercise 8-3
Introduction to NI ELVIS
8-8
ni.com
Lab 8
Exercise 8-4
8-9
Introduction to NI ELVIS
Lab 8
Exercise 8-5
Complete the following steps to build the gated digital oscillator. 1. Build a gated oscillator using a 555 timer chip and the following components: RA: 1.0 k RB: 1.0 k C: 0.5 F 2. Connect pin 4 on the 555 timer chip to the digital line (DI 0) on the NI ELVIS II protoboard. 3. Connect the oscillator output pin 3 to the IR LED anode pin. 4. Connect the output of the detector circuit to the oscilloscope (CH 0) BNC socket. 5. Connect pin 1 of the 555 timer chip to Ground.
Introduction to NI ELVIS
8-10
ni.com
Lab 8
6. From the NI ELVISmx Instrument Launcher, select Oscilloscope (Scope) and Digital Writer (DigOut). 7. For the oscilloscope, select Scope CH 0 as Source, Trigger on Edge, CH 0 Source, Level 1.0 V. In operation, every time you set Bit 0 (DO 0) of the Digital Writer to HI, a 1 kHz signal appears on the oscilloscope. No signal is presented when Bit 0 is LO. Try some of the other digital patterns like Walking 1s or Ramp, and view the modulation scheme on the oscilloscope panel. In remote controllers, the encoding scheme is slightly more complicated. If you are interested in building a computer-controlled IR remote transmitter, refer to Sensors, Transducers and LabVIEW by Barry E. Paton for details.
Figure 8-9. Tone Burst Oscillator Controlled from a Digital Line (red lead)
8-11
Introduction to NI ELVIS
Lab 8
Introduction to NI ELVIS
8-12
ni.com
RF Wireless Communications
Midday at Signal Hill near St. Johns, Newfoundland, in Canada, Guglielmo Marconi pressed his ear to a telephone headset connected to an experimental wireless receiver. About 1,700 miles away at Poldhu, Cornwall, in England, his coworkers were about to send the Morse code letter s, which is three dots. Faintly, but clearly psht-psht-psht pause psht-psht-psht came through the earphone. The date was December 12, 1901, and the first transatlantic message had just been sent and received.
Goal
In this lab, use a paper clip antenna to send this classic message and other waveforms over a wireless radio frequency (RF) link. The NI ELVIS II function generator is the transmitter and a high-gain op amp is the receiver. The classic message is formulated using the NI ELVIS II arbitrary waveform generator.
9-1
Introduction to NI ELVIS
Lab 9
RF Wireless Communications
Required Components
1 k resistor (brown, black, red) 100 k resistor (brown, black, yellow) 741 op amp or field-effect transistor (FET) op amp 753 7408 digital IC Paper clips
Introduction to NI ELVIS
9-2
ni.com
Lab 9
RF Wireless Communications
Exercise 9-1
The Transmitter
Complete the following steps to build a simple transmitter antenna from a paper clip: 1. Straighten a paper clip and cut it into a piece about 2.5 in. long. 2. Push one end of the paper clip into the output pin socket of the function generator. When FGEN is running, the output voltage leaks from the pin socket to the paper clip antenna and radiates a small RF signal. A similar antenna about a centimeter away can pick up this signal and amplify it to a higher signal level. Use this transmitter in Exercise 9-2.
3. Initially, use a sine wave to test the transmitter by setting the SFP function generator to sine waveform, 2.5 V amplitude, and 10000 Hz frequency.
9-3
Introduction to NI ELVIS
Lab 9
RF Wireless Communications
Exercise 9-2
The Receiver
Complete the following steps to build a simple receiver antenna from a paper clip: 1. Bend a second paper clip into step shape, with the long side about 2.5 in., the step height about 0.25 in., and the step width about 0.5 in. 2. Insert the short end of the paper clip into a pin socket. The midsection supports the antenna on the protoboard, so you can rotate the antenna about the short end. The long side sits vertically and is parallel to the transmitter antenna (see Figure 9-2). 3. Build a high-gain amplifier using a 741 op amp or 753 FET op amp in the simple inverting configuration.
4. Connect a 1 k resistor to the input (pin 2). 5. Connect a 100 k bias resistor to the + input (pin 3). 6. Connect the other end of the resistors to AIGND. 7. Connect a 100 k resistor as the feedback resistor Rf from pin 2 to pin 6. 8. To power the circuit, connect +15 V on pin 7 and 15 V on pin 4. Nominally the op amp has a gain of 101. You can use other resistor combinations for higher gains. 9. The receiver antenna is connected to the input (pin 3). 10. Connect the op amp output pin 6 to the oscilloscope.
Introduction to NI ELVIS
9-4
ni.com
Lab 9
RF Wireless Communications
Exercise 9-3
9-5
Introduction to NI ELVIS
Lab 9
RF Wireless Communications
these were all the ingredients needed for Morse code transmission. The letter S is just three dots in rapid succession. The letter O is just three dashes in rapid succession. The distress call, S-O-S (save our souls), is:
dot-dot-dot dash-dash-dash dot-dot-dot
For the first transatlantic message, Marconi chose the simpler signal dot-dot-dot.
Introduction to NI ELVIS
9-6
ni.com
Lab 9
RF Wireless Communications
Exercise 9-4
If you can generate this waveform on the NI ELVIS II digital-to-analog converter, or DAC (AO), then you can use the DAC output to gate the function generator on and off. The resulting tone burst signal from the FGEN can radiate the message to the world. Complete the following steps to build a program to produce a Morse code transmission: 1. From the NI ELVISmx Instrument Launcher, select Arbitrary Waveform Generator (ARB). With the arbitrary waveform generator, you can create unique waveforms, such as Marconis first message. You can use a special program called the Waveform Editor to create all kinds of unique diagnostic and control waveforms. 2. Click the Waveform Editor button to view this feature. The SFP ARB provides waveform control over the AO 0 and AO 1 outputs. 3. Click on the browser icon next to the DAC0 Waveform Name box. 4. From the NI ELVIS II library folder, select the 1VSine1000.wdt file. Enable AO output by clicking on AO 0:[box]. When you click on the Run button, a 1.0 V amplitude sine wave at 1000 Hz is applied to the AO 0 pin socket.
9-7
Introduction to NI ELVIS
Lab 9
RF Wireless Communications
5. Connect the oscilloscope CH 0 BNC input to the AO 0 pin socket. Click the Run button and observe a 1 kHz sine wave signal on the oscilloscope window.
Note
For a steady signal trace, trigger on Channel 0. 6. Return to the AO 0 browser icon, navigate to the Hands-On NI ELVIS II library folder, and select the file Morse.wdt. This file provides the waveform for the letter S in Morse code. Change the AO 0 gain to 2.5. 7. Click Run and observe this signal on the oscilloscope.
Introduction to NI ELVIS
9-8
ni.com
Lab 9
RF Wireless Communications
For the real transmission, change the Update Rate box to 10000.0 S/s.
9-9
Introduction to NI ELVIS
Lab 9
RF Wireless Communications
Exercise 9-5
4. Now configure the SFP function generator for TTL output levels. Amplitude Offset Waveform Frequency 2.2 V 2.5 V Square 1 kHz
5. Observe the transmitted and received signals on the oscilloscope: Channel 0 goes to pin 3 of the 7408 chip (the transmitter signal) and Channel 1 goes to pin 6 of the op amp (the receiver signal). 6. Trigger on Channel 0. You should be able to see the transmitted message S on Channel 0 and the received signal on Channel 1.
Introduction to NI ELVIS
9-10
ni.com
Lab 9
RF Wireless Communications
9-11
Introduction to NI ELVIS
Mechanical Motion
10
The ability to translate electrical signals into motion in the real world combined with the ability to measure position can help you exploit the power of the computer to generate computer automation the source of much of the modern worlds conveniences.
Goal
In this experiment, use the power capacity of the NI ELVIS II variable power supply to run and control the speed of a small DC motor. Using a modified free space IR link, build a tachometer to measure the speed of the motor. By combining the motor and tachometer with a LabVIEW program, you can incorporate computer automation in the system.
10-1
Introduction to NI ELVIS
Lab 10
Mechanical Motion
Required Components
1 k resistor (brown, black, red) 10 k resistor (brown, black, orange) IR LED/phototransistor module DC motor Small punch or drill Glue Several combs with varying numbers of teeth per inch
Introduction to NI ELVIS
10-2
ni.com
Lab 10
Mechanical Motion
Lab 10
Mechanical Motion
Emitter +5V
Detector
1k Gnd
10 k
+ To ACH4 -
In the case of an LED/phototransistor module, an internal LED is used for the optical source. Power it from the +5 V power supply through a 1 k current limiting resistor Then connect a 10 k resistor from the phototransistor emitter to ground and connect the same +5 V power supply to the phototransistor collector. The voltage developed across the 10 k resistor is the phototransistor or tachometer signal. 2. Connect leads from the 10 k resistor to the [AI 0+] and [AI 0] pin sockets.
Introduction to NI ELVIS
10-4
ni.com
Lab 10
Mechanical Motion
3. Select Scope from the NI ELVISmx Instrument Launcher and select the settings, as shown in Figure 10-4.
4. Power on the protoboard and run the oscilloscope SFP. 5. Pass a piece of paper through the IR motion sensor. You should see the oscilloscope trace change (HI-LO-HI). With a narrow piece of paper, you might catch the pulse generated as you drag it through the sensor. 6. Place a comb with many teeth in the sensor IR beam. Dragging it through the sensor generates a train of pulses. You can even run it back and forth like a saw to generate a continuous stream of pulses as shown in Figure 10-4. It is interesting to try combs with different sizes and numbers of teeth. Each comb generates its own signature waveform.
10-5
Introduction to NI ELVIS
Lab 10
Mechanical Motion
Emitter +5V
Detector
VPS+
1k Gnd
10 k
+ To ACH 4 -
Gnd 12 V DC Motor
You can also use the CD and motor of Lab 6. Instead of a small magnet triggering the sensor, you can drill a hole about the size of the transmitter/receiver beam (3 mm) near the edge of the CD. Align the IR sensor so that the beam passes through the hole.
Introduction to NI ELVIS
10-6
ni.com
Lab 10
Mechanical Motion
10-7
Introduction to NI ELVIS
Lab 10
Mechanical Motion
4. Read the pulse frequency (Freq:) from the measurement row CHO Meas: at the bottom of the oscilloscope screen. Take frequency measurements for a variety of power supply levels. A plot of frequency versus VPS voltage level demonstrates the linearity of your rotary motion system. 5. Close NI ELVIS and all SFPs.
Introduction to NI ELVIS
10-8
ni.com
Lab 10
Mechanical Motion
You can convert the period measurement to revolutions per minute by inverting the period to get frequency and multiplying by 60 to get rpm. For scaling, divide by 1000 to get krpm. You can also use the Express template for Timing and Transitions Measurements and get the frequency directly. Then convert the frequency to rpm as discussed above.
Note
10-9
Introduction to NI ELVIS
Lab 10
Mechanical Motion
Using LabVIEW, complete the following steps to measure the period/frequency on a continuous waveform. 1. Launch LabVIEW and open RPM.vi from the Hands-On-NI ELVIS II library folder. 2. Open the diagram window and study the program.
Use the DAQ Assistant to collect 1000 voltage samples for the tachometer graph and provide an input signal array for the Pulse Measurements.vi. The rpm signal is sent to a front panel meter and displayed in krpm. The rpm signal also goes to a shift register with five elements. This provides an averaged rpm signal for the front panel. You manually control the motor speed with the front panel knob labeled Setpoint. Also available on the front panel is a graph of the tachometer signal as a function of time.
Introduction to NI ELVIS
10-10
ni.com
Lab 10
Mechanical Motion
Run this VI and take your motor for a spin. See and hear how responsive the motor is to a rapid change in the rpm setpoint.
Figure 10-11. LabVIEW Tachometer and Motor Control Circuit Front Panel
10-11
Introduction to NI ELVIS
Lab 10
Mechanical Motion
If you are more familiar with control, you can use another VI (PID Autotuning.vi) to set the initial PID parameters automatically. Then you can fine-tune the parameters to your specific system. Search for additional LabVIEW PID resources at ni.com.
Introduction to NI ELVIS
10-12
ni.com
Lab 10
Mechanical Motion
Figure 10-13. Setpoint (yellow) and RPM (red) Traces show Optimal Control PID in Action
In Figure 10-13, the setpoint (yellow trace) is changed suddenly from 3300 to 4500 krpm. The system rpm (red trace) responds by moving the motor speed smoothly and optimally from the current setpoint to the target setpoint.
10-13
Introduction to NI ELVIS
Digital Dice
11
From the beginning of time, dice have been used for games of chance. Cubic dice similar to modern dice date back to before 5000 BC. The Greeks and Romans used dice made of stone or ivory with spots on the side inlayed with dark ink or bits of lead. In this lab, light emitting diodes (LEDs) in a dice pattern are used to display the lucky number.
Goal
In this lab, explore using Multisim to design an electronic version of digital dice with standard TTL ICs. From the virtual Multisim design, build a prototype circuit using real TTL ICs on the NI ELVIS II protoboard. Also use NI ELVIS II SFPs to test your design within a Multisim environment and, with a click of the mouse, use the same test instruments to test the real circuit.
11-1
Introduction to NI ELVIS
Lab 11
Digital Dice
Required Components
Two 100 k resistor (brown, black, yellow) Five 220 resistors (red, red, black) Four 1 k pull-up resistors (brown, black, red) [optional] Eight red LEDs Two 0.01 F capacitors 0.1 F capacitor Two 1 F capacitors 555 timer IC Two 7474 Dual D flip-flops One 7404 hex inverter Single-pole single-throw (SPST) switch or push button (normally open)
Introduction to NI ELVIS
11-2
ni.com
Lab 11
Digital Dice
Some Background
Consider the case of a single die. On each of its six sides, one of the following patterns appears, representing the numbers one through six.
These patterns are traditional. You can think of them as seven lights arranged in an H pattern.
By turning on the appropriate lights, you can create any one of the six patterns on the face of a die. On closer inspection, there are only four unique patterns from which the pattern for any face can be formed. Call these base patterns A, B, C, and D:
The base state A has only one light and it occupies the snake-eye position in the dices center position. The three remaining states all use two lights occupying one of the two diagonal positions or the horizontal position. If you write down a truth table for the presence or absence of these base patterns as a function of the die face number, the meaning of the base states becomes clearer.
11-3
Introduction to NI ELVIS
Lab 11
Digital Dice
Die face 1 2 3 4 5 6
The base pattern A is used by all of the odd numbers (1, 3, and 5). Pattern B is found in all numbers except 1. Base pattern C is found in the numbers 4, 5, and 6. Pattern D is used only when representing the number 6. You can build a single dice display using seven LEDs and four current limiting resistors.
+5 V
B A 330 D C
In the Figure 11-2 schematic diagram, shorting an input pad A, B, C, or D to ground turns on that base state. In the combinations of A, B, C, or D shown in Table 11-1, you can generate any of the standard dice displays.
Introduction to NI ELVIS
11-4
ni.com
Lab 11
Digital Dice
Set all the lines 0..1 to LO initially. All the LEDs should be lit. This is the lamp test state. These LEDs are active low, that is, setting the lines (A..D) LO turns on the selected base set of LEDs.
Note
Verify your circuit design follows the truth table in Table 11-1.
11-5
Introduction to NI ELVIS
Lab 11
Digital Dice
2. Use the NI ELVISmx Digital Writer as a diagnostic test instrument to test your circuit. Recall that the LEDs are active LO. 3. Use the values A, B, C, and D in Table 11-1 to verify the operation of your design. You can have both Multisim and the NI ELVIS protoboard active at the same time. In this exercise, the instrument control device [box] determines which application NI ELVISmx Digital Writer controls.
Note
[Multisim] selects the active Multisim panel [Dev 1 (NI ELVIS)] selects the NI ELVIS II protoboard By switching back and forth, you can easily compare your Multisim design with the real circuit on the NI ELVIS II protoboard.
Introduction to NI ELVIS
11-6
ni.com
Lab 11
Digital Dice
Q1 D Q Q
Q2 D Q Q
Q3
Q Q
clock
It uses three D-type flip-flop elements configured as a shift register. Note the switched tail; the inverted output of the last element is connected back to the input of the first element. On command from a rising edge of the clock pulse, all the D inputs shift to their respective outputs. Each clock pulse generates a new sequence of outputs on Q1, Q2, and Q3, which repeats after six pulses.
11-7
Introduction to NI ELVIS
Lab 11
Digital Dice
Cycle 1 2 3 4 5 6 7
Q1 0 1 1 1 0 0 0
Q2 0 0 1 1 1 0 0
Q3 0 0 0 1 1 1 0 same as cycle 1
With Multisim, design a modulo 6 counter using two 7474 Dual D edge-triggered flip-flop ICs. Each IC contains two D flip-flop elements labeled in Multisim as 1 and 2. The input is labeled as D for data source and the outputs are labeled as Q and Q where Q is the complement of Q. Each element has a Clear (CLR) and a Preset (PR) input, which is pulled HI for clocking operations. You form a shift register when you connect all the clock inputs (CLK) together and to the circuit clock.
Introduction to NI ELVIS
11-8
ni.com
Lab 11
Digital Dice
Figure 11-5. Multisim Version of a Switch Tail Ring Counter with LED Displays
To visualize the outputs Q1, Q2, and Q3, an LED is connected to each output (Q) and the power supply. Note when a Q bit is HI, current is sunk through Q to ground, which turns on the respective LED. The illuminated state signifies that Q is HI. Use the NI ELVISmx Function Generator as the circuit clock. Set the output for TTL levels, set the amplitude equal to 5 Vpkpk, and set an offset of 2.5 V. Set the function to Square Wave and frequency near 60 Hz. Verify your design by comparing it with the example Mod 6.ms10 in the NI ELVIS program library.
11-9
Introduction to NI ELVIS
Lab 11
Digital Dice
Exercise 11-4 Convert the Mod 6 Multisim Design into a Real Circuit
Complete the following steps to convert your Multisim design to a real circuit on an NI ELVIS II protoboard: 1. Transfer your working design into real circuit components. You need two 7474 ICs, three visible LEDs, and three current limiting resistors. 2. One can also use three of the LED indicators on the NI ELVIS II protoboard labeled LED 0, 1, and 2. Map Q1 to LED0, Q2 to LED0, and Q3 to LED0.
Note
These LEDs are active HI, that is, a HI state turns the LED on.
The Multisim program Mod 62.ms10 demonstrates this option. 3. Use the same NI ELVISmx Function Generator as you did in Exercise 11-3. 4. Switch back and forth between Multisim and the NI ELVIS II protoboard to verify the operation of your modulo 6 counter.
Introduction to NI ELVIS
11-10
ni.com
Lab 11
Digital Dice
3. Use the following components RA = 100 k RB = 100 k C = 0.01 f to complete the clock circuit and define the frequency of operation. 4. Use the NI ELVIS II SFP (Scope) to verify the circuit operation and measure the clock frequency.
11-11
Introduction to NI ELVIS
Lab 11
Digital Dice
5. To stop the dice rolling, you need only to stop the clock. You can simulate this feature, One-armed bandit, using a simple switch connected between Ground and pin 2 of the 555 timer IC. 6. Modify your clock design with this addition and verify the circuit operation. You should see the oscillator stop when the switch is closed.
7. When the circuit is operating correctly, replace the component list above with a second set of components to slow the clock down to a speed where your eye can follow the action. RA = 100 k RB = 100 k C = 2 f 8. Modify your circuit a second time by adding a single LED between the +5 V supply and by connecting a current limiting resistor to the 555 output (pin 5). 9. Power up the protoboard and click on Run to verify the slow speed clock operation. 10. Use the Multisim program Clock.ms10 in the NI ELVIS II library folder to check on your program.
Lab 11
Digital Dice
2. When the circuit is completed, power up the protoboard. You should see the LED flashing. 3. Power off the protoboard. 4. Remove the NI ELVIS SFP connection from your modulo 6 counter and replace it with a connection between the 555 output (pin 3) and the clock input of the modulo 6 counter. 5. Power up the protoboard. You should see the clock output LED flashing and the three output lines Q1, Q2, and Q3 on the modulo 6 counter displaying the count on the protoboard LEDs 0, 1, and 2. 6. Power off the protoboard. 7. Replace the second (RA, RB, C) set with the first (RA, RB, C) set. When you apply power to the protoboard, you should not be able to see any counting just a blur on the LEDs. 8. Push the switch and see the current count on the modulo 6 output lines.
Lab 11
Digital Dice
# 6 4 2 1 3 5
Q1 0 1 1 1 0 0
Q2 0 0 1 1 1 0
Q3 0 0 0 1 1 1
Q1 1 0 0 0 1 1
Q 2 1 1 0 0 0 1
Q3 1 1 1 0 0 0
For example, each output has three (1) states and three (0) states. You could use one of these outputs, say Q3, to signify odd states 1, 3, and 5. You could then use another output state, say Q2, to code the family 4, 5, and 6. These two lines then decode two of the base patterns for free. To decode the two remaining base patterns with a particular pattern of the three counter lines, you can use a three-input AND gate. Decode Not 1 with the combination Q1, Q2, and Q3 and decode the final base state 6 with Q1, Q2, and Q3. Build the encoder using two three-input AND gates with four inverter gates. The schematic diagram in Figure 11-10 shows the encoder circuit.
Introduction to NI ELVIS
11-14
ni.com
Lab 11
Digital Dice
Recall that the dice display in Exercise 11-2 requires that the dice display inputs be active LO to turn on the LEDs. This implies that the outputs of the encoder in Figure 11-10 must be inverted. You can do this by replacing the AND gates with NAND gates and rearranging to connections to A, B, C, and D. Study the Figure 11-10 design and make the necessary corrections. Sketch the new encoder circuit on paper. Complete the following steps to build the new encoder design. 1. Design a Multisim circuit for the new encoder. Use a 7410 (triple three-input NAND gate) IC and a 7404 (hex inverter) IC. 2. Set the encoder input lines Q1, Q2, and Q3 with three output lines, DIO 0, 1, and 2, of the NI ELVISmx Digital Writer. 3. View the output states A, B, C, and D with four lines, DIO 8, 9, 10, and 11, of the NI ELVISmx Digital Reader. 4. For assistance, take a peek at Encoder.ms10 in the Hands-On NI ELVIS II library folder. 5. Run the simulation and verify the truth table for the three- to four-line encoder.
11-15
Introduction to NI ELVIS
Lab 11
Digital Dice
Figure 11-11. Multisim circuit for 3-to-4 line Encoder with Dice Display
2. Use the NI ELVISmx Digital Writer to set the inputs Q1, Q2, and Q3. 3. Use the NI ELVISmx Digital Reader to view the encoder output states A, B, C, and D. 4. When you are satisfied with the circuit operation, replace the lines to the NI ELVISmx Digital Reader with the input lines for the real digital dice display. 5. Make one final check on the encoder/LED display circuit. 6. Power up your circuits. Verify the encoder/LED display generates the dice patterns (1..6). 7. If all works as expected, connect the four digital dice components: clock, counter, encoder, and display.
Lab 11
Digital Dice
11-17
Introduction to NI ELVIS
This appendix contains additional information about National Instruments technical support options and NI ELVIS resources.
A-1
Introduction to NI ELVIS
Appendix A
If you searched ni.com and could not find the answers you need, contact your local office or NI corporate headquarters. Phone numbers for our worldwide offices are listed at the front of this manual. You also can visit the Worldwide Offices section of ni.com/niglobal to access the branch office Web sites, which provide up-to-date contact information, support phone numbers, email addresses, and current events.
NI ELVIS Resources
You can find additional information about NI ELVIS at ni.com/nielvis.
Introduction to NI ELVIS
A-2
ni.com