0% found this document useful (0 votes)
9 views

Practice

aaaadsad

Uploaded by

Abid Hussain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Practice

aaaadsad

Uploaded by

Abid Hussain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ASME Workshop on Sensor Interfacing with LabVIEW

Najib Metni, Ph.D.



Tutorial on Thermocouple Interfacing and Data
Acquisition using LabView

This tutorial will help you deal with the sensor interface hardware and software.
We will design a hardware circuit for amplifying the sensor signal before connecting
it to the DAQ. The temperature measurement will be initiated by an external trigger
(Digital Switch).

I would like to thank Mr. Elie Kfoury for his help in preparing this tutorial.


Part I The Hardware



Step 1: Building the switching circuit

Generally, systems acquire sensors readings from an external trigger. We will build a
switching circuit to simulate this external trigger.
You will need a switch and an npn BJT (a transistor). Set the circuit wiring on your
NI ELVIS breadboard as shown in Figure 1 below. When the switch is closed, the
transistor will enter in saturation and it opens, the collector and emitter will become
connected. Therefore, the digital input becomes zero.

5 V
To Digital Input
5 V
R
1
=1k
R
1
=1k


Figure 1 The Switching Circuit

Page 2
ASME Workshop Thermocouple Interface Tutorial March 6, 2008

Step 2: Connecting the switching circuit output to the DAQ

After building the switching circuit, we have to connect it to the data acquisition card
to work as a trigger (we will acquire the reading on the falling edge of the digital
input). The connection is as follows: connect the Digital input to DI 0 on NI ELVIS,
then connect the transistors emitter to the GROUND of NI ELVIS.


Step 3: Building the amplification circuit

The voltage signal of the thermocouple is usually in the milli-volts range, hence
amplification is needed. One of the most used amplifiers is the "instrumentation
amplifier [IA]" (or high impedance differential amplifier). Aside from amplification,
this IA has the potential to remove common mode noise. It is formed by three
operational amplifiers a shown in Figure 2 below. We will connect this circuit on the
breadboard by using the quad Op-Amp IC (LM324) to save wiring complexity.


Figure 2 The Instrumentation Amplifier

The output of the amplifier is given as:
3 1
2 1 2
2
1
out
gain
V R R
V V R R

= +

( )
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.

You might also like