Telemark University College Department of ElectricalEngineering, Information Technology and Cybernetics
Faculty of Technology, Postboks 203, Kjlnes ring 56, N-3901Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
Data Acquisition in LabVIEW HANS-PETTER HALVORSEN,2013.02.11
2
Preface This tutorial explains the basic concepts of a DataAcquisition in LabVIEW.
You find this document and additional resources online at:
http://home.hit.no/~hansha/?tutorial=daq
You should have some basic knowledge about LabVIEW, e.g., theIntroduction to LabVIEW tutorial. This document is available fordownload at http://home.hit.no/~hansha/.
For more information about LabVIEW, visit:http://home.hit.no/~hansha/?page=labview.
In addition to LabVIEW, you will need to install the driverNI-DAQmx.
iii
Table of Contents Preface....................................................................................................................................................2
Table of Contents...................................................................................................................................iii
1 Introduction to LabVIEW..................................................................................................................1
1.1 Dataflow programming.............................................................................................................1
1.2 Graphical programming............................................................................................................1
1.3 Benefits.....................................................................................................................................2
2 Introduction to Data Acquisition......................................................................................................3
2.1 Introduction to DAQ - Data Acquisition....................................................................................3
2.1.1 Physical input/output signals.............................................................................................4
2.1.2 DAQ device/hardware.......................................................................................................4
2.1.3 Driver software..................................................................................................................5
2.1.4 Your software application (Application software)............................................................. 6
2.2 MAX Measurement and Automation Explorer.......................................................................6
2.3 NI-DAQmx.................................................................................................................................7
2.3.1 DAQ Assistant....................................................................................................................8
2.4 NI USB-6008..............................................................................................................................8
3 Physical input/output signals.........................................................................................................10
3.1 Transducers.............................................................................................................................10
3.2 Signals.....................................................................................................................................11
3.2.1 Analog Signals..................................................................................................................11
3.3 Digital Signals..........................................................................................................................13
4 MAX................................................................................................................................................15
5 NI-DAQmx.......................................................................................................................................17
iv Table of Contents
Tutorial: Data Acquisition in LabVIEW
5.1.1 DAQ Assistant..................................................................................................................18
5.2 Simulating a DAQ Device.........................................................................................................18
6 DAQ Devices...................................................................................................................................20
6.1 Performing Analog-to-Digital Conversion...............................................................................21
6.2 Performing Digital-to-Analog Conversion...............................................................................21
6.3 Using Counters........................................................................................................................21
6.4 Using Digital I/O......................................................................................................................21
7 NI USB-6008....................................................................................................................................23
7.1 Connect NI USB-6008 to the PC..............................................................................................23
7.1.1 Testing the USB-6008 in MAX..........................................................................................24
7.2 Using NI USB-6008 in LabVIEW...............................................................................................30
7.3 DAQ Assistant..........................................................................................................................31
7.3.1 Analog Input.....................................................................................................................31
7.3.2 Analog Output..................................................................................................................38
8 Logging to File.................................................................................................................................41
8.1 Writing to Measurement File..................................................................................................41
8.2 Read from Measurement File.................................................................................................44
1
1 Introduction to LabVIEW
LabVIEW (short for Laboratory Virtual InstrumentationEngineering Workbench) is a platform and development environmentfor a visual programming language from National Instruments. Thegraphical language is named "G". Originally released for the AppleMacintosh in 1986, LabVIEW is commonly used for data acquisition,instrument control, and industrial automation on a variety ofplatforms including Microsoft Windows, various flavors of UNIX,Linux, and Mac OS X. Visit National Instruments at www.ni.com.
The code files have the extension .vi, which is an abbreviationfor Virtual Instrument. LabVIEW offers lots of additional Add-Onsand Toolkits.
1.1 Dataflow programming The programming language used inLabVIEW, also referred to as G, is a dataflow programming language.Execution is determined by the structure of a graphical blockdiagram (the LV-source code) on which the programmer connectsdifferent function-nodes by drawing wires. These wires propagatevariables and any node can execute as soon as all its input databecome available. Since this might be the case for multiple nodessimultaneously, G is inherently capable of parallel execution.Multi-processing and multi-threading hardware is automaticallyexploited by the built-in scheduler, which multiplexes multiple OSthreads over the nodes ready for execution.
1.2 Graphical programming LabVIEW ties the creation of userinterfaces (called front panels) into the development cycle.LabVIEW programs/subroutines are called virtual instruments (VIs).Each VI has three components: a block diagram, a front panel, and aconnector panel. The last is used to represent the VI in the blockdiagrams of other, calling VIs. Controls and indicators on thefront panel allow an operator to input data into or extract datafrom a running virtual instrument. However, the front panel canalso serve as a programmatic interface. Thus a virtual instrumentcan either be run as a program, with the front panel serving as auser interface, or, when dropped as a node onto the block diagram,the front panel defines the inputs and outputs for the given nodethrough the connector pane. This implies each VI can be easilytested before being embedded as a subroutine into a largerprogram.
2 Introduction to LabVIEW
Tutorial: Data Acquisition in LabVIEW
The graphical approach also allows non-programmers to buildprograms simply by dragging and dropping virtual representations oflab equipment with which they are already familiar. The LabVIEWprogramming environment, with the included examples and thedocumentation, makes it simple to create small applications. Thisis a benefit on one side, but there is also a certain danger ofunderestimating the expertise needed for good quality "G"programming. For complex algorithms or large-scale code, it isimportant that the programmer possess an extensive knowledge of thespecial LabVIEW syntax and the topology of its memory management.The most advanced LabVIEW development systems offer the possibilityof building stand-alone applications. Furthermore, it is possibleto create distributed applications, which communicate by aclient/server scheme, and are therefore easier to implement due tothe inherently parallel nature of G-code.
1.3 Benefits One benefit of LabVIEW over other developmentenvironments is the extensive support for accessing instrumentationhardware. Drivers and abstraction layers for many different typesof instruments and buses are included or are available forinclusion. These present themselves as graphical nodes. Theabstraction layers offer standard software interfaces tocommunicate with hardware devices. The provided driver interfacessave program development time. The sales pitch of NationalInstruments is, therefore, that even people with limited codingexperience can write programs and deploy test solutions in areduced time frame when compared to more conventional or competingsystems. A new hardware driver topology (DAQmxBase), which consistsmainly of G-coded components with only a few register calls throughNI Measurement Hardware DDK (Driver Development Kit) functions,provides platform independent hardware access to numerous dataacquisition and instrumentation devices. The DAQmxBase driver isavailable for LabVIEW on Windows, Mac OS X and Linux platforms.
3
2 Introduction to Data Acquisition
This chapter explains the basic concepts of using DAQ inLabVIEW.
Topics:
Introduction to DAQ - Data Acquisition MAX Measurement andAutomation Explorer NI-DAQmx
LabVIEW is very powerful when it comes to creating DAQapplications. LabVIEW includes a set of VIs that let you configure,acquire data from, and send data to DAQ devices. Often, one devicecan perform a variety of functions, such as analog-to-digital (A/D)conversion, digital-to-analog (D/A) conversion, digital I/O, andcounter/timer operations. Each device supports different DAQ andsignal generation speeds. Also, each DAQ device is designed forspecific hardware, platforms and operating systems.
National Instruments, the inventor of LabVIEW, also make DAQdevices, so the integration with the DAQ devices from NI and theLabVIEW software is seamless and makes it easy to do I/O operationsfrom the LabVIEW environment.
2.1 Introduction to DAQ - Data Acquisition
The purpose of data acquisition is to measure an electrical orphysical phenomenon such as voltage, current, temperature,pressure, or sound. PC-based data acquisition uses a combination ofmodular hardware, application software, and a computer to takemeasurements. While each data acquisition system is defined by itsapplication requirements, every system shares a common goal ofacquiring, analyzing, and presenting information. Data acquisitionsystems incorporate signals, sensors, actuators, signalconditioning, data acquisition devices, and applicationsoftware.
So summing up, Data Acquisition is the process of:
Acquiring signals from real-world phenomena Digitizing thesignals Analyzing, presenting and saving the data
4 Introduction to Data Acquisition
Tutorial: Data Acquisition in LabVIEW
The DAQ system has the following parts involved, see Figure:
The parts are:
Physical input/output signals DAQ device/hardware Driversoftware Your software application (Application software)
For an Introduction to Data Acquisition, see this webcast:http://zone.ni.com/wv/app/doc/p/id/wv-169
2.1.1 Physical input/output signals A physical input/outputsignal is typically a voltage or current signal.
A voltage signal can typically be a 0-5V signal, while a currentsignal can typically be a 4-20mA signal.
2.1.2 DAQ device/hardware DAQ hardware acts as the interfacebetween the computer and the outside world. It primarily functionsas a device that digitizes incoming analog signals so that thecomputer can interpret them
A DAQ device (Data Acquisition Hardware) usually has thesefunctions:
Analog input Analog output Digital I/O Counter/timers
We have different DAQ devices, such as:
Desktop DAQ devices where you need to plug a PCI DAQ board intoyour computer. The software is running on a computer.
5 Introduction to Data Acquisition
Tutorial: Data Acquisition in LabVIEW
Portable DAQ devices for connection to the USB port, Wi-Ficonnections, etc. The software is running on a computer
Distributed DAQ devices where the software is developed on yourcomputer and then later downloaded to the distributed DAQdevice.
2.1.3 Driver software Driver software is the layer of softwarefor easily communicating with the hardware. It forms the middlelayer between the application software and the hardware. Driversoftware also prevents a programmer from having to doregister-level programming or complicated commands in order toaccess the hardware functions.
Driver software from National Instruments:
NI-DAQmx NI-DAQmx Base
The DAQ Assistant, included with NI-DAQmx, is a graphical,interactive guide for configuring, testing, and acquiringmeasurement data. With a single click, you can even generate codebased on your configuration, making it easier and faster to developcomplex operations. Because DAQ Assistant is completelymenu-driven, you will make fewer programming errors and drasticallydecrease the time from setting up your DAQ system to taking yourfirst measurement.
NI-DAQmx Base offers a subset of NI-DAQmx functionality onWindows and Linux, Mac OS X, Windows Mobile and Windows CE.
6 Introduction to Data Acquisition
Tutorial: Data Acquisition in LabVIEW
2.1.4 Your software application (Application software)
Application software adds analysis and presentation capabilitiesto the driver software. Your software application normally doessuch tasks as:
Real-time monitoring Data analysis Data logging Controlalgorithms Human machine interface (HMI)
In order to create your DAQ application you need a programmingdevelopment tool, such as LabVIEW.
2.2 MAX Measurement and Automation Explorer
Measurement & Automation Explorer (MAX) provides access toyour National Instruments devices and systems.
With MAX, you can:
Configure your National Instruments hardware and software Createand edit channels, tasks, interfaces, scales, and virtualinstruments Execute system diagnostics View devices and instrumentsconnected to your system Update your National Instrumentssoftware
In addition to the standard tools, MAX can expose item-specifictools you can use to configure, diagnose, or test your system,depending on which NI products you install. As you navigate throughMAX, the contents of the application menu and toolbar change toreflect these new tools.
7 Introduction to Data Acquisition
Tutorial: Data Acquisition in LabVIEW
2.3 NI-DAQmx The NI-DAQmx Driver software is the layer ofsoftware for easily communicating with the hardware. It forms themiddle layer between the application software and the hardware.Driver software also prevents a programmer from having to doregister-level programming or complicated commands in order toaccess the hardware functions.
The DAQmx palette in LabVIEW:
8 Introduction to Data Acquisition
Tutorial: Data Acquisition in LabVIEW
The DAQ Assistant is an easy way to start using the DAQ featuresin LabVIEW. We will learn more about the DAQ Assistant in a laterchapter.
2.3.1 DAQ Assistant The DAQ Assistant, included with NI-DAQmx,is a graphical, interactive guide for configuring, testing, andacquiring measurement data. With a single click, you can evengenerate code based on your configuration, making it easier andfaster to develop complex operations. Because DAQ Assistant iscompletely menu-driven, you will make fewer programming errors anddrastically decrease the time from setting up your DAQ system totaking your first measurement.
2.4 NI USB-6008 NI USB-6008 is a simple and low-costmultifunction I/O device from National Instruments.
9 Introduction to Data Acquisition
Tutorial: Data Acquisition in LabVIEW
The device has the following specifications:
8 analog inputs (12-bit, 10 kS/s) 2 analog outputs (12-bit, 150S/s) 12 digital I/O USB connection, No extra power-supply neeededCompatible with LabVIEW, LabWindows/CVI, and Measurement Studio forVisual Studio .NET NI-DAQmx driver software
The NI USB-6008 is well suited for education purposes due to itssmall size and easy USB connection.
10
3 Physical input/output signals
Data acquisition involves gathering signals from measurementsources and digitizing the signal for storage, analysis, andpresentation on a PC. Data acquisition (DAQ) systems come in manydifferent PC technology forms for great flexibility when choosingyour system. Scientists and engineers can choose from PCI, PXI, PCIExpress, PXI Express, PCMCIA, USB, Wireless and Ethernet dataacquisition for test, measurement, and automation applications.There are five components to be considered when building a basicDAQ system
Transducers and sensors Signals Signal conditioning DAQ hardwareDriver and application software
In this chapter we focus on Transducers, sensors andSignals.
3.1 Transducers Data acquisition begins with the physicalphenomenon to be measured. This physical phenomenon could be hetemperature of a room, the intensity of a light source, thepressure inside a chamber, the force applied to an object, or manyother things. An effective DAQ system can measure all of thesedifferent phenomena. A transducer is a device that converts aphysical phenomenon into a measurable electrical signal, such asvoltage or current. The ability of a DAQ system to measuredifferent phenomena depends on the transducers to convert thephysical phenomena into signals measurable by the DAQ hardware.Transducers are synonymous with sensors in DAQ systems. There arespecific transducers for many different applications, such asmeasuring temperature, pressure, or fluid flow. Below we see somecommon phenomena and the transducers used to measure them.
Phenomenon Transducer
Temperature Thermocouple, RTD, Thermistor
11 Physical input/output signals
Tutorial: Data Acquisition in LabVIEW
Light Photo Sensor
Sound Microphone
Force and Pressure Strain Gage, Piezoelectric Transducer
Position and Displacement
Potentiometer, LVDT, Optical Encoder
Acceleration Accelerometer
pH pH Electrode
Different transducers have different requirements for convertingphenomena into a measurable signal. Some transducers may requireexcitation in the form of voltage or current. Other transducers mayrequire additional components and even resistive networks toproduce a signal.
Refer to ni.com/sensors for more information on transducers.
3.2 Signals The appropriate transducers convert physicalphenomena into measurable signals. However, different signals needto be measured in different ways. For this reason, it is importantto understand the different types of signals and theircorresponding attributes. Signals can be categorized into twogroups:
Analog Digital
3.2.1 Analog Signals Analog input is the process of measuring ananalog signal and transferring the measurement to a computer foranalysis, display, or storage. An analog signal is a signal thatvaries continuously. Analog input is most commonly used to measurevoltage or current. You can use many types of devices to performanalog input, such as multifunction DAQ (MIO) devices, high-speeddigitizers, digital multimeters, and Dynamic Signal Acquisition(DSA) devices.
12 Physical input/output signals
Tutorial: Data Acquisition in LabVIEW
An analog signal can be at any value with respect to time. A fewexamples of analog signals include voltage, temperature, pressure,sound, and load. The three primary characteristics of an analogsignal is:
Level Shape Frequency
Level Because analog signals can take on any value, the levelgives vital information about the measured analog signal. Theintensity of a light source, the temperature in a room, and thepressure inside a chamber are all examples that demonstrate theimportance of the level of a signal. When measuring the level of asignal, the signal generally does not change quickly with respectto time. The accuracy of the measurement, however, is veryimportant. A DAQ system that yields maximum accuracy should bechosen to aid in analog level measurements.
13 Physical input/output signals
Tutorial: Data Acquisition in LabVIEW
Shape Some signals are named after their specific shape - sine,square, sawtooth, and triangle. The shape of an analog signal canbe as important as the level, because by measuring the shape of ananalog signal, you can further analyze the signal, including peakvalues, DC values, and slope. Signals where shape is of interestgenerally change rapidly with respect to time, but system accuracyis still important. The analysis of heartbeats, video signals,sounds, vibrations, and circuit responses are some applicationsinvolving shape measurements.
Frequency All analog signals can be categorized by theirfrequency. Unlike the level or shape of the signal, frequencycannot be directly measured. The signal must be analyzed usingsoftware to determine the frequency information. This analysis isusually done using an algorithm known as the Fourier transform.When frequency is the most important piece of information, it isimportant to consider including both accuracy and acquisitionspeed. Although the acquisition speed for acquiring the frequencyof a signal is less than the speed required for obtaining the shapeof a signal, the signal must still be acquired fast enough that thepertinent information is not lost while the analog signal is beingacquired. The condition that stipulates this speed is known as theNyquist Sampling Theorem. Speech analysis, telecommunication, andearthquake analysis are some examples of common applications wherethe frequency of the signal must be known.
3.3 Digital Signals A digital signal cannot take on any valuewith respect to time. Instead, a digital signal has two possiblelevels: high and low. Digital signals generally conform to certainspecifications that define characteristics of the signal. Digitalsignals are commonly referred to as transistor-to-transistor logic(TTL). TTL specifications indicate a digital signal to be low whenthe level falls within 0 to 0.8 V, and the signal is high between 2to 5 V. The useful information that can be measured from a digitalsignal includes the state and the rate.
14 Physical input/output signals
Tutorial: Data Acquisition in LabVIEW
State Digital signals cannot take on any value with respect totime. The state of a digital signal is essentially the level of thesignal - on or off, high or low. Monitoring the state of a switch -open or closed - is a common application showing the importance ofknowing the state of a digital signal.
Rate The rate of a digital signal defines how the digital signalchanges state with respect to time. An example of measuring therate of a digital signal includes determining how fast a motorshaft spins. Unlike frequency, the rate of a digital signalmeasures how often a portion of a signal occurs. A softwarealgorithm is not required to determine the rate of a signal
15
4 MAX Measurement & Automation Explorer (MAX) providesaccess to your National Instruments devices and systems.
With MAX, you can:
Configure your National Instruments hardware and software Createand edit channels, tasks, interfaces, scales, and virtualinstruments Execute system diagnostics View devices and instrumentsconnected to your system Update your National Instrumentssoftware
In addition to the standard tools, MAX can expose item-specifictools you can use to configure, diagnose, or test your system,depending on which NI products you install. As you navigate throughMAX, the contents of the application menu and toolbar change toreflect these new tools.
LabVIEW installs MAX to establish all devices and channelconfiguration parameters. MAX reads the information the DeviceManager records in the Windows Registry and assigns a logicaldevice number to each DAQ device.
You use the device number to refer to the device in LabVIEW. Youcan access MAX by selecting ToolsMeasurement & AutomationExplorer in LabVIEW. This displays the primary MAX window.
16 MAX
Tutorial: Data Acquisition in LabVIEW
Before using a data acquisition board, you must confirm that thesoftware can communicate with the board by configuring the devices.For Windows, the Windows Configuration Manager keeps track of allthe hardware installed in the computer, including NationalInstruments DAQ devices. The Windows Configuration Managerautomatically detects and configures Plug & Play (PnP)devices.
Windows Configuration Manager
If you have a PnP device, such as an E Series MIO device, theWindows Configuration Manager automatically detects and configuresthe device. If you have a non-PnP device, or legacy device, youmust configure the device manually using the Add New Hardwareoption in the Control Panel. You can verify the WindowsConfiguration by accessing the Device Manager.
17
5 NI-DAQmx Driver software is the layer of software for easilycommunicating with the hardware. It forms the middle layer betweenthe application software and the hardware. Driver software alsoprevents a programmer from having to do register-level programmingor complicated commands in order to access the hardwarefunctions.
Driver software from National Instruments:
NI-DAQmx NI-DAQmx Base
The DAQ Assistant, included with NI-DAQmx, is a graphical,interactive guide for configuring, testing, and acquiringmeasurement data. With a single click, you can even generate codebased on your configuration, making it easier and faster to developcomplex operations. Because DAQ Assistant is completelymenu-driven, you will make fewer programming errors and drasticallydecrease the time from setting up your DAQ system to taking yourfirst measurement.
NI-DAQmx Base offers a subset of NI-DAQmx functionality onWindows and Linux, Mac OS X, Windows Mobile and Windows CE.
National Instruments DAQ boards have a driver engine thatcommunicates between the board and the application software. Thereare two driver engines, NI-DAQmx and Traditional NI-DAQ. You canalso use the DAQ Assistant, an Express VI that communicates withNI-DAQmx, in LabVIEW to communicate with the DAQ board. Inaddition, National Instruments provides Measurement &Automation Explorer (MAX) for configuring DAQ boards.
The NI-DAQmx Driver software is the layer of software for easilycommunicating with the hardware. It forms the middle layer betweenthe application software and the hardware. Driver software alsoprevents a programmer from having to do register-level programmingor complicated commands in order to access the hardwarefunctions.
The DAQmx palette in LabVIEW:
18 NI-DAQmx
Tutorial: Data Acquisition in LabVIEW
5.1.1 DAQ Assistant The DAQ Assistant, included with NI-DAQmx,is a graphical, interactive guide for configuring, testing, andacquiring measurement data. With a single click, you can evengenerate code based on your configuration, making it easier andfaster to develop complex operations. Because DAQ Assistant iscompletely menu-driven, you will make fewer programming errors anddrastically decrease the time from setting up your DAQ system totaking your first measurement.
Scales
You can configure custom scales for your measurements using MAX.This is very useful when working with sensors. It allows you tobring a scaled value into your application without having to workdirectly with the raw values. For example, you can use atemperature sensor that represents temperature with a voltage. Theconversion equation for the temperature is, Voltage x 100 =Celsius. After a scale is set, you can use it in your applicationprogram, providing the temperature value, rather than thevoltage.
When performing analog input, the task can be timed to:
Acquire 1 Sample Acquire n Samples Acquire Continuously
5.2 Simulating a DAQ Device You can create NI-DAQmx simulateddevices in NI-DAQmx 7.4 or later. Using NI-DAQmx simulateddevices:
You can try NI products in your application without thehardware.
19 NI-DAQmx
Tutorial: Data Acquisition in LabVIEW
Later, when you acquire the hardware, you can import theNI-DAQmx simulated device configuration to the physical deviceusing the MAX Portable Configuration Wizard.
You can work on your applications on a portable system and uponreturning to the original system, you can easily import yourapplication work.
Creating NI-DAQmx Simulated Devices
To create an NI-DAQmx simulated device, right-click Devices andInterfaces and select Create New. The Create New dialog box promptsyou to select a device to add. Select NI-DAQmx Simulated Device andclick Finish. In the Choose Device dialog box, select the family ofdevices for the device you want to simulate. Select the device andclick OK. If you select a PXI device, you are prompted to select achassis number and PXI slot number. If you select an SCXI chassis,the SCXI configuration panels open.
20
6 DAQ Devices DAQ hardware acts as the interface between thecomputer and the outside world. It primarily functions as a devicethat digitizes incoming analog signals so that the computer caninterpret them
A DAQ device (Data Acquisition Hardware) usually has thesefunctions:
Analog input Analog output Digital I/O Counter/timers
We have different DAQ devices, such as:
Desktop DAQ devices where you need to plug a PCI DAQ board intoyour computer. The software is running on a computer.
Portable DAQ devices for connection to the USB port, Wi-Ficonnections, etc. The software is running on a computer
Distributed DAQ devices where the software is developed on yourcomputer and then later downloaded to the distributed DAQdevice.
21 DAQ Devices
Tutorial: Data Acquisition in LabVIEW
Most DAQ devices have four standard elements: analog input,analog output, digital I/O, and counters. The DAQ device transfersthe measured signals to a computer through different busstructures. For example, you can plug a DAQ device into the PCI busor the USB port of a computer or the Personal Computer Memory CardInternational Association (PCMCIA) socket of a laptop. You also canuse PXI/CompactPCI to create a portable, versatile, and ruggedmeasurement system.
6.1 Performing Analog-to-Digital Conversion
Analog-to-digital conversion is a process of acquiring andtranslating signals into digital data so that a computer canprocess it. Analog-to-digital converters (ADCs) are circuitcomponents that convert a voltage level into a series of ones andzeroes. ADCs sample the analog signal on each rising or fallingedge of a sample clock. In each cycle, the ADC takes a snapshot ofthe analog signal, measures and converts it into a digital value.The ADC obtains and approximates the signal with fixed precisionand converts it into a series of digital values.
6.2 Performing Digital-to-Analog Conversion
Digital-to-analog conversion is the opposite ofanalog-to-digital conversion. In digital-to-analog conversion, thecomputer generates the data.
6.3 Using Counters A counter is a digital timing device. Youtypically use counters for event counting, frequency measurement,period measurement, position measurement, and pulse generation.
6.4 Using Digital I/O
22 DAQ Devices
Tutorial: Data Acquisition in LabVIEW
Digital signals are electrical signals that transfer digitaldata over a wire. These signals typically have only two states: onand off, also known as high and low, or 1 and 0. When sending adigital signal across a wire, the sender applies a voltage to thewire and the receiver uses the voltage level to determine the valuebeing sent. The voltage ranges for each digital value depend on thevoltage level standard being used.
Digital signals have many users:
Digital signals control or measure digital devices such asswitches or LEDs
23
7 NI USB-6008 NI USB-6008 is a simple and low-cost multifunctionI/O device from National Instruments.
The device has the following specifications:
8 analog inputs (12-bit, 10 kS/s) 2 analog outputs (12-bit, 150S/s) 12 digital I/O USB connection, No extra power-supply neededCompatible with LabVIEW, LabWindows/CVI, and Measurement Studio forVisual Studio .NET NI-DAQmx driver software
The NI USB-6008 is well suited for education purposes due to itssmall size and easy USB connection.
7.1 Connect NI USB-6008 to the PC Configuring and testing:USB-6008 can be configured and tested using MAX (Measurement andAutomation Explorer), which is installed with the NI-DAQmx DriverSoftware.
The first time you connect the USB-6008 to the PC, the WindowsHardware Installer Wizard will open.
The wizard searches the PC for the necessary driver software forthe USB-6008. This driver software was installed along with theinstallation of the NI-DAQ software. When the wizard has finishedthe installation of the driver software, the USB-6008 is ready foruse.
24 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
7.1.1 Testing the USB-6008 in MAX Before you start to use theUSB-6008 in an application, you should test the device in theMeasurement and Automation Explorer (MAX).
In the MAX window, expand the Devices and Interfaces node andthen NI DAQmx Devices. Right-click on the NI USB-6008 device andselect Self-Test.
25 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
Hopefully the self-test passes without errors. Then, you shouldtest the individual channels of the USB-6008 to check that theinput signals are detected correctly by the USB-6008, and that theoutput signals generated by the USB-6009 have correct values. ThisI/O can be tested in several ways, depending on which channels youactually want to test.
We will perform a simple loopback test:
Here, let us test analog output channel 0 (AO0) and the analoginput channel 0 (AI0) to see if they work correctly. We willperform a very simple test, which is sufficient if we are to checkthat both AO0 and AI0 work correctly. The test procedure, which isdenoted loopback, is to connect the AI0 channel to the AO0 channel.Then we generate some legal voltage at AO0. If AI0 detects the samevoltage, we know that both AO0 and AI0 work. (We may then repeatthis procedure for other channels.) If for some reason AI0 detectssome other voltage than the value we set for AO0, then there is anerror in either the AI0 channel or in the the AO0 channel, andfurther investigations are necessary.
To prepare for the loopback test, we wire together AI0 and AO0.To see the terminals of the USB-6000, select Device Pinouts fromthe right-click menu.
26 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
The Figure shows the AI0 and AO0 channels wired together.
To actually perform the loopback test, right-click on the NIUSB-6008 device in MAX, and then select Test Panels.. in order toopen the Test Panels. In the Test Panels window, select the AnalogOutput tab.
27 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
In the Analog Output tab, select any voltage between 0V and5V.
Next, click the Analog Input tab in the Test Panels window.
28 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
The Analog Input tab should indicate the same (or almost thesame) voltage as is set out on AO0. There may be a small differencebetween the values due to the limited resolution in theDA-converter (digital-to-analog) and in the AD-converter(analog-to-digital).
29 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
You should also always use a multi-meter to check if the voltagelevels on the output and input channels are correct according toyour settings.
30 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
7.2 Using NI USB-6008 in LabVIEW In order to use the NI USB-6008in LabVIEW you need to use the DAQmx functions, see Figurebelow.
DAQmx Data Acquisition palette:
31 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
7.3 DAQ Assistant The easiest ways is to use the DAQAssistant.
7.3.1 Analog Input When you drag the DAQ Assistant icon on yourBlock Diagram, the following window appears:
32 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
In this window you need to select either Acquire Signals (i.e.,Input Signals) or Generate Signals (i.e., Output Signals).
Select Acquire Signals Analog Input Voltage.
In the next window you select which Analog Input you want touse. Select ai0 (Analog Input channel 0) and click Finish.
33 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
The following window appears:
34 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
In the Timing Settings Select 1 Sample (On Demand).
35 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
The next step is to select the Signal Input Range. A commonsignal is 0-5V.
You may also rename the name of the channel (right-click on thename):
36 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
You are now finished with the configuration. Click OK in the DAQAssistant window The DAQ Assistant icon appears on the BlockDiagram:
37 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
Example:
Wire the data output to a numeric indicator like this (and hitthe Run button):
Then numeric indicator will show, e.g., the following value:
[End of Example]
Example:
If you want a continuous acquisition, put a While loop aroundthe DAQ Assistant like this:
We can also communicate with the DAQ device without using theDAQ Assistant:
38 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
For more advanced applications this approach is recommended.
[End of Example]
7.3.2 Analog Output Analog Output is similar.
39 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
40 NI USB-6008
Tutorial: Data Acquisition in LabVIEW
Example:
Or inside a loop for continuous writing to the DAQ device:
We can also communicate with the DAQ device without using theDAQ Assistant:
For more advanced applications this approach is recommended.
[End of Example]
41
8 Logging to File In many cases you want to write your data youget from the DAQ device to a text file for later use. In thischapter we will learn how to write to a measurement file inLabVIEW. We will also learn how to read the same file.
You can use the Write to Measurement File function on the FileI/O palette in LabVIEW for writing data to text files You can saveyour data in a tab separated text (LVM data file format) or as abinary (TDMS file format) file.
If we use the LVM, it is easy to open and view the data inNotepad.
8.1 Writing to Measurement File We will use the Write toMeasurement File function in the File I/O palette in LabVIEW forwriting data to text files. We will also focus on the LVM data fileformat, not the TDMS file format which give binary files.
42 Logging to File
Tutorial: Data Acquisition in LabVIEW
When you drag in the Write to Measurement File, a configurationdialog window will automatically pop up.
Recommended settings for the Write To Measurement File is asfollows:
Example:
Example of LabVIEW Program that write data to a MeasurementFile:
Front Panel:
43 Logging to File
Tutorial: Data Acquisition in LabVIEW
In this application we log data from a process based on a manualcontrol signal. Both the input signal u and the output signal(temperature) is saved to a Measurement File.
Block Diagram:
The LVM file may look something like this:
44 Logging to File
Tutorial: Data Acquisition in LabVIEW
The first column is the time, the second column is the inputsignal, and the third column is the output signal.
[End of Example]
8.2 Read from Measurement File
When you drag in the Read from Measurement File, a configurationdialog window will automatically pop up.
Recommended settings for the Read From Measurement File:
45 Logging to File
Tutorial: Data Acquisition in LabVIEW
Example:
Example of LabVIEW Program that read data from a MeasurementFile:
This application reads the data and plots it in 2 differentgraphs.
46 Logging to File
Tutorial: Data Acquisition in LabVIEW
Block Diagram:
[End of Example]
Telemark University College
Faculty of Technology
Kjlnes Ring 56
N-3918 Porsgrunn, Norway
www.hit.no
Hans-Petter Halvorsen, M.Sc.
Telemark University College
Faculty of Technology
Department of Electrical Engineering, Information Technology andCybernetics
E-mail: [emailprotected]
Blog: http://home.hit.no/~hansha/
Room: B-237a
FAQs
How data acquisition is done in LabVIEW? ›
LabVIEW-based data acquisition involves writing software on top of appropriate hardware to acquire data from various sensors (e.g., temperature, pressure, current, …). Those data are then usually manipulated and/or filtered before being displayed and/or recorded for further analysis.
How do I create a DAQ in LabVIEW? ›- Step 1: Identify Sensor Specifications. ...
- Step 2: Select a DAQ Hardware Platform or Device. ...
- Step 3: Install Software and Drivers. ...
- Step 4: Install NI CompactDAQ Chassis and C Series Modules. ...
- Step 5: Connect Sensors to Your NI C Series Module. ...
- Step 6: Learn LabVIEW Basics. ...
- Step 7: Write Your DAQ Program in LabVIEW.
Data acquisition, or DAQ as it is often referred, is the process of digitizing data from the world around us so it can be displayed, analyzed, and stored in a computer. A simple example is the process of measuring the temperature in a room as a digital value using a sensor such as a thermocouple.
What are important steps in data acquisition system? ›There are four methods of acquiring data: collecting new data; converting/transforming legacy data; sharing/exchanging data; and purchasing data. This includes automated collection (e.g., of sensor-derived data), the manual recording of empirical observations, and obtaining existing data from other sources.
What are the three major components of used for data acquisition? ›All data acquisition systems consist of three essential elements – Sensor, Signal Conditioning, and Analog-to-Digital Converter (ADC).
How do I write data to an Excel file in LabVIEW? ›- Open an . xlsx file using the New Excel Report node.
- Write data using Create Excel Data Sheet. It can write different data types, e.g. DBL, I32, string.
- Use the Close Excel Report node to close the Excel file again.
LabVIEW logs data each time you run the VI and appends a new record to the datalog file each additional time you run the VI. You cannot overwrite a record after LabVIEW writes it to a datalog file. To log your data interactively, select Operate»Data Logging»Log. LabVIEW appends the data to the datalog file immediately.
How to connect database to LabVIEW? ›...
These include:
- Microsoft Access.
- SQL Server.
- Oracle.
Right-click the device name and select Configure. Be sure to click the device name under the folder for the system (My System or Remote Systems) and NI-DAQ API in which you want to control the device. For Network DAQ devices, click the device name and then the Network Settings tab to configure network settings.
What is the purpose of DAQ? ›A general-purpose DAQ device is a device that acquires or generates data and can contain multiple channels. You also can use general-purpose DAQ devices to generate analog signals, such as a sine wave, and digital signals, such as a pulse.
Why do we need DAQ? ›
Data acquisition provides greater control over an organization's processes and faster response to failures that may occur. The procedures are optimized to the maximum to obtain products and services of quality that maximize the result of the company and increase its efficiency.
How does a DAQ process and output data? ›DAQ hardware is either connected to the computer using the USB ports or through the PCI-Express slots on the motherboard. The DAQ hardware takes in the analog signals from the sensors and converts them to digital signals readable by the computers.
What are the 5 components of data acquisition system? ›- Essential Components. of Data Acquisition Systems.
- Introduction.
- Measurement Hardware.
- A/D Converter: The A/D converter, a.
- Digital Input: Some data.
- Counter: Some data acquisition.
- Control Hardware.
- Analog Output: Some data.
Data acquisition: The first step in data management is to acquire process data in the control center without which no further actions are possible.
What are the two types of data acquisition system? ›- Computer-connected DAQ Modules.
- Stand-alone Data Acquisition Systems (also called Portable data acquisition systems with a built-in computer)
- Rack-mounting Data Acquisition Systems.
A data acquisition system is a collection of software and hardware that allows one to measure or control the physical characteristics of something in the real world. A complete data acquisition system consists of DAQ hardware, sensors and actuators, signal conditioning hardware, and a computer running DAQ software.
What are the 3 R's of data acquisition? ›The Three R's of a Data Acquisition System (DAQ) are - Resolution, Range and Rate.
What is DAQ in LabVIEW? ›What is DAQ? Data acquisition (DAQ) is the process of measuring an electrical or physical phenomenon, such as voltage, current, temperature, pressure, or sound. A DAQ system consists of sensors, DAQ measurement hardware, and a computer with programmable software such as LabVIEW.
What format is LabVIEW data file? ›The LabVIEW Measurement (. lvm) format is a text-based file format for one-dimensional data. This text-based measurement file is a tab-delimited text file you can open with a spreadsheet application or a text-editing application.
What are the three main data types available in LabVIEW? ›- Scalar.
- Char.
- Dynamic.
- Memory-related.
- Constants.
What is meant by data acquisition? ›
A data acquisition system (or DAS or DAQ) converts physical conditions into digital form, for further storage and analysis. Typically, signals from sensors (sometimes processed by sensor conditioners) are sampled, converted to digital, and stored by a computer, or by a standalone device.
How does data flow in LabVIEW? ›LabVIEW follows a dataflow model for running VIs. A block diagram node executes when it receives all required inputs. When a node executes, it produces output data and passes the data to the next node in the dataflow path.
How to connect CSV to database? ›- Choose the data source (CSV) that you wish to convert
- Choose input options to ensure the SQL queries are properly created.
- Choose output options to format your data.
- Copy the SQL queries, and run them in your database.
- Create a New Workspace.
- Import your CSV file.
The LabVIEW Database Connectivity Toolkit is a software add-on for LabVIEW that helps you perform many database operations without using structured query language (SQL) programming. It readily connects to popular databases, such as Microsoft Access, SQL Server, and Oracle.
How do I connect my database to my project? ›Right-click on the project and select Publish. The Publish Database pane appears where you need to check the Target Database connection. Also, make sure that you check the checkboxes that say Register as a Data-tier Application. Once you have verified the details, you can hit the Publish button.
How do I choose a DAQ device? ›- What types of signals do I need to measure or generate?
- Do I need signal conditioning?
- How fast do I need to acquire or generate samples of the signal?
- What is the smallest change in the signal that I need to detect?
...
Installing LabVIEW NI-DAQmx Examples in Windows
- Go to My Computer»Control Panel»Add or Remove Programs»National Instruments Software»NI-DAQmx.
- Select Change to modify this installation.
DAQ (Data acquisition) system can be controlled using LabVIEW. Explanation: DAQ (Data acquisition) system can be controlled using LabVIEW. LabVIEW provides an interface in which a user can manually enter one or many sample sets and can convert it into graphical form or manipulate it to give reasonable meanings.
What is the difference between analog and digital DAQ? ›Analog systems are used when wide bandwidth is required or when lower accuracy can be allowed. Digital systems are used when the physical process being monitored slowly varies and when high accuracy and low per-channel cost is required.
What are the four 4 benefits of using data acquisition systems? ›Data acquisition systems employ automation, which minimizes human error and misplacement. Additionally, storing information gathered digitally is cheaper, takes up less space than physical paper, and can be retrieved almost instantaneously. The data is also entered faster.
What type of signal is acquired by DAQ? ›
- Analog signals, which are obtained from the direct measurement of electrical quantities such as DC & AC voltages, DC & AC currents, resistance and etc.
- Analog signals, which are obtained from transducers such as LVDT, Thermocouple & etc.
Data acquisition format specification
Data is encoded using CBOR or JSON and signed according to the JSON Web Signature specification. Data can easily be generated by any language that has a CBOR or JSON library available, but there are examples available for C, C++, Node. js and Python.
Vision Acquisition Software is driver software for acquiring, displaying, and saving images from a wide variety of camera types. NI Vision Acquisition Software (VAS) enables you to acquire, display, and save images from a range of industry standard cameras interfaces including GigE Vision, USB3 Vision, and Camera Link.
How to record data in LabVIEW? ›To log your data interactively, select Operate»Data Logging»Log. LabVIEW appends the data to the datalog file immediately. Log your data interactively so you can select when to log the data. Logging your data automatically logs the data each time you run the VI.
What is NI data acquisition? ›NI Data Acquisition devices interface with Data Acquisition Toolbox™, which provides apps and functions for configuring data acquisition hardware, reading data into MATLAB® and Simulink®, and writing data to analog and digital output channels.
What are the four stages of data flow? ›Understanding the four stages of data: collect, curate, analyse, and act.
How does image acquisition work? ›In image processing, image acquisition is an action of retrieving image from an external source for further processing. It's always the foundation step in the workflow since no process is available before obtaining an image.
What are the objectives of LabVIEW? ›LabVIEW is used for 4 main purposes:
Automated Manufacturing test of a component/sub-system/system. Automated Product design validation of a component/sub-system/system. Control and/or monitoring of a machine/piece of industrial equipment/process. Condition monitoring of a machine/piece of industrial equipment.
An Express VI is a VI whose settings you can configure interactively through a dialog box. Express VIs appear on the block diagram as expandable nodes with icons surrounded by a blue field.
What are the 4 methods of recording data? ›Since most research involves the collection of data, there are several methods for direct, or primary, data collection, including surveys, questionnaires, direct observations, and focus groups.
What are the 5 methods of recording data? ›
- Surveys. Surveys are physical or digital questionnaires that gather both qualitative and quantitative data from subjects. ...
- Transactional Tracking. ...
- Interviews and Focus Groups. ...
- Observation. ...
- Online Tracking. ...
- Forms. ...
- Social Media Monitoring.
The most common data types are Integer, String, Arrays, Boolean and Float.
What happens in data acquisition? ›Data acquisition (commonly abbreviated as DAQ or DAS) is the process of sampling signals that measure real-world physical phenomena and converting them into a digital form that can be manipulated by a computer and software.
Why is DAQ used? ›Their common function is to covert analogic signals like light, temperatures, speed, etc. into digital signals for the computer. DAQ systems employ high-quality sensors that give accurate readings with minimal or no noise.