This course prepares you to do the following: Use LabVIEW to create applications. Understand front panels, block diagrams, and icons and connector panes. Use built-in LabVIEW functions. Create and save programs in LabVIEW so you can use them as subroutines. Create applications that use plug-in DAQ devices.This course does not describe any of the following: Programming theory Every built-in LabVIEW function or object Analog-to-digital (A/D) theoryNI does provide free reference materials on the above topics on ni.com.The LabVIEW Help is also very useful:LabVIEW»Help»Search the LabVIEW Help
Virtual InstrumentationFor more than 30 years, National Instruments has revolutionized the way engineers andscientists in industry, government, and academia approach measurement andautomation. Leveraging PCs and commercial technologies, virtual instrumentationincreases productivity and lowers costs for test, control, and design applicationsthrough easy-to-integrate software, such as NI LabVIEW, and modular measurementand control hardware for PXI, PCI, USB, and Ethernet.With virtual instrumentation, engineers use graphical programming software to createuser-defined solutions that meet their specific needs, which is a great alternative toproprietary, fixed-functionality traditional instruments. Additionally, virtualinstrumentation capitalizes on the ever-increasing performance of personal computers.For example, in test, measurement, and control, engineers have used virtualinstrumentation to downsize automated test equipment (ATE) while experiencing up toa 10 times increase in productivity gains at a fraction of the cost of traditionalinstrument solutions.
National Instruments LabVIEW is an industry-leading software tool for designing test,measurement, and control systems. Since its introduction in 1986, engineers andscientists worldwide who have relied on NI LabVIEW graphical development forprojects throughout the product design cycle have gained improved quality, shorter timeto market, and greater engineering and manufacturing efficiency. By using theintegrated LabVIEW environment to interface with real-world signals, analyze data formeaningful information, and share results, you can boost productivity throughout yourorganization. Because LabVIEW has the flexibility of a programming languagecombined with built-in tools designed specifically for test, measurement, and control,you can create applications that range from simple temperature monitoring tosophisticated simulation and control systems. No matter what your project is, LabVIEWhas the necessary tools to make you successful quickly.
Virtual Instrumentation ApplicationsVirtual instrumentation is effective in many different types of applications, from design toprototyping to deployment. The LabVIEW platform provides specific tools and models to meetspecific application challenges, ranging from designing signal processing algorithms to makingvoltage measurements, and can target any number of platforms from the desktop to embeddeddevices – with an intuitive, powerful graphical paradigm.LabVIEW scales from design and development on PCs to several embedded targets, fromrugged toaster-size prototypes to embedded systems on chips. LabVIEW streamlines systemdesign with a single graphical development platform. In doing so, it encompasses bettermanagement of distributed, networked systems because as the targets for LabVIEW grow variedand embedded, you need to be able to more easily distribute and communicate between thevarious LabVIEW code pieces in your system.
Integrated Hardware PlatformsA virtual instrument consists of an industry-standard computer or workstation equippedwith powerful application software, cost-effective hardware such as plug-in boards, anddriver software, which together perform the functions of traditional instruments.Virtual instruments represent a fundamental shift from traditional hardware-centeredinstrumentation systems to software-centered systems that exploit the computing power,productivity, display, and connectivity capabilities of popular desktop computers andworkstations.Although the PC and integrated circuit technology have experienced significantadvances in the last two decades, software truly offers the flexibility to build on thispowerful hardware foundation to create virtual instruments, providing better ways toinnovate and significantly reduce cost. With virtual instruments, engineers and scientistsbuild measurement and automation systems that suit their needs exactly (user-defined)instead of being limited by traditional fixed-function instruments (vendor-defined).
This LabVIEW course is designed for audiences with or without access to NationalInstruments hardware.Each exercise is divided into three tracks, A, B, and CTrack A is designed to be used with hardware supported by the NI-DAQmx driver. Thisincludes most USB, PCI, and PXI data acquisition devices with analog input. Somesignal conditioning and excitation (external power) is required to use a microphone witha DAQ device.Track B is designed to be used with no hardware. You can simulate the hardware withNI-DAQmx Version 8.0 and later. This is done by using the NI-DAQmx SimulatedDevice option in the Create New menu of MAX. The simulated device’s driver isloaded, and programs using it are fully verified.Track C is designed to be used with a standard sound card and microphone. LabVIEWincludes simple VIs for analog input and analog output using the sound card built intomany PCs. This is convenient for laptops because the sound card and microphone areusually already built-in.
Setting Up Your Hardware for Your Selected TrackTrack A – NI Data Acquisition with MicrophoneUSB-6009, Microphone and LEDSuggested HardwareQty Part ierLow-Cost USB DAQElectret Microphone100 Ω Resistor220 Ω ResistorLight Emitting Diode (LED)National kThe following schematic was drawn with NI Multisim, a widely used SPICE schematic captureand simulation tool. Visit ni.com/Multisim for more info.Track B – Simulated NI Data AcquisitionNI-DAQmx Software Version 8.0 or laterTrack C – Third-Party Sound CardSound card and MicrophoneSuggested HardwareQty1Part Number DescriptionSupplierStandard Plug-In PC Microphone* RadioShack* Laptops often have a built-in microphone (no plug-in microphone is required)
What type of device should I use?There are many types of data acquisition and control devices on the market. A few have beenhighlighted above. The trade-off usually falls between sampling rate (samples/second),resolution (bits), number of channels, and data transfer rate (usually limited by “bus” type:USB, PCI, PXI, and so on). Multifunction DAQ (data acquisition) devices are ideal becausethey can be used in a wide range of applications.NI USB-6008 and USB-6009 Low-Cost USBDAQThe National Instruments USB-6009 deviceprovides basic data acquisition functionality forapplications such as simple data logging, portablemeasurements, and academic lab experiments. TheUSB-6008 and USB-6009 are ideal for students.Create your own measurement application byprogramming theUSB-6009 using LabVIEW and NI-DAQmxdriver software for Windows. For Mac OS X andLinux users, download and use the NI-DAQmxBase driver.Linux is the registered trademark ofLinus Torvalds in the U.S. and othercountries.USB-6009 Specifications: Eight 14-bit analog inputs 12 digital I/O lines 2 analog outputs 1 counterni.com/daq
The next level of software is called Measurement & Automation Explorer (MAX).MAX is a software interface that gives you access to all of your National InstrumentsDAQ, GPIB, IMAQ, IVI, Motion, VISA, and VXI devices. The shortcut to MAXappears on your desktop after installation. A picture of the icon is shown above. MAX ismainly used to configure and test your National Instruments hardware, but it does offerother functionality such as checking to see if you have the latest version of NI-DAQmxinstalled. When you run an application using NI-DAQmx, the software reads the MAXconfiguration to determine the devices you have configured. Therefore, you mustconfigure DAQ devices first with MAX.The functionality of MAX falls into six categories: Data Neighborhood Devices and Interfaces IVI Instruments Scales Historical Data SoftwareThis course will focus on Data Neighborhood, Devices and Interfaces, Scales, Software,and you will learn about the functionality each one offers.
Exercise 1 – Testing Your Device (Track A)In this exercise, use Measurement and Automation Explorer (MAX) to testyour USB-6009 DAQ device.1. Launch MAX by double-clicking the icon on the desktop or by selecting Start»Programs»National Instruments»Measurement & Automation.2. Expand the Devices and Interfaces section to view the installed NationalInstruments devices. MAX displays the National Instruments hardware and softwarein the computer.3. Expand the NI-DAQmx Devices section to view the installed hardware that iscompatible with NI-DAQmx. The device number appears in quotes following thedevice name. The data acquisition VIs use this device number to determine whichdevice performs DAQ operations. Your hardware is listed as NI USB-6009:“Dev1.”4. Perform a self-test on the device by right-clicking it in the configuration tree andchoosing Self-Test or clicking Self-Test along the top of the window. This tests thesystem resources assigned to the device. The device should pass the test because it isalready configured.5. Check the pinout for your device. Right-click the device in the configuration treeand select Device Pinouts or click Device Pinouts along the top of the centerwindow.6. Open the test panels. Right-click the device in the configuration tree and select TestPanels or click Test Panels along the top of the center window. With testpanels, you can test the available functionality of your device, analog input/output,digital input/output, and counter input/output without doing any programming.7. On the Analog Input tab of the test panels, change Mode to “Continuous” and Rateto “10,000 Hz.” Click Start and hum or whistle into your microphone to observe thesignal that is plotted. Click Stop when you are done.8. On the Digital I/O tab, notice that initially the port is configured to be all input.Observe under Select State the LEDs that represent the state of the input lines.Click the All Output button under Select Direction. Notice you now have switchesunder Select State to specify the output state of the different lines. Toggle line 0 andwatch the LED light up. Click Close to close the test panels.9. Close MAX.
End of Exercise 1 (Track A)
Exercise 1 – Setting Up Your Device (Track B)In this exercise, use Measurement and Automation Explorer (MAX) to configure asimulated DAQ device.1. Launch MAX by double-clicking the icon on the desktop or by selecting Start»Programs»National Instruments»Measurement & Automation.2. Expand the Devices and Interfaces section to view the installed NationalInstruments devices. MAX displays the National Instruments hardware and softwarein the computer. The device number appears in quotes following the device name.The data acquisition VIs use this device number to determine which device performsDAQ operations.3. Create a simulated DAQ device for use later in this course. Simulated devices area powerful tool for development without having hardware physically installed inyour computer. Right-click Devices and Interfaces and select Create New »NI-DAQmx Simulated Device. Click Finish. The simulated device appears yellowin color.4. Expand the M Series DAQ section. Select PCI-6220 or any other PCI device ofyour choice. Click OK.5. The NI-DAQmx Devices folder expands to show a new entry for PCI-6220:“Dev1.” You have now created a simulated device.6. Perform a self-test on the device by right-clicking it in the configuration tree andchoosing Self-Test or clicking Self-Test along the top of the window. This tests thesystem resources assigned to the device. The device should pass the test because it isalready configured.7. Check the pinout for your device. Right-click the device in the configuration treeand select Device Pinouts or click Device Pinouts along the top of the centerwindow.8. Open the test panels. Right-click the device in the configuration tree and select TestPanels or click Test Panels along the top of the center window. The test panelsallow you to test the available functionality of your device, analog input/output,digital input/output, and counter input/output without doing any programming.9. On the Analog Input tab of the test panels, change Mode to “Continuous.” ClickStart and observe the signal that is plotted. Click Stop when you are done.
10. On the Digital I/O tab, notice that initially the port is configured to be all input.Observe under Select State the LEDs that represent the state of the input lines.Click the All Output button under Select Direction. Note that you now haveswitches under Select State to specify the output state of the different lines. ClickClose to close the test panels.11. Close MAX.End of Exercise 1 (Track B)
Exercise 1 – Setting Up Your Device (Track C)In this exercise, use Windows utilities to verify your sound card and prepare it for usewith a microphone.1. Prepare your microphone for use. Double-click the volume control icon on the taskbar to open up the configuration window. You also can find the sound configurationwindow from the Windows Control Panel: Start»Settings»Control Panel»Soundsand Audio Devices»Advanced.2. If you do not see a microphone section, go to Options»Properties»Recording andplace a checkmark in the box next to Microphone. This displays the microphonevolume control. Click OK.3. Uncheck the Mute box if it is not already unchecked. Make sure that the volume isturned up.Uncheck Mute4. Close the volume control configuration window.5. Open the sound recorder by selecting Start»Programs»Accessories»Entertainment»Sound Recorder.6. Click the record button and speak into your microphone. Notice how the soundsignal is displayed in the sound recorder.7. Click Stop and close the sound recorder without saving changes when you arefinished.End of Exercise 1 (Track C)
LabVIEWLabVIEW is a graphical programming language that uses icons instead of lines oftext to create applications. In contrast to text-based programming languages, whereinstructions determine program execution, LabVIEW uses dataflow programming,where the flow of data determines execution order.You can purchase several add-on software toolkits for developing specializedapplications. All the toolkits integrate seamlessly in LabVIEW. Refer to theNational Instruments Web site for more information about these toolkits.LabVIEW also includes several wizards to help you quickly configure your DAQdevices and computer-based instruments and build applications.LabVIEW Example FinderLabVIEW features hundreds of example VIs you can use and incorporate into VIsthat you create. In addition to the example VIs that are shipped with LabVIEW,you can access hundreds of example VIs on the NI Developer Zone(zone.ni.com). You can modify an example VI to fit an application, or you cancopy and paste from one or more examples into a VI that you create.
LabVIEW programs are called virtual instruments (VIs).Controls are inputs and indicators are outputs.Each VI contains three main parts: Front panel – How the user interacts with the VI Block diagram – The code that controls the program Icon/connector – The means of connecting a VI to other VIsIn LabVIEW, you build a user interface by using a set of tools and objects. The userinterface is known as the front panel. You then add code using graphical representationsof functions to control the front panel objects. The block diagram contains this code. Insome ways, the block diagram resembles a flowchart.You interact with the front panel when the program is running. You can control theprogram, change inputs, and see data updated in real time. Controls are used for inputssuch as adjusting a slide control to set an alarm value, turning a switch on or off, orstopping a program. Indicators are used as outputs. Thermometers, lights, and otherindicators display output values from the program. These may include data, programstates, and other information.Every front panel control or indicator has a corresponding terminal on the blockdiagram. When you run a VI, values from controls flow through the block diagram,where they are used in the functions on the diagram, and the results are passed intoother functions or indicators through wires.
Use the Controls palette to place controls and indicators on the front panel. TheControls palette is available only on the front panel. To view the palette, selectWindow»Show Controls Palette. You also can display the Controls palette by rightclicking an open area on the front panel. Tack down the Controls palette by clicking thepushpin on the top left corner of the palette.
Use the Functions palette to build the block diagram. The Functions palette is availableonly on the block diagram. To view the palette, select Window»Show FunctionsPalette. You also can display the Functions palette by right-clicking an open area onthe block diagram. Tack down the Functions palette by clicking the pushpin on the topleft corner of the palette.
If you enable the automatic selection tool and you move the cursor over objects on thefront panel or block diagram, LabVIEW automatically selects the corresponding toolfrom the Tools palette. Toggle automatic selection tool by clicking the AutomaticSelection Tool button in the Tools palette.Use the Operating Tool to change the values of a control or select the text within acontrol.Use the Positioning/Resizing Tool to select, move, or resize objects. The PositioningTool changes shape when it moves over a corner of a resizable object.Use the Labeling Tool to edit text and create free labels. The Labeling Tool changes toa cursor when you create free labels.Use the Wiring Tool to wire objects together on the block diagram.Other important tools:
Click the Run button to run the VI. While the VI runs, the Run button appears with ablack arrow if the VI is a top-level VI, meaning it has no callers and therefore is not asubVI. Click the Continuous Run button to run the VI until you abort or pause it. You also canclick the button again to disable continuous running. While the VI runs, the Abort Execution button appears. Click this button to stop the VIimmediately.Note: Avoid using the Abort Execution button to stop a VI. Either let the VI complete its dataflow or design a method to stop the VI programmatically. By doing so, the VI is at a knownstate. For example, place a button on the front panel that stops the VI when you click it. Click the Pause button to pause a running VI. When you click the Pause button,LabVIEW highlights on the block diagram the location where you paused execution. Clickthe Pause button again to continue running the VI. Select the Text Settings pull-down menu to change the font settings for the VI, includingsize, style, and color. Select the Align Objects pull-down menu to align objects along axes, including vertical,top edge, left, and so on. Select the Distribute Objects pull-down menu to space objects evenly, including gaps,compression, and so on. Select the Resize Objects pull-down menu to change the width and height of front panelobjects.
Select the Reorder pull-down menu when you have objects that overlap each otherand you want to define which one is in front or back of another. Select one of theobjects with the Positioning Tool and then select from Move Forward, MoveBackward, Move To Front, and Move To Back.Note: The following items only appear on the block diagram toolbar. Click the Execution Highlighting button to see the flow of data through the blockdiagram. Click the button again to disable execution highlighting. Click the Retain Wire Values button to save the wire values at each point in theflow of execution so that when you place a probe on a wire, you can immediatelyobtain the most recent value of the data that passed through the wire. Click the Step Into button to single-step into a loop, subVI, and so on. Singlestepping through a VI steps through the VI node to node. Each node blinks to denotewhen it is ready to execute. By stepping into the node, you are ready to single-stepinside the node. Click the Step Over button to step over a loop, subVI, and so on. By stepping overthe node, you execute the node without single-stepping through the node. Click the Step Out button to step out of a loop, subVI, and so on. By stepping out ofa node, you complete single-stepping through the node and go to the next node.Additional ToolsRetain WireValues
When you create an object on the front panel, a terminal is created on the blockdiagram. These terminals give you access to the front panel objects from the blockdiagram code.Each terminal contains useful information about the front panel object it corresponds to,and uses color and symbols to provide information about the data type. For example, thedynamic data type is a polymorphic data type represented by dark blue terminals.Boolean terminals are green with TF lettering.In general, blue terminals should wire to blue terminals, green to green, and so on. Thisis not a hard-and-fast rule; you can use LabVIEW to connect a blue terminal (dynamicdata) to an orange terminal (fractional value), for example. But in most cases, look for amatch in colors.Controls have a thick border and an arrow on the right side. Indicators have a thinborder and an arrow on the left side. Logic rules apply to wiring in LabVIEW: Eachwire must have one (but only one) source (or control), and each wire may have multipledestinations (or indicators).
LabVIEW uses many common data types – Boolean, numeric, strings, clusters, andso on.The color and symbol of each terminal indicate the data type of the control or indicator.Control terminals have a thicker border than indicator terminals. Also, arrows appear onfront panel terminals to indicate whether the terminal is a control or an indicator. Anarrow appears on the right if the terminal is a control and on the left if the terminal is anindicator.Definitions Array: Arrays group data elements of the same type. An array consists of elementsand dimensions. Elements are the data that make up the array. A dimension is thelength, height, or depth of an array. An array can have one or more dimensions andas many as (231) – 1 elements per dimension, memory permitting. Cluster: Clusters group data elements of mixed types, much like a bundle of wiresin a telephone cable, where each wire in the cable represents a different element ofthe cluster.See Help»Search the LabVIEW Help for more information. The LabVIEW UserManual on ni.com provides additional references for data types found in LabVIEW.
LabVIEW follows a dataflow model for running VIs. A block diagram node executeswhen all its inputs are available. When a node completes execution, it supplies data toits output terminals and passes the output data to the next node in the dataflow path.Visual Basic, C , JAVA, and most other text-based programming languages follow acontrol flow model of program execution. In control flow, the sequential order ofprogram elements determines the execution order of a program.Consider the block diagram above. It adds two numbers and then multiplies by 2 fromthe result of the addition. In this case, the block diagram executes from left to right, notbecause the objects are placed in that order but because one of the inputs of the Multiplyfunction is not valid until the Add function has finished executing and passed the data tothe Multiply function. Remember that a node executes only when data are available atall of its input terminals, and it supplies data to its output terminals only when it finishesexecution. In the second piece of code, the Simulate Signal Express VI receives inputfrom the controls and passes its result to the graph.You may consider the add-multiply and the simulate signal code to coexist on the sameblock diagram in parallel. This means that they begin executing at the same time and runindependently of one another. If the computer running this code had multipleprocessors, these two pieces of code could run independently of one another (each on itsown processor) without any additional coding.
When your VI is not executable, a broken arrow is displayed in the Run button in thepalette. Finding Errors: To list errors, click on the broken arrow. To locate the bad object,click on the error message. Execution Highlighting: Animates the diagram and traces the flow of the data,allowing you to view intermediate values. Click on the light bulb on the toolbar. Probe: Used to view values in arrays and clusters. Click on wires with the Probe toolor right-click on the wire to set probes. Retain Wire Values: Used with probes to view the values from the last iteration ofthe program. Breakpoint: Sets pauses at different locations on the diagram. Click on wires orobjects with the Breakpoint tool to set breakpoints.
Exercise 2 – Acquiring a Signal with DAQ (Track A)Complete the following steps to create a VI that acquires data continuously from yourDAQ device.1. Launch LabVIEW.2. In the Getting Started window, click the File»New orthe New dialog box.More link to display3. Open a data acquisition template. From the Create New list, select VI»FromTemplate»DAQ»Data Acquisition with NI-DAQmx.vi and click OK.4. Display the block diagram by clicking it or by selecting Window»Show BlockDiagram. Read the instructions written there about how to complete the program.5. Double-click the DAQ Assistant to launch the configuration wizard.6. Configure an analog input operation.a. Choose Acquire Signals»Analog Input»Voltage.b. Choose Dev1 (USB-6009)»ai0 to acquire data on analog input channel 0 andclick Finish.c. In the next window, define the parameters of your analog input operation.To choose an input range that works well with your microphone, on the Settingstab enter 2 V for the maximum and –2 V for the minimum. Under timingsettings choose “Continuous” for the acquisition mode and enter 10000 for therate. Leave all other choices set to their default values. Click OK to exit thewizard.7. Place the Filter Express VI to the right of the DAQ Assistant on the block diagram.From the Functions palette, select Express»Signal Analysis»Filter and place it onthe block diagram inside the While Loop. When you bring up the Functions palette,press the small pushpin in the upper left-hand corner of the palette. This tacks downthe palette so that it remains visible. This step is omitted in the following exercises,but you should repeat it. In the configuration window under Filtering Type, choose“Highpass.” Under Cutoff Frequency, use a value of "300 Hz." Click OK.
8. Make the following connections on the block diagram by hovering your mouse over the terminalso that it becomes the wiring tool and clicking once on each of the terminals you wish to connect:a. Connect the Data output terminal of the DAQ Assistant VI to the Signal input of the Filter VI.b. Create a graph indicator for the filtered signal by right-clicking on the Filtered Signal outputterminal and choosing Create»Graph Indicator.9. Return to the front panel by selecting Window»Show Front Panel or by pressing Ctrl-E .10. Run your program by clicking the Run button. Hum or whistle into the microphone to observe thechanging voltage on the graph.11. Click Stop once you are finished.12. Save the VI as Exercise 2 – Acquire.vi in your Exercises folder and close it.Note: The solution to this exercise is printed in the back of this manual.Tip: You can place the DAQAssistant on your block diagramfrom the Functions palette.Right-click the block diagram toopen the Functions palette and goto Express»Input to find it.End of Exercise 2 (Track A)
Exercise 2 – Acquiring a Signal with DAQ (Track B)Complete the following steps to create a VI that acquires data continuously from yoursimulated DAQ device.1. Launch LabVIEW.2. In the Getting Started window, click the File»New orthe New dialog box.More link to display3. Open a data acquisition template. From the Create New list, select VI»FromTemplate»DAQ»Data Acquisition with NI-DAQmx.vi and click OK.4. Display the block diagram by clicking it or by selecting Window»Show BlockDiagram. Read the instructions written there about how to complete the program.5. Double-click the DAQ Assistant to launch the configuration wizard.6. Configure an analog input operation.a. Choose Acquire Signals»Analog Input»Voltage.b. Choose Dev1 (PCI-6220)»ai0 to acquire data on analog input channel 0 and clickFinish.c. In the next window, define the parameters of your analog input operation. On thetask timing tab, choose “Continuous” for the acquisition mode, enter 10000 forsamples to read, and 10000 for the rate. Leave all the other choices set to theirdefault values. Click OK to exit the wizard.7. Create a graph indicator for the signal by right-clicking on the “Data” output on theDAQ Assistant and choosing Create»Graph Indicator.8. Return to the front panel by selecting Window»Show Front Panel or by pressing Ctrl-E .9. Run your program by clicking the run button. Observe the simulated sine wave on thegraph.10. Click Stop once you are finished.11. Save the VI as Exercise 2 – Acquire.vi in the Exercises folder. Close the VI.Notes: The solution to this exercise is printed in the back of this manual.You can place the DAQ Assistant on your block diagram from the Functions palette.Right-click the block diagram to open the Functions palette and go to Express»Inputto find it. When you bring up the Functions palette, press the small pushpin in theupper left-hand corner of the
National Instruments LabVIEW is an industry-leading software tool for designing test, measurement, and control systems. Since its introduction in 1986, engineers and . Track A is designed to be used with hardware supported by the NI-DAQmx driver. This includes most USB, PCI, and PXI data acquisition devices with analog input. Some