LabVIEW Tutorial for Data Acquisition 1 University of

advertisement
University of Waterloo
Systems Design Engineering
LabVIEW Tutorial for Data Acquisition
By Tariq Naqvi.
Please refer to link “Introduction to Data Acquisition system and LabVIEW ” on SD292 Lab website
before you read the following. The information provided by this link will facilitate the understanding
of LabVIEW software, data acquisition hardware and the terminology that is used in the following.
LabVIEW is a trademark of National Instruments Corporation and the data acquisition hardware we
are using is from Measurement Computing.
With the help of this tutorial you will construct a data acquisition virtual instrument (VI) in LabVIEW.
There are two parts to a VI: the panel and the diagram. The panel resembles the front panel of an
instrument and the diagram is where you make connections with various components.
This VI will acquire the data from a specified channel and display it on front panel. There is no text
programming involved in LabVIEW. The VI when complete should look like the following:
Figure 1 - Front Panel
LabVIEW Tutorial for Data Acquisition
1
Procedure:
Click
to start InstaCal software from Measurement Computing. This is necessary as it would
allow the PC to detect the connected DAQ hardware.
Click
on your desktop to start LabVIEW. Click NewVI to start a new VI application.
Front Panel
Front Panel Design:
For data acquisition to work we need to provide controls, functions and indicators in the VI. Controls
allow us to change the value of parameters, indicators allow us to graph and chart data, and functions
provide the processing or the input/output control of the acquired data.
1. Explore the Controls menu. Choose DIGITAL CONTROL from the Numeric window as
shown in Fig 2. A field will appear on the panel, label it as "Board #".
Figure 2-Numeric Controls
1. Repeat this 3 times and label them as “Sample Rate”, “Low Channel” and “High Channel”.
These controls will allow us to enter the numeric values for the Minilab1008 data acquisition
board.
LabVIEW Tutorial for Data Acquisition
2
2. For using the Error control, LabVIEW reads from a set of strings. From the String & Path
Controls menu, as shown in Fig 3, select String Indicator and label it as Error Message.
Remember this is a window for error messages relating the status of the hardware.
Figure 3-String controls
3. To plot the acquired data, go to GRAPH menu as shown in Fig 4, select WAVEFORM
GRAPH and label it as Display.
Figure 4- Waveform Graphs
NOTE: With manipulation of G objects, the front panel could look like as shown in Fig. 1.
LabVIEW Tutorial for Data Acquisition
3
Diagram
Diagram Design
Click on the diagram part of the VI. You will notice another floating palette titled Functions. This
palette has a variety of functions and sub-VIs that control all aspects of the DAQ board or module and
signal measurement and processing. If you have labeled all the numeric controls and indicators, then
you will find their terminals on the diagram labeled appropriately. In case you forgot to label the
numeric and strings just as you brought them into front panel it can be confusing. Use the right click
mouse while selecting the terminal and choose "Find Terminal" from the menu. Alternatively, you can
double-click on the terminal in the diagram and it will point to the control in the front panel. To get to
the diagram, go to the Windows menu and select SHOW DIAGRAM. The diagram should look as
shown in Fig. 5:
Figure 5 - Diagram
To change the numeric representation as shown in figure 5., right click on the numeric box and from
the Representation menu change the numeric integer type as shown below:
LabVIEW Tutorial for Data Acquisition
4
1. From Functions menu select MCC and choose AlnScFg Input from Analog Input as shown in
Fig 6
Figure 6-Analog I/O functions
Hint:
To turn on HELP, from the Help menu, choose Show Help . When the mo use is kept on the any part of
the diagram, a help window will show on the screen. The help for "AInScFg" is shown in Fig 7.
This VI scans a range of AD channels in the foreground and stores the samples in an array.
Figure 7-Analog Input for acquiring waveforms
LabVIEW Tutorial for Data Acquisition
5
2. From the Functions menu select MCC and choose ToEng from Signal Conditioning as shown
in Fig 8.
Figure 8-Signal Conditioning functions
The help for "ToEng" is shown in Fig 9.
Figure 9-Signal conditioning to convert raw A/D data
LabVIEW Tutorial for Data Acquisition
6
3. From the Functions menu select MCC and choose ErrMsg from MISC (Calibration &
Configuration) as shown in Fig 10.
Figure 10-Error Message Handling
The help for "ErrMsg" is shown in Fig 11.
Figure 11- Error message return
LabVIEW Tutorial for Data Acquisition
7
4. From the Functions menu select Numeric and choose Numeric Constant as shown in Fig 12.
Figure 12- Numeric Constant
Note: Enter numeric value 1000 into the constant field. Repeat step 4 and enter value 0.
The reason we are doing this is to provide an input to number of samples to collect and also to
provide an input to t0 (trigger time of the waveform). Please see figure 18 for more information.
5. From the Functions menu select Numeric and choose Ring Constant as shown in Fig 13.
Figure 13- Ring Constant
Note: Enter “Not Programmable” text in the first constant field and then enter numeric value
+-10V into the second constant field. To add a second field right click on the box and choose
“Add item after” from the menu and then type +-10V.
The reason we are doing this is to provide an input to the Range. This is used for collecting the A/D
sample. The input voltage range for linear operation, single ended mode for MiniLAB1008 is
±10Vmax.
LabVIEW Tutorial for Data Acquisition
8
6. From the Functions menu select Waveform and choose Build Waveform as shown in Fig 13.
Figure 14- Build Waveform
The reason we are building our own waveform is that we need to customize the x-axis scaling. Changing
the X-axis to display Time would help us to visualize the graph in a meaning full manner. Once you
insert the build waveform component drag the middle end to make it look as shown below:
Note: Select the Position/Size cursor from the Tools palette in order to drag and increase the middle
end.
The help for "Build Waveform” is shown in Fig 15.
Figure 15- Build Waveform
LabVIEW Tutorial for Data Acquisition
9
At this point it is important to understand the tool bar. The tool bar is used for choosing different tools.
Figure 16 - Tool bar description
While designing a diagram remember the following rules:
For any Function or sub-VI the inputs to it are always to the left and the outputs are always to the
right.
To look at all the connections, go to the Help menu and choose "Show Help". With Help turned on, as
you move your editing tool on a function/sub-VI the help screen will pop up. The entire screen
captures in this document are from the "Help" screen.
When the
tool is placed over a function or a sub-VI, the terminals on the functions light up with
the connections highlighted. This makes it easy to connect the wire to appropriate terminals.
If the connections between two functions/sub-VIs are incompatible, then a dotted (-----) line will
appear between the connections rather then a solid line. This means that the wire connection is
carrying incompatible data (e.g. an array to a number or a cluster to an array). Check the connections
again with the "Help" screen or by looking at Fig 18.
Using the wire tool
, connect the appropriate controls to the sub-VI as shown in Fig 18. Connect
the graphing indicator on towards the end of your construction. When your implementation is
complete, the tool bar will show the status of the VI. As said before if a connection is bad or is not
appropriate, it will show on the diagram with a broken line. If the terminals are not connected
appropriately, the tool bar will display the status as shown in Fig 17.
Figure 17 - Tool bar status
LabVIEW Tutorial for Data Acquisition
10
On completion and if the wiring is correct, the diagram should look like the one shown in Fig. 18.
Please consult with a TA for more help on additional components and the wiring you see in the
following diagram:
Figure 18 - Diagram of data acquisition VI
After connecting all the wires as shown above, proceed to the front panel and fill in the appropriate
information on the front panel as described below:
Low & High Channel as 0 for Channel control. Adjust your function generator to output 100 Hz, 2v pp sine wave signal
Depending on the frequency of the input waveform, enter an appropriate sampling frequency number.
The number that you enter should be at least twice the frequency of the input waveform.
In the Count, put the same number as the Sample rate.
After entering the appropriate information, click on the
to begin acquiring data.
If the information entered was correct the collected signal will appear on the front panel.
As you may have noticed, the data acquisition is done only at the time of clicking
To do a continuous data acquisition, follow these steps:
Click on
and the data acquisition will continue until STOP is pressed.
Show your first VI to the lab instructor. Save the VI on your Nexus drive.
To Access your nexus drive (N drive) type \\ecfile1\<username> in Start -> Run-> field
DO NOT SAVE YOUR WORK ON LAB HARD DISKS
LabVIEW Tutorial for Data Acquisition
11
Download