Introduction
The purpose of this task is to give learners experience of using the LabVIEW development environment to conduct data acquisition by conducting a lab experiment. The experiment shall be seeking to measure the temperature change of an object as it transitions from a room temperature air environment to a cold water environment. A thermistor shall be covered in a small amount of blu-tack (or similar material) and in this experiment we shall seek to establish the time constant governing the rate of change of temperature for this solid body.
This set of notes shall initially present some theory describing:
- the functioning of a thermistor measurement sensor.
- the design and analysis of a measurement circuit.
- the method for determining the time constant of the heat transfer dynamics that governs the rate of change of temperature.
The notes shall then present a step-by-step walk-through for the creation of a LabVIEW VI which will be used to take the measurements (data acquisition), present the temperature to the user in real-time and store the data for later analysis (data storage).
Finally, these notes shall describe the experiment setup and present a coursework task: to conduct the experiment and report results in a laboratory report format.
Prerequisites
This lab experiment references a specific hardware and software setup [i.e.: a Windows 10 workstation; LabVIEW 2020 w/ NI-DAQmx installed, a NI USB-6008 DAQ device, a 10 kΩ Thermistor]. Whilst the candidate’s setup may not match this equipment specification precisely, it is assumed that their setup will be similar in kind and that these notes could be adapted to an alternative arrangement.
- All NI software and drivers (LabVIEW 2020 w/ NI-DAQmx and NI DAQ-6008 drivers) should be installed on the candidate’s workstation PC in accordance with NI documentation: https://www.ni.com/getting-started/install-software/
- Help with installing and configuring NI USB DAQ devices can be found at this NI online resource: https://www.ni.com/getting-started/set-up-hardware/data-acquisition/usb
- Help with connecting analogue voltage signals to a DAQ device can be found at this NI online resource: https://www.ni.com/getting-started/set-up-hardware/data-acquisition/analog-voltage
In working through these notes, the following materials may be of general help:
- https://www.ni.com/getting-started/labview-basics/online-help (NI LabVIEW Online Help Resources)
- LabVIEW Introduction and Programming Notes, RLO 1 to RLO 7 (Doug Rattray, LCC, UHI – 2020).
Equipment List and Hardware/Software Requirements
Before starting this laboratory experiment, the following hardware and software should be ready for use:
- Workstation PC with the following software and drivers installed:
- LabVIEW 2020.
- Data acquisition to LabVIEW driver: ‘NI-DAQmx’
- The drivers associated with the particular DAQ device.
- NI USB-6008 DAQ Device (or similar) with proprietary USB cable.
- A Digital Multimeter
- Measurement Circuit Components:
- 10 kΩ NTC Thermistor temperature sensor.
e.g.: RS 697-4465 - https://uk.rs-online.com/web/p/thermistor-ics/6974465/ - 10 kΩ resistor
- Breadboard
- Wiring
- 10 kΩ NTC Thermistor temperature sensor.
- experiment apparatus:
- Blu-tack (or similar)
- A Glass of cold water (or similar)
- A thermometer (optional)
Required Background Knowledge
This lab experiment requires a basic understanding of the following aspects of theory:
- the functioning of a thermistor measurement sensor.
- the design and analysis of a measurement circuit.
- the method for determining the time constant of the heat transfer dynamics that governs the rate of change of temperature.
For revision, a review each of these shall be presented in the subsequent sections – where learners feel that their existing knowledge is adequate, it may be appropriate to skip one or more of these sections.
Thermistor Function
A thermistor is a type of resistor whose resistance varies with changes in temperature. Many thermistors fall into two distinct types:
- Positive Temperature Coefficient (PTC) thermistors – whose resistance increases as temperature rises – are commonly used to protect against overcurrent conditions when connected in series to a circuit.
- Negative Temperature Coefficient (NTC) thermistors – whose resistance decreases as temperatures rises – are commonly used for temperature sensing or to act as an inrush current limiter when connected in series to a circuit.
It is an NTC thermistor that we shall be using in this experiment. NTC thermistor technology has improved significantly since the turn of the century and can now be purchased at very low costs whilst still retaining very good stability and accuracy. It is common for thermistors to be rated to operate across a wide temperature range (circa. −55°C to +150°C ), but normally performs best between 0°C to 70°C.
Thermistor manufactures typically try to achieve a linear relationship between changes in resistance and changes in temperature such that for NTC resistors:
Where:
- ‘∆T’ and ‘∆R’ are the change in temperature and resistance, respectively.
- ‘k’ is some constant value.
However, this first order relationship is generally only true over a limited temperature range. Over wider temperature ranges, the manufactures normally specify the resistance-temperature relationship by a third order approximation colloquially known as the β parameter equation:
rewritten as:
_____eq.(1)
Where:
- ‘TTHERM’ and ‘RTHERM’ are the actual temperature and resistance of the thermistor.
- ‘T0’ and ‘R0’ is the reference temperature and resistance as specified by the manufacturer – in our case 10 kΩ at 25°C [298 K].
- ‘β’ is a constant value of 4038.
It is this third order formula (eq. (1)) that we shall be using when analysing the thermistor function in our lab experiment.
Design and Analysis of the Measuring Circuit
In this lab experiment, we shall be using the NI USB-6008 DAQ device. This unit does not have the capability to measure resistance directly, therefore, to measure the changing resistance of the thermistor we shall take resistance measurements indirectly. We shall do so by building the following basic voltage divider circuit:
© Doug Rattray, LCC, UHI
‘VMEAS’ is the voltage that we shall measure using the DAQ device, and is calculated using the following formula:
The resistance of the thermistor can therefore be evaluated by rearranging the above formula in terms of ‘RTHERM’:
_____eq.(2)
We can now combine eq. (1) and eq. (2) to express the temperature of the thermistor in terms of the measured voltage and various constants (manufacturer specified reference values):
_____eq.(3)
Just for clarity, the constant values in the above equation are (for our particular equipment list):
T0 = 298 K R0 = 10 kΩ Vs = 5 V β = 4038
Determining the Time Constant of the Temperature Change in a Solid Body
When an object has been located in a stable temperature environment (e.g.: AIR) for some time, its internal temperature can be assumed to be at the same constant temperature as its surroundings.
© Doug Rattray, LCC, UHI
When that object is then moved to a cooler environment (e.g.: WATER), its internal temperature goes through a transient change in temperature as it adjusts to its new surroundings.
© Doug Rattray, LCC, UHI
The rate of change of this transient temperature change is based on various material properties of the object (such as its surface area, density, specific heat, and coefficients of heat transfer). Where these properties are unknown, the transient behaviour can be modelled instead as an exponential decay function and described by stating the time constant of the temperature change. The time constant is a measure of how quickly the object responds to the change in the temperature of its surroundings.
Note that the time constant of temperature change describes the behaviour of the transient temperature change but does not tell us anything of the material properties of the object.
The time constant is given the symbol ‘tau’ (τ) and is expressed in our analysis as an exponential decay function: . This function implies that when time (t) = 1 time constant (τ); the function ( ) has decayed by approximately 63% . The function then continues to decay as follows:
Time (No. of time constants) |
Exponential Decay Function (% of starting value) |
1 |
36.8 % |
2 |
13.5 % |
3 |
5.0 % |
4 |
1.8 % |
5 |
0.7 % |
Often once an exponential decay function has passed 5 time constants it is deemed to have settled to the new lower value.
In our laboratory experiment, we shall estimate the time constant of temperature change for our object (τ) by conducting various steps:
1. Measure the temperature of our object as it decays to a final value:
2. Equate this fraction to our exponential decay function:
3. Compare measured temperatures to an best fit decay function to estimate the time constant (τ) of the decay.
Building a Draft LabVIEW VI
Prior to taking measurements, we shall create a custom built LabVIEW VI from scratch, into which we shall later connect the DAQ input. The draft LabVIEW VI will be required to:
- Receive a dummy voltage input – between 0 V and 5 V
- Convert the dummy input voltage to thermistor temperature (TTHERM) in accordance with Eq. (3).
- Present TTHERM (°C) to the user.
At a later stage we will then add the following additional functionality:
- Replace the dummy input with NI USB-6008 DAQ device input voltage.
- Connect the DAQ device to a temperature measurement circuit.
- Program data collection, processing, and storage.
- Add data storage (write to measurement file).
For help in creating, troubleshooting and running the following LabVIEW VI, candidates are referred to the associated learning materials (LabVIEW Introduction and Programming Notes, RLO 1 to RLO 7 (Doug Rattray, LCC, UHI – 2020)).
Start LabVIEW and create a new blank VI.
On the Front Panel place a numeric control slider to act as a dummy voltage input.
- Label the control slider object ‘dummy input (V)’
- Set the range limits to 0 and 5.
Place two indicators (a numeric indicator and a gauge).
- Label the numeric indicator ‘Temp (C)’
Set the gauge range limits to 0 and 25
Save the VI.
Switch to the Block Diagram (CTRL-E).
- From within the Functions Palette, navigate to the Express sub-folder and add a ‘formula’ block to the Block Diagram.
Note: For now, ignore the Configure Dialogue Box if it automatically opens when placing the object. - Use the wiring tool to connect each of the objects as illustrated.
Double-click on the Formula Block and configure the function to compute the conversion stated in eq. (3).
In our setup, the constants of this equation are listed below (constants may vary depending on your component selection):
T0 = 298 K R0 = 10 kΩ Vs = 5 V β = 4038
Note that TTHERM in eq. (3) is stated in Kelvin. The constant ‘273’ should also be subtracted from eq. (3) to convert to degrees Celsius.
Return to the Front Panel and Run the VI Continuously.
Observe that as the ‘dummy input’ slider input is changed manually, the output temperature (gauge and indicator) varies appropriately. To check that the formula block has been input correctly, candidates can spot check the VI function using the validation set shown:
dummy input (V) |
Temp (C) |
1.5 |
44.88 |
2.5 |
25.00 |
4 |
7.46 |
Save the VI once again before moving on to the next section.
Integrating DAQ Measurements to the LabVIEW VI
We shall now use our custom LabVIEW VI to collect data from the external world by integrating DAQ measurements. In this stage we shall:
- Connect the NI USB-6008 DAQ device to our computer.
- Replace the dummy input with NI USB-6008 DAQ device input voltage.
- Configure our DAQ device using the NI-DAQ Assistant.
- Test the DAQ device and LabVIEW VI by forcing some known voltage measurements.
At a later stage we will then add the following additional functionality:
- Connect the DAQ device to a temperature measurement circuit.
- Program the data collection, processing and storage
- Add data storage (write to measurement file).
Connect the NI USB-6008 DAQ device to your workstation PC using the proprietary USB cable. On the NI USB-6008 confirm that the green LED on the device is blinking to confirm connection.
© Doug Rattray, LCC, UHI
In your LabVIEW Vi, switch to the Block Diagram.
- From within the Functions Palette, navigate to the Express / Input sub-folder and add a ‘DAQ Assistant’ block to the Block Diagram.
- A ‘Create New…’ Dialogue Box automatically opens when placing the object. Configure the device to Acquire Signals >> Analogue Input >> Voltage.
Here we are configuring this function block to relay a voltage signal from input ‘ai0’ of our DAQ to the Block Diagram variable space.
Note: On the NI USB-6008 unit, input ‘ai0’ corresponds to pin number 2.
On the next page select the ‘ai0’ as the Supported Physical Channel.
Click ‘Finish’ to complete this first stage of the configuration.
The ‘DAQ Assistant’ Dialogue Box now opens to allow us to configure the Voltage Input Setup of input ai0 on the DAQ device with the following settings.
- Signal Input Range (Max): 5
- Signal Input Range (Min): 0
- Scaled Units: Volts
- Terminal Configuration: RSE (Measurement made with respect to ground)
- Acquisition Mode: N Samples
- Samples to Read: 10
- Rate (Hz): 1k
Once completed the ‘DAQ Assistant’ block will be added to the Block Diagram’.
Replace the ‘dummy input (V)’ block from your Block Diagram with the new ‘DAQ Assistant’ block, wiring the ‘data’ output from the ‘DAQ Assistant’ function into the input of the Formula function block.
Add an additional Numeric Indicator to the Block Diagram, labelled: ‘Input Voltage (V)’, and wire it into the output of the ‘DAQ Assistant’ function block.
In your LabVIEW VI, switch to the Front Panel and re-organise the objects into an uncluttered user interface.
To test that the voltage measurement is operational:
- Connect a wire to the pin 2 (‘ai0’) of the Ni USB-6008 DAQ device.
- Run the LabVIEW VI using ‘Run Continuously’
- Press the other end of the wire to pin 1 (GND (0V)) and confirm the measurement in the LabVIEW VI.
- Remove the wire from pin 1 and now press the end of the wire to pin 31 (5V) and confirm the measurement in the LabVIEW VI.
- Stop the VI by pressing the Abort Execution button.
- Remember to save the VI once again before exiting.
Note: If you have any doubt of the voltage readings, confirm them manually using your digital multimeter.
Build and Test the Measurement Circuit
Before returning to our LabVIEW VI, we shall build and test our measurement circuit.
As a reminder, we shall not be measuring resistance directly with our DAQ device – in this lab we will create the following measurement circuit, measure the voltage across our thermistor and then infer its resistance from this measurement.
Note the resistance across the thermistor varies with the measured voltage in according with eq. (2):
© Doug Rattray, LCC, UHI
Create the measurement circuit on a breadboard (or by soldered wire) and wire the circuit to the NI USB-6008 DAQ using the following pin connections:
- VS – pin 31 (+5V)
- VMEAS – pin 2 (AIO)
- GND – pin 1 (GND)
© Doug Rattray, LCC, UHI
To test that the circuit is working:
- Open your LabVIEW VI and run the program using ‘Run Continuously’. You should expect the initial temperature to be around your normal room temperature.
- Pinch the thermistor between your fingers being careful not to disconnect any part of the measurement circuit. You should expect the temperature gauge to slowly begin to rise in temperature, whilst not exceeding around 30 to 40 °C.
- Stop the VI by pressing the Abort Execution button.
- Remember to save the VI once again before exiting.
© Doug Rattray, LCC, UHI
Program Data Collection, Processing and Storage
In our existing LabVIEW VI, measurement data is sampled (once the VI is initiated by the run command) and presented in a real-time interface. The Vi stops when the user manually clicks the Abort Execution button. In this section, we shall expand our LabVIEW VI as follows:
- On VI termination, data shall be collected and stored in a measurement file on the user’s workstation PC.
- The DAQ sampling rate shall be modified to suit to the dynamic characteristic requirements of the measurement.
In your LabVIEW Vi, switch to the Block Diagram.
- From within the Functions Palette, navigate to the Express / Signal Manipulation sub-folder and add a ‘Collector’ block to the Block Diagram.
- A ‘Configure Collector’ Dialogue Box automatically opens when placing the object. Set the maximum number of samples to 10,000.
- Use the wiring tool to connect the output temperature to the ‘Signals’ input of the new Collector block as illustrated.
The Collector block gathers input signals, stores a fixed number of samples, and returns the latest samples up to that dataset limit, discarding older samples as the program runs.
Next, we want to store our collected data in an external file.
- From within the Functions Palette, navigate to the Express / Output sub-folder and add a ‘Send to Measurement File’ block to the Block Diagram.
- A ‘Configure Write to Measurement File’ Dialogue Box automatically opens when placing the object. Setup the Measurement Function to store the data in an appropriate location and configure the following settings:
- If a file already exists: Overwrite File
- File Format: Text (LVM)
- X Value: One column only
- Delimiter: Comma
- Use the wiring tool to connect the Collector output to the ‘Signals’ input of the Write to Measurement Block as illustrated.
To test that the data storage functionality:
- Confirm that your measurement circuit is connected to the NI USB-6008 DAQ device and that the device is correctly connected to your workstation PC.
- Run your LabVIEW VI using ‘Run Continuously’.
- Pinch the thermistor between your fingers being careful not to disconnect any part of the measurement circuit to cause a slight temperature variation in your measured data.
- Stop the VI after a few seconds by pressing the Abort Execution button.
Save the VI once again before continuing.
© Doug Rattray, LCC, UHI
Now navigate to the file directory specified in the Write to Measurement File Dialogue Box and open the file using the plain text editor, e.g.: Notepad. Your data file should look similar to the image shown:
Note that Header Information has been excluded from this screenshot.
The first column of data presented here is time (seconds) and the second column is the measured temperature (°C).
Reviewing our dataset, it appears that the time interval between samples is 1 ms (i.e.: the sample rate is 1 kHz) and that only 10 samples have been recorded. Our recorded dataset has therefore only stored the first 10 ms of temperature readings.
Note that whilst our collector block is set to gather a dataset of 10,000 samples; the configuration of the DAQ Assistant block is such that only 10 samples are produced covering the first 10 ms of the experiment.
It would be more useful if our LabVIEW program recorded a much longer timespan and at a lower sample rate (discarding unnecessarily granular data). Actually instead of programming a fixed time period, it would be preferable to allow the program to run on a continuous basis until the user terminates it manually.
We can implement these changes by re-configuring the DAQ Assistant block and encapsulating some parts of our block diagram within a LabVIEW While Loop structure.
In your LabVIEW VI, switch to the Block Diagram.
- Double-click on the DAQ Assistant block and change the ‘Samples to Read’ to 10 and the ‘Rate (Hz)’ to 10 also.
Note: This changes the time interval between samples to 0.1 s and sets the minimum number of samples to 10 during a single loop.
- From within the Functions Palette, navigate to the Structures sub-folder and draw a While Loop around the section of the block diagram illustrated.
Add a STOP button to your Front Panel and wire this Boolean control to the Loop Condition of the While Loop.
Rerun the test procedure followed earlier, however, this time execute the VI using the ‘Run’ control instead of the ‘Run Continuously’ control and terminate the VI using the STOP button on the Front Panel instead of the ‘Abort Termination’ control.
Note that if you run your VI for approximately 10 seconds; 100 samples (100 Hz x 10 secs = 100 samples) will be generated.
If the collector block is limited to gather 10,000 samples, this implies that the maximum measurable timespan for our DAQ is 1000 seconds (approx. 16 mins).
Once again, navigate to the file directory specified in the Write to Measurement File Dialogue Box and open the file
Confirm that the time interval between samples has been amended to 1 ms and that the dataset extends through the full test time as expected.
If you are happy that the data is being stored correctly, remember to save the VI once again before exiting.
Importing the Data to Excel
Before importing data to excel for analysis, re-run your LabVIEW VI to collect a new set of measurement data.
- Aim to collect approximately 10 seconds of data and during this measurement induce a notable temperature response in your dataset (e.g.: pinch thermistor gently).
- Open the datafile in a text editor and delete header files, leaving only the two columns of data.
- Save the file before exiting.
- Open MS Excel and open the datafile from within Excel.
- Select File >> Open.
- Navigate to the folder directory.
- Change the file type from ‘All Excel Files’ to ‘All Files’.
- Select your measured datafile and click open.
- Work through the data import wizard – ensuring to select comma delimited where prompted.
- If imported successfully, you should have two columns of data, one for time and the other for temperature measurements.
- Select all of your data and create a plot to illustrate the data.
- From reviewing the data on your graph, identify the data that is capturing the temperature response. In the illustrated dataset, the temp response data is approximately those measurements between approximately 3.5 and 5.5 seconds.
- Right-click your graph and click “Select Data”.
- Add a new Data Series to the graph setting the X and Y values to be only the data between these times.
- Select this new dataset and add an exponential trendline to your graph.
- Finally, right-click your trendline, select format and select to display equation and display R2 value on your graph.
It is with these basic techniques in Excel that we shall analyse our data during the final laboratory experiment.
Note: The R2 value is a measure of good fit whereby a value of 1 represents a perfect fit. It is generally acknowledged that R2 values less than 0.9 indicate an unacceptably poor fit.
Laboratory Experiment
In this experiment we shall use our measurement circuit and LabVIEW VI to measure the temperature change of an object as it transitions from a room temperature air environment to a cold water environment. The thermistor shall be covered in a small amount of blu-tack (or similar material) and in this experiment we shall seek to establish the time constant governing the rate of change of temperature for this solid body.
To analyse measured data, we will import the data to an Excel spreadsheet, process the data and perform a trendline curve fit (using an exponential decay curve) to determine the time constant.
Conduct Experiment
The following steps should be followed to conduct the experiment:
- Prepare the glass of iced water (place several cubes of ice in a glass of water and leave if for approximately 10 mins to settle to its cooled temperature).
- Cover your thermistor with a small amount of blu-tack or similar material (being careful not to short the thermistor leads).
- Verify that the thermistor is initially at approximately room temperature using your LabVIEW VI.
- At the same time plunge the blu-tack covered thermistor into the glass of cold water as you start your LabVIEW VI.
- Record data for approximately 3 to 5 mins to ensure that enough data is calculated – depending on the amount of the blu-tack added you may need to adjust this timespan allowing adequate time for the temperature reading to settle at a new low value.
- Stop the LabVIEW VI (using the STOP button) before removing the thermistor from the glass of iced water.
Processing the Data
Import the datafile into Excel and create a scatter graph of the raw data.
- Identify the time span in the graph representing the region of exponential decay (green box) – in my case: 3.5 to 30.0 seconds
- Also identify the final temperature, aka: TFINAL (red line) – in my case 10.3 °C
Create a new column of data, spanning 3.5 to 30 seconds and calculate (TMEAS-TFINAL) for all data points in this time range.
In a new scatter graph, plot (TMEAS-TFINAL) against time. Add an exponential trendline to the graph illustrating the trendline’s formula on the graph.
Note: Remember to confirm that the trendline is a good fit by reviewing the R2 value.
Reviewing our equations for exponential decay:
and
We can equate this exponential decay equation to our trendline equation (focusing on the exponent) such that:
Therefore, we can say that in this experimental setup the estimated time constant governing the rate of change of temperature for our solid body to be approximately 13.5 seconds. Given this information, we could estimate that the temperature of the solid body would have decayed by approximately 63% after the first 13.5 seconds (1 x τ) and that after 67.5 seconds (5 x τ) the solid body could be deemed to have settled to the new lower final temperature.
Coursework Exercise – Lab Report
Once you have conducted the above experiment, write up your findings in a lab report (maximum – 1500 words). Include a standard Introduction, Methods, Results and Discussion section in your report. Include an appropriate set of graphs and results to illustrate your results.