academic workshop lab measuring temperature with thermistors

35
Academic Workshop Lab Measuring Temperature with Thermistors

Upload: anabel-jefferson

Post on 17-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Academic Workshop Lab Measuring Temperature with Thermistors

Academic Workshop Lab

Measuring Temperature with Thermistors

Page 2: Academic Workshop Lab Measuring Temperature with Thermistors

2 Cypress Confidential

Objective

• Exploit PSoC topology to build inexpensive digital thermometer.

• Understand the operation of a negative temperature coefficient (NTC) thermistor.

• Understand how to calculate Steinhart Hart constants for a specific thermistor.

• Calculate temperature using the Steinhart & Hart equation.

• Calculate temperature using a look up table.

Page 3: Academic Workshop Lab Measuring Temperature with Thermistors

3 Cypress Confidential

Hardware Overview

• CY8C3210-PSoCEval1 board.• MiniProg• Thermistor • 10k resistor• Breadboard wire

Page 4: Academic Workshop Lab Measuring Temperature with Thermistors

4 Cypress Confidential

Reference Material

• AN2028 Ohmmeter• AN2017 Thermistor Based Thermometer• AN2239 ADC Selection

Page 5: Academic Workshop Lab Measuring Temperature with Thermistors

5 Cypress Confidential

Measuring Resistance

• Unlike measuring voltage or current, measuring a a passive characteristic like resistance requires stimulus

• A Classic method is to push current into a resistor and measure the developed voltage.

• Only as accurate as• Current Source• ADC Gain and Offsets

• Resistance limited to ADC range.• Requires different current values for wide range

of resistors.

• Very popular when cost of accurate current sources was less than the cost of computation.

Rtest

Vresponse

Istim

ADC

stim

responsetest I

VR

Page 6: Academic Workshop Lab Measuring Temperature with Thermistors

6 Cypress Confidential

PSoC and Measuring Resistance• For this circuit the following equation

holds.

• Solving for Rtest results in:

• Offset errors removed by difference• Measurement offset voltages subtract out!

• Gain errors removed by quotient• Measurement path errors divide out!

• Accuracy determined by an external reference resistor …

testref R

VV

R

VV 2110

10

21

VV

VVRR reftest

Page 7: Academic Workshop Lab Measuring Temperature with Thermistors

7 Cypress Confidential

PSoC and Measuring Resistance • And ADC resolution

• For an n bit ADC the number of counts seen across aR is:

• The reading is accurate to +/- .5 counts.

• Overall resolution tolerance is:

• For 14 bits and an attenuation of 15/16, the equation simplifies to:

21

12

a

aAttenn

a

a

Attentol

n

221 1

2

a

atol

21

720,30

1

Tol (%) a

0.332% 0.01

0.0399% 0.1

0.013% 1

0.0399% 10

0.332% 100

Page 8: Academic Workshop Lab Measuring Temperature with Thermistors

8 Cypress Confidential

Thermistors

• A negative temperature coefficient thermistor (NTC) is a semiconductor device that becomes less resistive as its temperature increases. The change in resistance is “roughly” expressed by the equation below.

Where: • A is some empirical value less than one for negative

temperature coefficient (NTC) thermistors.• T1 & T2 are temperatures measured in Kelvin.

• R(T1) & R(T2) are the thermistor’s resistances at these

temperatures.

)(

2

1 21

)(

)( TTATR

TR

Page 9: Academic Workshop Lab Measuring Temperature with Thermistors

9 Cypress Confidential

NTC Thermistors

• ”Roughly” is defined as a good approximation for an academic introduction to thermistors.

• It shows the temperature/resistance relationship to be ideally exponential.

• It won’t hold up for real world temperature-measuring application.

• But for small temperature differences the following holds:

)(

2

1 21

)(

)( TTATR

TR

2121

2TRTR

TTR

Page 10: Academic Workshop Lab Measuring Temperature with Thermistors

10 Cypress Confidential

Steinhart-Hart Equation

• The Steinhart-Hart equation describes the resistance change of a thermistor as related to its temperature. The equation below shows it to be a 3rd order logarithmic polynomial using three constants.

Where: • A, B, and C are empirical constants.• TK & is temperature in Kelvin.

• R is the thermistor’s resistance in Ohms .

3)ln()ln(1

RCRBATK

Page 11: Academic Workshop Lab Measuring Temperature with Thermistors

11 Cypress Confidential

Steinhart-Hart Equation

• Many thermistors come with these three parameters defined.

• For this particular thermistor they are in the datasheet• If not they must be calculated.

• This is done by taking three points in the conversion table and solving for these constants.

• It makes most sense to use the minimum, maximum, and a middle value for the temperature range for which you are interested. From the Thermistor Table

Tc Resistance

0°C 32,660 ohms

40 °C 5,325 ohms

80 °C 1,257 ohms Note: This is an example and not for the thermistor we are using

Page 12: Academic Workshop Lab Measuring Temperature with Thermistors

12 Cypress Confidential

Steinhart-Hart Equation• Apply the three data points to the following equation.

To get the three following equations.

• Solve to get:A = 0.11261637e-2B = 0.23461776e-3C = 0.85700804e-7

3)ln()ln(15.273

1RCRBA

TC

.366099e-2 A 10.3939 B 1122.89 C

.319336e-2 A 8.58017 B 631.666 C

.283166e-2 A 7.13648 B 363.456 C

Page 13: Academic Workshop Lab Measuring Temperature with Thermistors

13 Cypress Confidential

Thermistors

• The cost of thermistors is primarily determined by the accuracy of the thermistor’s resistance. This is where the exponential nature of thermistors works out to your advantage.

• A thermistor’s resistance tolerance shows up as a temperature shift. This can be calibrated out with a single point calibration.• In test, bring the thermistor to 25˚C and measure its

temperature.• Suppose it reads 26.2˚C• Software needs to store a 1.2˚offset in memory.

Page 14: Academic Workshop Lab Measuring Temperature with Thermistors

14 Cypress Confidential

Thermistors

• In consumer products this calibration is many times left to the user.• The user interface allows access to the temperature offset

register.• The user sets this if they think the temperature is a bit low or a

bit high.

• A good rule of thumb is that a thermistor resistance uncertainty of n% works out to a temperature shift of approximately (n/3)˚C. This will help determine if any calibration is needed. Temperature calculations are only as accurate as the resistance measurement of the thermistor

Page 15: Academic Workshop Lab Measuring Temperature with Thermistors

15 Cypress Confidential

Let’s Get Started

Desired Topology• Connect 10k Ohm from P05 to

P01.• Connect 10k Ohm thermistor

from P01 to P03.• Start Designer

• Name the Project Therm.Therm

V0_OutREFHI

PSoC

10k

ADC

REFLO

P05

P01

P03V2_Out

V1_In

buf1

buf0

InputAtten

R

15R

Buffer

Page 16: Academic Workshop Lab Measuring Temperature with Thermistors

16 Cypress Confidential

EVAL1 Connections

10K

Therm

P05

P03

P01

Wire

Page 17: Academic Workshop Lab Measuring Temperature with Thermistors

17 Cypress Confidential

Starting a New Project

• Open PSoC Designer

• Select Start new project

Page 18: Academic Workshop Lab Measuring Temperature with Thermistors

18 Cypress Confidential

Starting a New Project

• Select Project Type

• Name The Project

Page 19: Academic Workshop Lab Measuring Temperature with Thermistors

19 Cypress Confidential

Starting a New Project

• Select Device and Coding Method • CY8C29466-24PXI• C

• OK

Page 20: Academic Workshop Lab Measuring Temperature with Thermistors

20 Cypress Confidential

Global Resource Settings

Page 21: Academic Workshop Lab Measuring Temperature with Thermistors

21 Cypress Confidential

Select PGA UM

• Select PGA and name it InputAtten• Insert into ACB00• Set the PGA parameters to:

• Atten Value set to 15/16• Reference to AGND• Input connected to column

MUX to read all three points on the resistor string

Page 22: Academic Workshop Lab Measuring Temperature with Thermistors

22 Cypress Confidential

Select Second PGA UM

• Select PGA and name it Buffer• Insert into ACB01• Set the PGA parameters to:

• This UM generate API in multiplex the input lines.

Page 23: Academic Workshop Lab Measuring Temperature with Thermistors

23 Cypress Confidential

Select AMUX4 UM

• Select an AMUX4 and rename it ADCMUX

• Set its parameter has shown.

Page 24: Academic Workshop Lab Measuring Temperature with Thermistors

24 Cypress Confidential

Select ADCINC UM• Select an ADCINC UM and rename it ADC.• Select a single modulator and place it in ASC10.• Select the clock to be VC2.• Place the digital block in DBB0.

• Input connects to Buffer.• PWM is not used

Page 25: Academic Workshop Lab Measuring Temperature with Thermistors

25 Cypress Confidential

Select LCD UM

• Select and LCD UM and name it LCD.

• Connect to Port 2• BarGraph is not needed.

Page 26: Academic Workshop Lab Measuring Temperature with Thermistors

26 Cypress Confidential

Rename Buffers and Pins

• Connect the AnalogOutBuf_1 to P05.• Rename this pin V0_Out.

• Connect the AnalogOutBuf_0 to P03.• Rename V2_Out.

• Change PO1 to be an AnalogInput.• Rename it V1_In.

Page 27: Academic Workshop Lab Measuring Temperature with Thermistors

27 Cypress Confidential

Add Initialization Code •In the Initialization Section

• Add code to start Buffer, InputAtten, ADC, and LCD.

• Add code to connect REFHI to the column1 analog bus.

• Add code to connect REFLO to the column0 analog bus.

• Declare iV0, iV1, iV2, iRvalue to be global variables.

• Enable global interrupt.• Declare bTempValue to

be a global 8 bit variable.• Add LookUp table.

(Cut and Paste from File on CD)

Page 28: Academic Workshop Lab Measuring Temperature with Thermistors

28 Cypress Confidential

LookUp Table Temperature Conversion

• The Steinhart-Hart equation requires using the floating point math library. Floating point is slow and uses buckets more ROM compared to integer math.

• An alternative is to use a look up table. For any particular thermistor, the manufacturer either supplies a R/T conversion table, or supplies the three Steinhart-Hart coefficients. If only the coefficients are supplied, a table can be generated from them. This particular thermistor has a R/T conversion table that supplied.

Page 29: Academic Workshop Lab Measuring Temperature with Thermistors

29 Cypress Confidential

Create a Look Up Table

• Excel file ThermTable.xls contains the 81resistance values for temperature for 0°C to 80 °C.

• Calculate half values for ½°C to 79 ½°C using the following equation.

• ½ degrees are used for rounding.

• Add the value zero at the end.

121 nRnRnR

Page 30: Academic Workshop Lab Measuring Temperature with Thermistors

30 Cypress Confidential

Create a Look Up Table*

• These values are used to make an ROM array WThermTable[ ] containing 81 values.

121 nRnRnR

*code is provided in lab file

Page 31: Academic Workshop Lab Measuring Temperature with Thermistors

31 Cypress Confidential

Add Code Control Loop•In the Control Loop

• Set ADCMUX to P05.• Run ADC.• Wait for data.• Place in iV0• Set ADCMUX to P01.• Run ADC.• Wait for data• Place in iV1.• Set ADCMUX to P03.• Run ADC.• Wait for data• Place in iV2.• Calculate Resistance.• Display on LCD.

Page 32: Academic Workshop Lab Measuring Temperature with Thermistors

32 Cypress Confidential

Add Code CalculateR

• If iV0<-iV1 (Open Circuit)• lRvalue = -1

• Else If iV1 <= iV2 (Short Circuit)• iRvalue = 0

• Else• Calculate Resistance• Add half denominator to

numerator to implementround off.

5.intint 21

B

A

B

BA

Page 33: Academic Workshop Lab Measuring Temperature with Thermistors

33 Cypress Confidential

Run

• Build the Project.• Record RAM and ROM Usage.

• Download to the Eval board and run.• Using the look up table determine the

temperature.

Page 34: Academic Workshop Lab Measuring Temperature with Thermistors

34 Cypress Confidential

Summary

• PSoC makes measure resistance a cost effective option.

• Temperature can easily be measure using thermistor with the Steinhart-Hart equation or look up table.

Page 35: Academic Workshop Lab Measuring Temperature with Thermistors

35 Cypress Confidential

Questions