AN58829 PSoC1 Infrared Thermometer.pdf

AN58829
Infrared Thermometer using PSoC®
Author: Sanjeev Kumar K.
Associated Project: Yes
Associated Part Family: CY8C24x94, CY8C27xxx, CY8C28xxx, CY8C29xxx
Software Version: PSoC ® Designer™ 5.4
Related Application Notes: For a complete list of the application notes, click here.
To get the latest version of this application note, or the associated project file, please visit
http://www.cypress.com/go/AN58829
This application note describes how to build an infrared thermometer using PSoC® 1. This application note also
discusses the theory of Infrared thermometers in brief. This design uses no external active components to buffer,
amplify, and detect the signal source.
Contents
Introduction
Introduction ....................................................................... 1
Infrared Thermometer Principle ......................................... 1
Steps to Calculate Object Temperature ............................ 2
Measure Thermopile Voltage ....................................... 2
Measure Thermistor Resistance (Ra) and Calculate
Ambient Temperature ................................................... 3
Object temperature calculation ..................................... 3
Software ............................................................................ 3
Create Lookup Table .................................................... 5
Read ADC Values ........................................................ 5
Process ADC Values for Temperature ......................... 5
Schematic ......................................................................... 7
Accuracy of Object Temperature ....................................... 8
Field of View Angle ....................................................... 8
Casing and Optics in the Sensor .................................. 8
Distance between Sensor and Object .......................... 8
Calibration .................................................................... 9
Summary ......................................................................... 10
Related Application Notes ............................................... 10
Worldwide Sales and Design Support ............................. 12
Infrared thermometers are widely used in medical and
industrial applications.
www.cypress.com

They measure temperature without any contact with the
object for measurement.


They measure a wide range of temperature.
Their accuracy is comparable with other types of
thermometers.
Infrared Thermometer Principle
Infrared thermometer uses thermopile sensor to measure
temperature. Thermopile sensor has an IR absorber
connected with a series of thermocouples. The cold contacts
of the thermocouples are connected to a known reference.
These thermocouples measure the object temperature. The
ambient temperature of the sensor is measured using a
thermistor.
Document No. 001-58829 Rev. *C
1
Infrared Thermometer using PSoC
Figure 1. Thermopile
®
temperature. The total heat power Prad received from the
object at temperature Tobj is given to
Equation 2
Thermopile generates a voltage Vtp which is proportional to
the incident radiation.
Equation 3
Equation 4
Where S is sensitivity is calibration constant and
emissivity.
is
Usually, sensitivity of the thermocouple is in the range of
microvolts if the ambient temperature is fixed. An empirical
relation between Vtp and Tobj or a look up table gives the
object temperature. From Equation 2 it is evident that Vtp
changes according to changes in ambient temperature. This
ambient temperature needs to be compensated to get the
correct object temperature.
Figure 2. Thermopile Pin Details
Figure 3. Block Diagram
A thermopile sensor has four pins, two of them give the
voltage across the series of thermocouples and the other
two pins are used to measure thermistor resistance. The
thermopile sensor generates a voltage, which is proportional
to the incident infrared (IR) radiation power. You can deduct
the object’s temperature from the thermopile signal because
every object emits IR radiation with a power, which is a strict
function of its temperature.
Steps to Calculate Object Temperature
The total radiation power Pobj emitted by an object of
temperature Tobj can be expressed as Equation 1
1.
Measure thermopile voltage (Vtp)
2.
Measure thermistor resistance (Ra) and calculate
ambient temperature (Ta)
3.
Calculate ambient temperature compensation and
object temperature
Equation 1
with σ being the Stefan-Boltzmann constant and ε the socalled emission factor (or emissivity) of the object. In an
ideal case ε has the values ‘1’ and ‘0’. For most substances,
the emission factor lies in the range 0.85 to 0.95. Equation 1
is called the Stefan-Boltzmann law.
The heat-balance equation relates the net power Prad
received by the thermopile to two temperatures: Tobj and
Tamb. In most cases the instrument’s temperature Tobj equals
(or is near to) the temperature of the ambient Tamb.
Therefore, refer to this value as Ta, the ambient
www.cypress.com
Measure Thermopile Voltage
Usually the output of thermopile is in the order of a few µV,
so take care for offset and SNR.
As an example, a sensor from Perkin Elmer TPS23B is
used. The average sensitivity (Δ VTP/ΔT) of the thermopile is
50 µV/K or 1.845 mV at 309.9K, which is the typical human
body temperature.
Document No. 001-58829 Rev. *C
2
Infrared Thermometer using PSoC
Thermopile voltage can be amplified using correlated double
sampling method (CDS). CDS is followed to reduce offset
and low frequency noise cancellation. For more details on
CDS, refer Application Note AN2226, Correlated Double
Sampling. A brief about this method is reproduced here for
reference. Consider the two ends of a voltage source
(thermopile) connected as the inputs to the programmable
gain amplifier (PGA). This is then connected to the analog to
digital convertor (ADC) that has offsets. The block diagram
of the connections is shown in Figure 4.
Measure Thermistor Resistance (Ra) and
Calculate Ambient Temperature
Thermistor resistance can be measured by ‘PSoC Style’ as
described in detail in the application note, AN2017.
Figure 5. Thermistor Connection Block Diagram
PSoC
Equation 6
Rref
Equation 7
Vtp = Vsource + Vnoise1 − Vnoise2
The noise subtraction in time gives a result of low frequency
noise cancelation response for the system .This response
affects only the noise and not the actual signal, thus
cancelling the low frequency noise. The details about the
math for this waveform are given in AN2226.
IIR Filter
IIR low pass filter is implemented in software to reduce the
high frequency noise. In other words, the implementation
essentially takes a part of the old value and adds it to a part
of the new value. The theory and implementation behind the
IIR filter in software are provided in the Application Note
AN2099, Single-Pole IIR Filters. The voltage measurement
for temperature sensor is well filtered by the CDS and IIR
filter. The value is then used for both thermopile voltage and
ambient temperature compensation.
M
U
X
V1
3
PGA
ADC
Thermistor
4
V2
Vout 2 = Voffset 2 + Vnoise2
Voffset1 and Voffset2 are equal as the offset is constant
over time. So when you subtract Vout2 from Vout1, the
offset is cancelled and the result is:
Vref+
V0
When the MUX selection is input 1, the Vout would be as
shown in Equation 3.
Equation 5 Vout1 = Vsource + Voffset1 + Vnoise1
When the MUX selection is changed to input 2, the Vout
would be changed to Equation 4.
Vref-
A voltage divider is constructed using a reference Rref and
thermistor inside the sensor. V0 and V2 are voltage
references RefHi and RefLo from PSoC. A mux is switched
between V0, V1, and V2. The signal from the mux is fed to a
PGA of gain ‘G’, which is read by an ADC.
Equation 8
 V − V2 

Rthermistor = Rref *  1
 V0 − V1 
Find the thermistor value either in the thermistor lookup
table provided by the sensor manufacturer or using Stein
Harts equation to locate the ambient temperature Ta.
Object temperature calculation
To calculate the object temperature, follow these steps:
1.
Locate the equivalent temperature Ta in the lookup table
provided by the sensor manufacturer.
2.
Locate the equivalent
Equation 5) to Ttp.
3.
The object temperature is calculated by adding Ttp to Ta.
Figure 4. Thermopile Connections Block Diagram
Equation 9
temperature
of
Vtp
(from
Tobj = Ttp + Ta
PSoC
Software
1
1
M
U
X
+
Thermopile
2
External Reference
www.cypress.com
2
AMP
A
D
C
®
The software flow is as follows:



Create lookup table
Read ADC values for thermistor and thermo couple
Process ADC values for temperature
Document No. 001-58829 Rev. *C
3
Infrared Thermometer using PSoC
Figure 6. Software Flow
Start
Read thermistor
resistance(Rth)
Calculate ambient
temperature Ta from Rth
Accumulate Thermopile ADC
values using correlated
double sampling(Vtp)
Perform IIR filtering on the
collected samples
No
If No of
samples ==4
Yes
Find Thermopile temperature
Ttp from thermopile adc value
(Vtp)
Perform ambient temperature
compensation
Tobj=Ta+Ttp
Print Tobj in Celsius and
Farenheit
www.cypress.com
Document No. 001-58829 Rev. *C
4
®
Infrared Thermometer using PSoC
Create Lookup Table
The lookup table for a thermistor is created using the table
from Perkin-Elmer data sheet, which describes the
thermistor’s voltage against temperature characteristics.
Table 1. Thermistor Data
Temperature
Rnom
Temperature
Rnom
°C
Ω
°C
Ω
-20
915479
45
44175
-15
694575
50
36497
-10
531349
55
30303
-5
409715
60
25280
0
318336
65
21187
5
249149
70
17836
10
196369
75
15079
15
155815
80
12800
20
124439
85
10910
25
100000
90
9334
30
80843
95
8016
35
65732
100
6908
40
53743
Table 1 has temperature mapped against resistance
value. Consider Rnom (Rth) as the nominal resistance.
Thermistor can be calculated from Equation 8.
Table 2. Thermocouple Data
Temperature
Typ
Temperature
Typ
°C
mV
°C
mV
-20
-1.55
40
0.71
-10
-1.29
50
1.25
0
-0.98
60
1.84
10
-0.61
70
2.48
20
-0.21
80
3.16
25
0
90
3.9
30
0.23
100
4.7
Table 2 represents the variation in thermopile voltage with
temperature difference between the hot and cold ends of
the thermopile. The reference temperature is taken as 25
degrees Celsius; by subtracting 25 from the left column,
you get the correlation between the temperature difference
and the milli volt output.
index in an array. Therefore, it is beneficial to linearly
interpolate between the temperature values so that the
entire array is in steps of 5 degrees.
The thermopile voltage is amplified and then fed to the
ADC. Therefore, you can construct a table that maps ADC
voltages directly to a temperature difference.
Read ADC Values
This function captures and accumulates 32 thermopile and
thermistor values into variables tp_avg and tr_avg
respectively. It then calculates the average of those values
and stores the average in variables called tp and tr.
Correlated doubling and IIR filtering is performed in this
part of code.
Process ADC Values for Temperature
The temperature is calculated from the thermistor
resistance Rth and thermopile voltage Vtp values using the
following algorithm:

Check for overflow and underflow; if condition exists,
exit with an error.

Find the closest value in the appropriate table for the
ADC value.

Perform linear interpolation between the closest two
values.

For the thermopile, the interpolation formula is as
follows:


Vtp − U tp Cal[i ]

Ttp = −45 + 5i + 5 * 
 U Cal[i + 1] − U Cal[i ] 
tp
 tp


For the thermistor, the interpolation formula is
follows:


Rth − U th Cal[i ]

Ta = −20 + 5i + 5 * 
U
Cal
[
i
+
1
]
−
U
Cal
[
i
]
th
th


Where
Uth and Utp are lookup table entries for thermistor and
thermocouple respectively.
i is the index of lookup table, or temperature
Ambient temperature can also be calculated from Stein
Hart’s equation:
TC =
1
− 273.15
A + B ⋅ ln( R) + C ⋅ ln( R )3
Because the temperature scale moves in steps of 5 near
25 degrees and steps of 10 farther away, it is difficult to
www.cypress.com
®
Document No. 001-58829 Rev. *C
5
Infrared Thermometer using PSoC
Where:
A, B, and C are empirical constants that are determined
from thermistor characteristics
R is the thermistor’s resistance in ohms.
manufacturer or from a bigger lookup table, which has
much closer values of temperature.
Ambient temperature compensation is performed using
Equation 10
Equation 10
TC is the temperature in Celsius.
Tobj = Ttp + Ta
To increase accuracy, temperature is calculated from ADC
values using the polynomial provided by the sensor
Figure 7. PSoC Internal Routing Diagram
www.cypress.com
®
Document No. 001-58829 Rev. *C
6
Infrared Thermometer using PSoC
Schematic
Figure 8 shows the schematic of infrared and Table 3 provides details of each net.
Figure 8. Schematic
www.cypress.com
Document No. 001-58829 Rev. *C
7
®
Infrared Thermometer using PSoC
Table 3. Net Details
®
Figure 10. Casing
Net Name
Details
TH+ and TH-
Thermistor output of thermopile sensor
TC+ and TC-
Thermocouple output of thermopile
sensor
AGND
Analog ground
LCD_xx
LCD data and control lines
Vref- and Vref+
Reference voltages from PSoC
Accuracy of Object Temperature
The accuracy of object temperature depends on the
following parameters. These parameters help to increase
accuracy from 98 to 99 percent:

Field of view angle (FOV) of IR radiation from object to
sensor



Type of casing and optics used in sensor
Distance between sensor and object
Distance between Sensor and Object
Calibration of the device
Field of View Angle
FOV angle is the angular measure of the cone opening from
which the sensor receives radiation as Figure 9 shows.
Figure 9. FOV Angle
Tobj
The distance between the sensor and object produces a
variation in readings. Therefore, the typical distance
provided by the sensor manufacturer should be maintained.
For sensor TPS23B, the distance is 2 to 3 cm. Proximity
sense in PSoC can be used to maintain correct distance
between sensor and object (human body) thereby reducing
the error due to incorrect positioning.
Ta
FOV
+
VTP
-
Vtp varies with sin2 (FOV) and accuracy can be increased by
keeping FOV nearer to 90 degrees.
Casing and Optics in the Sensor
The type of casing used around the sensor affects its
accuracy. Therefore, take special care when enclosing the
sensor. More details of the case designing can be got from
the sensor manufacturer. Figure 10 shows the casing built
for Perkin Elmer TPS23B sensor. Sensor manufacturers can
be contacted for more details about the design of casing.
www.cypress.com
Document No. 001-58829 Rev. *C
8
Infrared Thermometer using PSoC
®
VTobj (theor ) := VTobj ( Radiation _ source) − VTobj ( Sensor )
Calibration
Follow these steps for calibration:
1.
2.
Measure the offset of your device: The thermopile
sensor is exposed to a complete thermal equilibrium in
a closed environment. In front of the window, the same
temperature is presented as the equilibrium
temperature. Now the sensor gives 0 V, which is used
to calibrate the offset of the electronics. Alternatively, a
precise voltmeter is used for the thermopile output to
measure how good the thermal equilibrium is.
The voltage V_TObj (exp) is used to scale the sensors
output in future and get a calibration constant k. From
the table or from the polynomial, you get a voltage of a
typical sensor V_T_Obj (theor) by calculating:
Calibration constant k is calculated as
K=
3.
VTobj (theor )
VTobj ( Sensor )
During measurements, all thermopile voltages must first
be multiplied with k before further processing with
polynomials of lookup-tables.
The look up table in the attached project is calibrated
for the hardware setup including casing sensor etc.
Figure 11. IR Thermometer
www.cypress.com
Document No. 001-58829 Rev. *C
9
Infrared Thermometer using PSoC
About the Author
Summary
This application note explains how to build an infrared
thermometer with zero external active analog components.
The project attached with this application note does not
include any calibration routine.
Name:
Sanjeev Kumar. K
Title:
Applications Engineer
Background:
Sanjeev has a bachelor’s degree in
Electronics and Communication from
the College of Engineering, Guindy,
Chennai. He currently works on PSoC
based applications at Cypress.
Contact:
kuk@cypress.com
Related Application Notes
AN2017 –- PSoC® 1 Temperature Measurement with
Thermistor
AN2226–- PSoC® 1 –- Using Correlated Double Sampling
to Reduce Offset, Drift, and Low Frequency Noise
AN2099–- PSoC® 1, PSoC 3, and PSoC 5LP–- SinglePole Infinite Impulse Response (IIR) Filters
www.cypress.com
Document No. 001-58829 Rev. *C
10
®
Infrared Thermometer using PSoC
Document History
Document Title: Infrared Thermometer using PSoC® - AN58829
Document Number: 001-58829
Revision
ECN
Orig. of
Change
Submission
Date
Description of Change
**
2855922
KUK
1/18/10
New application note
*A
3126363
KUK
01/03/2011
Software version changed from PSoC designer 5.0 to 5.1
®
®
Device name in abstract updated from PSoC to PSoC 1
AN Changed from CapSense category to PSoC1 category
Updated details on casing
Updated project to PSoC designer 5.1
*B
3941788
KUK
03/22/2013
Software Version as “PSoC Designer™ 5.3”.
Updated Abstract.
Updated Infrared Thermometer Principle (Updated Figure 2 and Figure 3).
Removed the Note “Medical demo daughter card is build for internal cypress
demo and the same is not sold in cypress web.” below Figure 11.
Updated Summary.
Updated to new template.
Updated project to PSoC designer 5.3.
Updated code to match latest CY coding standards.
*C
4729551
ASRI
04/17/2015
Updated Software Version “PSoC Designer™ 5.4” in page 1.
Updated attached associated project with PSoC designer 5.4.
Updated to new template.
Completing Sunset Review.
www.cypress.com
®
Document No. 001-58829 Rev. *C
®
11
®
Infrared Thermometer using PSoC
®
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
Products
Automotive
cypress.com/go/automotive
psoc.cypress.com/solutions
Clocks & Buffers
cypress.com/go/clocks
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Interface
cypress.com/go/interface
Lighting & Power Control
cypress.com/go/powerpsoc
cypress.com/go/plc
Memory
cypress.com/go/memory
PSoC
cypress.com/go/psoc
Touch Sensing
cypress.com/go/touch
USB Controllers
cypress.com/go/usb
Wireless/RF
cypress.com/go/wireless
Cypress Developer Community
Community | Forums | Blogs | Video | Training
Technical Support
cypress.com/go/support
PSoC is a registered trademark of Cypress Semiconductor Corp. “Programmable System-on-Chip” and PSoC Designer are trademarks of Cypress
Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2010-2015. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
www.cypress.com
Document No. 001-58829 Rev. *C
12