Practice
Practice
( )
3 1
2 1
2
2
1
out
gain
R R
V V V
R R
= +
For example, if we choose R
gain
=R
1
=R
3
=100k, and R
2
=1 k, then:
( )
2 1
300
out
V V V =
Therefore, the output voltage is amplified by 300 times.
Page 3
ASME Workshop Thermocouple Interface Tutorial March 6, 2008
Below, you can check the pinout of the LM324 quad-amplifier (V
cc
= 5V)
Step 4: Connecting the thermocouple to the amplifier, and then to the DAQ
After building the amplifier, connect the two terminals of the thermocouple to the V
1
and V
2
terminals shown on Figure 2. Then connect The V
out
terminal of the IA to
ACH0
+
on NI ELVIS. Also, connect the ground of the amplifier shown in Figure 2 to
the GROUND pin on NI ELVIS.
Part II The Software
Step 1: Constructing the LabVIEW part to monitor the status of the switch
The first section of building the LabVIEW virtual instrument is to read the switch
status. The block diagram is shown in Figure 3 below.
Figure 3 The VI that monitors the status of the switch
Page 4
ASME Workshop Thermocouple Interface Tutorial March 6, 2008
The steps for building the above VI are shown below:
Step a: Right click on the block diagram. Go to "Instrument I/O", then to
"Instrument Drivers", then to "NI ELVIS", then to "Low Level NI ELVIS VIs",
then to "Digital IO", then to "NI ELVIS DIO Initialize.vi". Place this node to the
leftmost on your block diagram as shown in Figure 3.
Step b: Repeat the same procedures explained in Step a, and go to "NI ELVIS
DIO Read.vi" and place this VI to the right of the "initialize.vi".
Step c: Repeat the same procedure again and go to "NI ELVIS DIO Close.vi"
and place it to the right of the "Read.vi".
Step d: Right click on the block diagram and go to "Dialogue and User Interface",
then pick the "simple error handler.vi" and place it to the right of the "Close.vi".
Step e: Right click on the Block Diagram and go to "Structures", then choose the
"While Loop". Place the while loop over the "Read.vi" as shown in Figure 3
above.
Step f: Move your mouse over the left edge of the "NI ELVIS DIO Initialize.vi"
and right click on "Device Name" and then go to "Create" then go to "Constant".
You will see a purple text line with a downwards pointing arrow to its left. Click
on the arrow, and choose "Dev1".
Step g: Keep your mouse on the left border of the "NI ELVIS DIO Initialize.vi"
and then right click on "Operation", and then go to "Create", and then go to
"Constant". You will see a blue text line with a downwards pointing arrow to its
left. Click on the arrow, and choose "Read".
Step h: Right click on the block diagram and go to "Comparison", and go to
Equal?. Place it below the right border of the "NI ELVIS DIO Read.vi" as
shown in Figure 3 above. Right click on the lower left input of the "Equal?" node
and go to "Create", then go to "Constant". Write "1" in the constant that appears.
Step i: Wire the boolean output of the "Equal?" node to the loop stop condition.
And wire all the nodes as shown in Figure 3 above.
Step 2: Constructing the LabVIEW part to acquire the temperature reading
The second section of the LabVIEW VI is to read the voltage from the thermocouple,
and convert it into a temperature reading (after calibrating your sensor). Figure 4
below, shows the Block Diagram of the VI. The steps for creating the VI are shown
below.
Page 5
ASME Workshop Thermocouple Interface Tutorial March 6, 2008
Figure 4 The VI that acquires the voltage of the thermocouple
Step a: On the same previous VI, right click on the Block Diagram. Go to
"Measurement IO", then go to "DAQmx Data Acquisition", then go to "DAQmx
Create Virtual Channel.vi". Place it to the right of the first part of the VI (the part
needed to read the status of the switch). Right click on "Physical Channels" (on
the left border of the "DAQmx Create Virtual Channel.vi"), then go to "create",
then go to "constant". You will notice that text line appears with a downwards
pointing arrow on its right side. Click on that arrow and go to "Dev1/ai0". If you
wish to determine the upper value and/or the lower value of the read voltage, then
right click on "maximum value" and "minimum value" (located on the top edge of
the "DAQmx Create Virtual Channel.vi") and then go to "create" then "constant",
and then enter the values of the maximum and the minimum correspondingly.
N.B: You might need to determine the values for minimum and maximum if you
want to increase the resolution of the acquired voltage (by allowing the DAQ
amplification to use the entire A/D converter bits over the specified range).
Step b: Right Click on the Block Diagram. Go to "Measurement IO", then go to
"DAQmx Data Acquisition ", then go to "DAQmx Read.vi". Place it to the left of
the "DAQmx Create Virtual Channel.vi".
Step c: Right Click on the Block Diagram. Go to "Measurement IO", then go to
"DAQmx Data Acquisition ", then go to "DAQmx Clear Task.vi". Place it to the
right of the "DAQmx Read.vi".
Step d: Right click on the block diagram and go to "Dialogue and User Interface",
then pick the "simple error handler.vi" and place it to the right of the "DAQmx
Clear Task.vi".
Step e: Right click on the Block Diagram and go to "Structures", then choose the
"While Loop". Place the while loop over the "DAQmx Read.vi" as shown in
Figure 4 above.
Step f: Enter the calibration Equation by placing a formula node in the while loop:
Right click on the block diagram. Go to "Structures", and then to "Formula Node".
Place the node under the right edge of the "DAQmx Read.vi" as shown in Figure 4
above. Then, right click on the left edge of the formula node, and go to "Create
Input", then name the input "voltage". Then right click on the right edge of the
formula node and go to "Add Output", and then write Temp. (This formula is
Page 6
ASME Workshop Thermocouple Interface Tutorial March 6, 2008
just an example, we cannot get the true calibration equation unless after
thermocouple calibration).
Step g: In this step, Filtering should be applied to the acquired signal. To do this,
right click on the block diagram, then go to signal processing, then go to point
by point, then go to probability and statistics point by point, then go to mean.
Right click on the lower left edge of the mean block, then go to create, then
go to constant, then enter a value of 10 to the constant. This means, that this
filter is a moving average of 10 temperature readings.
Step h: Place a waveform chart on the front panel. Then wire the VI as shown in
Figure 4 above.
Step 3: Completing the LabVIEW VI
Right click on the block diagram and then go to structures, then go to flat sequence
structure. Place it on the block diagram. Right click on the right border of the flat
sequence, and then go to "add frame after". Now place the whole part of the code that
has been written in.
Step 1: Constructing the LabVIEW part to monitor the status of the switch" in the
left box of the flat structure. Then place the whole code that has been written in.
Step 2: Constructing the LabVIEW part to acquire the temperature reading". The
final code block diagram is shown in Figure 5 below.
Figure 5 The complete block diagram of the VI
Page 7
ASME Workshop Thermocouple Interface Tutorial March 6, 2008
Part III The DAQ Assistant
In order to make things easier, National Instruments have create a subVI that aids us
in configuring data acquisition devices and/or sensors. This subVI is called the DAQ
Assistant subVI. In order to work with it, right click on the block diagram, then go
to Measurement I/O, then go to DAQmx Data Acquisition, then go to DAQ
Assistant.
When DAQ is placed in the block diagram, a series of pop-up windows provides the
medium to create and configure DAQmx tasks.
Figure 6 Series of window pop ups that configure the data acquisition for DAQ Assistant
Select Measurement Type
Select Analog Input
Select Temperature
Select Thermocouple
Select ai0 associated with Dev1 then
Select Next. A new dialogue box appears to assign a name to the task.
Assign a name and
Select Finish
At this point, the DAQ Assistant opens a window which displays the options for
configuring the selected channels. The Settings tab allows setting of the input range
and the Task Timing tab selects the number of samples. At this point you can click
the Test button to access the Analog Input Test Panel dialog box to test the channel
by clicking on the Start button. Once done, click OK to return to DAQ Assistant
window. Click OK again to return to the block diagram. Once there, right click on the
Data output of the DAQ Assistant Express VI and select Create >> Graph
Indicator.