Data Acquisition (DAQ) hardware provides simple interface to bring Analog/Digital signals in to your computer and the LabVIEW software is used to process the acquired signal. For example you can connect a thermocouple sensor to the DAQ module via analog input channel and with the help of LabVIEW VI read / display the current temperature.
In this tutorial I will construct a data acquisition virtual instrument (VI) in LabVIEW for MiniLab1008 DAQ Module. The information provided here will facilitate the understanding of LabVIEW software and data acquisition hardware. LabVIEW is a trademark of National Instruments Corporation (NI) and the data acquisition hardware we are using is from Measurement Computing (MCC).
The cost of Minilab1008 USB DAQ Module is around $129
See MCC site for more information on MiniLab1008 : http://www.measurementcomputing.com/
See NI site for more information on LabVIEW: http://www.ni.com/labview/
Step 1: Communication Link
The drivers provided with the Measurement Computing (MCC) DAQ modules do not
offer direct control of the hardware from the LabVIEW software. We need Universal Library to communicate with the LabVIEW. See figure 1.1 for hierarchical communication link between LabVIEW and the MCC Minilab1008 DAQ.
Step 2: Two Parts to a VI - Front Panel and Diagram
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 fig 1:
Step 3: Detecting Hardware & Starting LabVIEW
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.
Step 4: Designing Front Panel
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.
Step 1 - Adding Digital Control
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 #".
Repeat this 3 times by adding more digital control 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
Step 5: Designing Front Panel
Step 2 - Adding Control for Error Messages
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.
Step 6: Designing Front Panel
Step 3 - Choosing Graph for plotting
To plot the acquired data, go to GRAPH menu as shown in Fig 4, select WAVEFORM
GRAPH and label it as Display.
NOTE: With manipulation of G objects, the front panel could look like as shown in Fig. 1.
Step 7: Designing Diagram Panel
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:
Step 8: Designing Diagram Panel
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:
Step 9: Designing Diagram Panel
Step 1 - Adding Analog Input Function
From Functions menu select MCC Icon and choose AlnScFg Input from Analog Input as shown in Fig 6
NOTE: To turn on HELP, from the Help menu, choose Show Help . When the mouse is kept on any part of the diagram, a help window will show on the screen. For example the help for "AInScFg" is shown as in Fig 7.
Step 10: Designing Diagram Panel
Step 2 - Add Signal Conditioning functions
From the Functions menu select MCC and choose ToEng from Signal Conditioning as shown
in Fig 8.
Details of ToEng.VI is shown in Fig 9
Step 11: Designing Diagram Panel
Step 3 - Add Error Message Handing
From the Functions menu select MCC and choose ErrMsg from MISC (Calibration & Configuration) as shown in Fig. 10
Fig.11 shows the help for "Err Msg" function.
Step 12: Designing Diagram Panel
Step 4 - Numeric Constant
From the Functions menu select Numeric and choose Numeric Constant as shown in Fig 12.
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.
Step 13: Designing Diagram Panel
Step 5 - Ring Constant
From the Functions menu select Numeric and choose Ring Constant as shown in Fig 13.
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
Step 14: Designing Diagram Panel
Step 6 - Build Waveform
From the Functions menu select Waveform and choose Build Waveform as shown in Fig 14.
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 in the yellow box 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.
Step 15: Designing Diagram Panel
Final Step - Connecting the boxes
At this point it is important to understand the tool bar. The tool bar is used for choosing different tools. Fig. 16 gives a 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.
When the wire 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.
Step 16: Designing Diagram Panel
On completion and if the wiring is correct, the diagram should look like the one shown in Fig. 18.
There are some additional optional components and the wiring you see in the diagram:
After connecting all the wires as shown in Fig.18, 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 right arrow as shown in fig.16 below 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 the right arrow
To do a continuous data acquisition click on the loop arrows and the data acquisition will continue until STOP button is pressed.
Written by Tariq Naqvi
Participated in the
The Instructables Book Contest