Sie sind auf Seite 1von 10

Experiment

Build a Temperature Sensor


6
A thermistor is a device whose resistance varies with temperature. Typical thermistors are made
from ceramic semiconductors or from platinum wires wrapped around ceramic mandrels or
spindles. Thermistors usually have negative temperature coefficients which means the resistance
of the thermistor decreases as the temperature increases. Thermistors are used extensively. They
are used throughout cars, for digital thermostats, to monitor the temperature of battery packs
while charging, measuring breathing patterns, and fluid flow measurements, to name just a few
applications. In this experiment, a thermistor will be placed in a voltage divider circuit in order to
create a sensor for measuring temperature. In addition, a LabVIEW subVI will be developed to
convert the raw voltage reading into temperature units.

OBJECTIVES
In this experiment, you will create your own temperature sensor with the following steps:
• Design and build a voltage divider circuit using a resistor and a thermistor
• Create a LabVIEW subVI to convert the voltage reading to temperature (ºC)
• Create a LabVIEW program to measure the voltage of the voltage divider circuit and
convert to temperature with the use of the subVI

Engineering with Computers 6-1


Experiment 6

MATERIALS
Windows computer 33K Ω resistor
Vernier SensorDAQ Hot and cold water bath
LabVIEW Jumper wires
Vernier Surface Temperature Probe Breadboard (optional)
(STS-BTA) or Stainless Steel
Temperature Probe (TMP-BTA)
Thermistor

THEORY OF OPERATION
The resistance-temperature relationship of a thermistor is nonlinear, but can be approximated
using the Steinhart-Hart model. This equation gives the absolute temperature as a function of the
resistance of a thermistor:

1
T =
( )
K 0 + K1 ln R + K 2 ln R ( )3
Where T is the temperature in Kelvin (K), R is the resistance of thermistor (ohms), and K0, K1
and K2 are the "Steinhart Coefficients" for a thermistor. Thermistor manufacturers publish data
for these coefficients for their thermistor products, or they can be determined from experimental
measurements.

BUILD THE CIRCUIT


As shown in the Steinhart-Hart equation above, the temperature of the thermistor can be
calculated if the thermistor resistance is known. The resistance of the thermistor is measured
indirectly by placing it in a two-resistor voltage divider circuit. In this circuit, two resistors are
connected as shown in the following diagram:

This is a common circuit design used to measure resistance. The output voltage Vout is related to
Vin as follows:

 
RT
V out = Vin  
 T
R + R1 

6-2 Engineering with Computers


Thermistor

Where Vin is the supplied voltage, Vout is the measured voltage, and R1 is a resistor placed in
series with the thermistor (RT).

From this equation we can solve for the thermistor resistance:

 V out R1 
R T =  
 V in − V out 

The values of R1 and Vin are known. The circuit will be built with a 33K Ω resistor (R1), and the
voltage supplied by SensorDAQ is 5.08 Volts (Vin). Therefore, the new equation is:

V out × 33000
(1) RT =
5 .08 − V out
You will measure the circuit’s output voltage (Vout) and solve for the thermistor’s resistance (RT).
As a second calculation, the thermistor resistance value (solved in equation 1) is used to solve for
temperature with the Steinhart-Hart equation. Note that the equation is modified slightly
(subtracting 273.15) to provide temperature in units of degrees Celsius (not Kelvin).

1
T = − 273.15
(2)
(
K 0 + K1 ln RT ) + K 2 (ln RT )
3

PRELIMINARY SETUP

1. Insert one lead of the 33K resistor into +5V on the SensorDAQ screw terminal (screw hole
6).

2. Connect the other lead of the resistor to one lead of the thermistor. Use a jumper wire to
connect this combination to analog input channel AI0 on the SensorDAQ screw terminal
(screw hole 11).

3. Insert the other lead of the thermistor into GND on the SensorDAQ screw terminal (screw
hole 10).

Engineering with Computers 6-3


Experiment 6

PROCEDURE
Part I Build a SubVI to Convert Raw Voltage to Temperature
You will build a LabVIEW VI that will convert a raw voltage signal to a temperature reading.
This VI will be placed inside of a top-level LabVIEW VI and used as a subVI in Part 2.

The finalized VI will look like the figure below:

1. Open a new, blank VI

2. The first calculation converts the voltage reading to the thermistor resistance (RT). Use
equation 1 above. To perform the equation use the Multiply, Subtract, and Divide functions
found in the Numeric palette.

a. Place the Multiply function on the Block Diagram.


b. Right Click on the upper input node and select Create>Constant.
c. Make this value 33000 (the resistor value)
d. Right click on the lower input node and select Create>Control. Give this control a label of
“Voltage Out”
e. Place the Subtract function on the Block Diagram
f. Right Click on the upper input node and select Create>Constant.
g. Make this value 5.08 (the value of Vin)
h. Wire the Voltage Out control into the lower node of the Subtract function.
i. Place the Divide function on the Block Diagram.
j. Wire the result of the Multiply function into the upper input node and the result of the
Subtract function into the lower input node.

4. Place a Formula Express VI on the block diagram. This Express VI is found in the bottom
left corner of the Numeric palette, and will be used to solve for temperature from the
Steinhart-Hart equation. Use equation 2 above.

6-4 Engineering with Computers


Thermistor

a. Enter “K0”, “K1”, “K2”, and “RT” in the Formula’s Label controls
b. Build the formula by pressing the calculator buttons (press the X1, X2, X3, and X4 button
to insert K0, K1, K2, and RT into the formula).
c. Press the “OK” button when the formula is complete.

5. Create numeric constants to represent the Steinhart-Hart coefficients, and then wire these
inputs into the Formula Express VI.

a. Place a Numeric Constant on the block diagram (found in the Numeric palette). Note the
blue color box around this number. The color of boxes, the color of wires, and the
thickness of wires in the LabVIEW block diagram are important, since they are used to
signify the data type. LabVIEW represents numeric data types as floating-point numbers,

Engineering with Computers 6-5


Experiment 6

integers, unsigned integers, and complex numbers. (The difference among the numeric
data types is the number of bits they use to store data and the data values they represent.)
The blue color shows that this numeric value is represented as an integer.

b. Change the representation of this numeric to a double-precision, floating-point number.

· Right click on the number and select Representation>DBL. Note the color change.
c. Make 2 more copies of this numeric (an easy way to do this is to press and hold the Ctrl
key as you click on the number and drag a new copy)
d. Change the values of the 3 numeric constants to the proper K0, K1, and K2 values.

e. Locate these numbers next to the inputs of the Formula Express VIs and wire them in.
7. Wire the result (RT) of the thermistor calculation into the proper input of the Formula Express
VI. Create an indicator for the temperature output.

a. Wire the result from the Divide function (where RT was solved for) into the RT input of
the Formula Express VI.
b. Right click on the Result output of the Formula Express VI and choose Create>Numeric
Indicator. Label this indicator “Temperature Out”.
8. Build the icon and connector pane so that you can use this VI as a subVI.

6-6 Engineering with Computers


Thermistor

a. Go to the front panel and right click the icon in the upper right corner and select Edit Icon.
The icon editor dialog box appears.
b. Use the Icon Editor tools to draw an icon or write descriptive text (like the icon above).
c. When the icon is completed, click the OK button.
d. Right click the icon in the upper right corner again, and select Show Connector. It should
look like two rectangles inside the icon.

e. Click the left terminal (left rectangle) and then bring your mouse into the front panel and
click on the “Voltage Out” control. The left terminal should turn orange.
f. Click the right terminal and then click on the “Temperature Out” indicator. The right
terminal should turn orange.
9. The VI has now been configured for use as a subVI. Select File>Save and name the VI.

Part II Insert the subVI into the Top-Level VI


In Part 1 you built a subVI. In this section you will take the subVI and place it into a new VI that
collects data from Ch. 1 and AI0, converts the AI0 voltage to temperature, and displays all three
plots (Ch. 1 temperature, AI0 raw voltage, and AI0 in temperature units) on a single Chart. The
final VI will look like the figure below:

1. Build a VI that collects data from Ch. 1 and analog input terminal AI0 at a user-defined
sample rate. Data collection should continue until the user presses a stop button.

Engineering with Computers 6-7


Experiment 6

a. Insert and wire the Setup, Modify, Start, Read and Stop driver subVIs. (These should be
located in the SensorDAQ sub-palette found in the User Libraries palette).
b. Right click on the Config Ch. 1-3 node and the AI0 Configuration node of the Setup driver
subVI and choose Create>Constant. Set these inputs to collect data from Ch. 1-3 and AI0.
c. Right click on the Sample Rate node of the Modify driver subVI and choose
Create>Control. Go the front panel and make the rate 1 sample per second.
d. Create a constant for the Collection Parameters Enum input and select Modify with Inputs
into this subVI.
e. Encircle the Read driver subVI with a While Loop that is stopped with a Boolean control.
2. Create code to format the Ch.1 and AI0 voltage data arrays as single data points, and convert
the AI0 voltage data point into a temperature data point.

a. The Read driver subVI is configured to send back multi-point and single-point data from
Ch.1-3, AI0 and AI1. This provides flexibility in the program, and allows the use of just
one driver subVI for both scenarios. However, it means that the subVIs connector node for
the data must be in array data format. Array format allows a single point to be returned (an
array of 1 element) and it allows multi points to be returned (an array of N elements) – so
it covers both scenarios. However, this also means that if you need to analyze a single data
point (for comparison or to send to an indicator) you must extract the point out of the
array. Use the Index Array function to pull out this data point.
· Add 2 Index Array functions (Find this function in the Array palette, or press the
“Search” button at the top of the Function palette and type in “Index Array”).
· Wire the CH 1 data into the “array” input node of the first Index Array function and the
AI0 data into the array node of the second Index Array function.

6-8 Engineering with Computers


Thermistor

For both Index array functions, right click on the “Index” node and select
·
Create>Constant. Leave this input as 0. This code is used to pull out the first value of the
array.
b. Add the VI that your created in Part 1 (converts voltage to temperature) into the block
diagram.
· Click on the Select a VI Function palette.
· A popup dialog appears. Browse to the VI and open it
· Place it in the block diagram.
c. Wire the AI0 data point (this is the AI0 voltage) coming out of the Index Array function
into the “Voltage Out” node of the subVI. This subVI will convert this voltage into a
temperature reading.
3. Display the Ch. 1 data point, the AI0 voltage data point, and the AI0 temperature data point
as three plots on the same chart. (Sending a cluster of data points into a chart creates a multi-
plot chart).

a. Place the Bundle function onto the block diagram (located in the Cluster palette).
b. Resize the Bundle function to have three inputs instead of just two

· Locate your cursor at the bottom middle of the function so that it changes into an up and
down arrow.
· Click and drag down to resize the function to have three inputs.
c. Wire the Ch. 1 data into the top input, the temperature into the middle input, and the AI0
voltage into the 3rd input.
d. Go to the Front Panel and create a chart
e. Go to the Block Diagram and move the chart terminal next to the Bundle function.
f. Wire the output cluster data from the Bundle function into the Chart terminal.

4. The VI is now complete. Modify the Front panel if needed and save the VI

Part III Run the VI and Measure Temperature


1. Run the VI created in Part 2. Measure the temperature using the thermistor circuit and a
commercial Surface Temperature sensor (or Stainless Steel Temperature sensor) connected to
Ch. 1. Having the temperature sensor in Ch. 1 allows for a direct comparison, making it much
easier to troubleshoot your circuit and your program.

Engineering with Computers 6-9


Experiment 6

2. Check the calibration of your temperature sensor over a range of temperatures. Compare the
readings of the two sensors in ice water, room temperature, and hot water. Make sure that you
provide time for the reading to stabilize (note that if you are using a Stainless Steel
Temperature sensor in Ch. 1 the temperature readings do not respond as quickly as a
thermistor). After completing the measurements, dry off the thermistor.

EXTENSIONS
1. Modify the VI to add a Table for the data. The data should only be sent to the table if the user
presses a button. To do this you can add an Express Table to the Front Panel. In the block
diagram use a “Merge Signals” function to merge the Ch.1, AI0 voltage, and AI0 temperature
data. The Merge Signals function converts the data into a proper data type format for the
Build Table Express function. Use a Boolean control to input a True or False into the
“Enable” input of the Build Table Express function.

2. Modify the subVI that converts voltage to temperature. Provide extra code to convert the
temperature reading to degrees Celsius, degrees Fahrenheit, or Kelvin. The subVI should now
have a control that controls what units the data are returned in. In order for the user to be able
to control the units from the top-level VI you will need to add a new connector to the subVI.

3. SensorDAQ has an input impedance of 1 M ohm that provides an “external” load on the
voltage divider. We have ignored this fact in the voltage to temperature calculation. Modify
the subVI that converts voltage to temperature to take into account this loading. The load
resistance and the thermistor resistance are in parallel. Draw up this new circuit and
determine the new/modified code that is required in the conversion.

4. Use the thermistor in a sensor based control system. If the temperature gets too high, turn on
a fan, if it gets too cold turn on a heat source. Use the DCU (or the digital output terminals) to
control the electronic devices.

6 - 10 Engineering with Computers

Das könnte Ihnen auch gefallen