Sie sind auf Seite 1von 5

6/1/2016

Measuringtemperaturetheeasyway

Measuringtemperaturetheeasyway
IhavebeenaskedformoredetailsonmytemperaturemeasurementschemesoIhaveconsolidated
someofmypreviousarticles:
Theobjectiveistomeasuretemperaturefromroomtemperaturetoabout250Cusingathermistor.
Thethermistorresistanceisaextremelynonlinear.Itisapproximatedbyanegativeexponentialof
thereciprocalofabsolutetemperature.

RoisresistanceatknowntemperatureTo,inthiscase25C,expressedinKelvin.Betaisasecond
parameterofthethermistorwhichcanbecalculatedifyouknowtheresistanceattwodifferent
temperaturesorcanbefoundonthedatasheet.
TheRepRapthermistorisanEpcosB57540G0103+,datasheethere.R25is10Kandbetais
around3500.Severalvaluesaregivenonthedatasheetfordifferenttemperaturerangesillustrating
thattheaboveequationisonlyanapproximation.Hereisagraphofitsresistanceagainst
temperature:

Thiscanbemademorelinearbyputtingafixedresistorsinparallel.Themagicvaluetouseappears
tobethevalueofthethermistoratthemiddleofthetemperaturerange.Inthiscaseitisabout470.
Hereistheresultingcombinedresistance,theformulafortworesistorsinparallelis:

http://hydraraptor.blogspot.hk/2007/10/measuringtemperatureeasyway.html

1/5

6/1/2016

Measuringtemperaturetheeasyway

1/R=1/R1+1/R2
I.e.thetotalconductanceisthesumofthetwoconductances.

Theresultingresistanceisalotmorelinear,howevertomeasuretemperaturewithanADCweneed
avoltageratherthanaresistance.Thisiseasy,insteadofwiringtheresistorinparallelconnectitin
seriestoavoltagesourceequaltothefullscalevoltageoftheADC.

Thevoltageacrossthethermistoristhen:

http://hydraraptor.blogspot.hk/2007/10/measuringtemperatureeasyway.html

2/5

6/1/2016

Measuringtemperaturetheeasyway

V=Vref.Rth/(R+Rth)
HereisagraphofthetheoutputvoltagewhenVrefis5V.

Notethatthevoltagedecreasesasthetemperaturerises.Thiscouldbeinvertedbyswappingthe
resistorandthermistorbutIprefertokeeponeendofthethermistorat0VsoIcanusesingle
screenedcable.ItisalsoagoodideatoputacapacitoracrosstheADCinputtofilteroutanynoise
whenusinglongleadslikeRepRapdoes.Iuseda10uFtantalumbead.
Anotherconsiderationishowmuchpowerisdissipatedinthethermistorasitwillcauseheatingand
alterthereading.Themaximumdissipationwilloccurwhenitsvalueequalsthevalueoftheresistor.
Atthispointhalfthevoltageisacrossthethermistorsothepowerdissipatedinitis:
P=(Vref/2)2/R
Intheexampleabovethisworksoutat13.3mW.Thethermistordatasheetspecifiesamaximumof
18mWandadissipationfactor(inair)of0.4mW/K.Ithinkthismeansthatthetemperaturewillrise
by33Cbyselfheating.Theerrorwouldbelesswhennotinair,butitisstillperhapsabithigh.My
systemusesaVrefof1.5voltswhich,becauseitisasquarelaw,onlydissipates1.2mWgivinga3C
riseatthemidrangetemperatureinair.
Fora5VsystemisisprobablyworthsacrificingsomeoftheADCresolutiontoreducetheselfheating
error.Thiscanbedonebyusingtworesistors:

http://hydraraptor.blogspot.hk/2007/10/measuringtemperatureeasyway.html

3/5

6/1/2016

Measuringtemperaturetheeasyway

Thefullscalevoltageisnow:
Vfsd=Vref*R1/(R1+R2)
Wealsowantthesourceimpedanceofthisvoltage,whichisR1inparallelwithR2,tobe470.
1/R=1/R1+1/R2
Solvingthesesimultaneousequationsgives:
R1=R/(1Vfsd/Vref)
R2=R.R1/(R1R)
SoforVfsd=1.5V,Vref=5VandR=470:
R1=671andR2=1569,preferredvaluesare680and1K6.
AndfinallyhereisthePythoncodetoworkoutthetemperature:
frommathimport*
classThermistor:
"Classtodothethermistormaths"
def__init__(self,r0,t0,beta,r1,r2):
self.r0=r0#statedresistance,e.g.10K
self.t0=t0+273.15#temperatureatstatedresistance,
e.g.25C
http://hydraraptor.blogspot.hk/2007/10/measuringtemperatureeasyway.html

4/5

6/1/2016

Measuringtemperaturetheeasyway

self.beta=beta#statedbeta,e.g.3500
self.vadc=5.0#ADCreference
self.vcc=5.0#supplyvoltagetopotentialdivider
self.vs=r1*self.vcc/(r1+r2)#effectivebiasvoltage
self.rs=r1*r2/(r1+r2)#effectivebiasimpedance
self.k=r0*exp(beta/self.t0)#constantpartofcalculation
deftemp(self,adc):
"ConvertADCreadingintoatemperatureinCelcius"
v=adc*self.vadc/1024#convertthe10bitADCvaluetoa
voltage
r=self.rs*v/(self.vsv)#resistanceofthermistor
return(self.beta/log(r/self.k))273.15#temperature
defsetting(self,t):
"ConvertatemperatureintoaADCvalue"
r=self.r0*exp(self.beta*(1/(t+273.15)1/self.t0))#
resistanceofthethermistor
v=self.vs*r/(self.rs+r)#thevoltageatthepotentialdivider
returnround(v/self.vadc*1024)#theADCreading

http://hydraraptor.blogspot.hk/2007/10/measuringtemperatureeasyway.html

5/5

Das könnte Ihnen auch gefallen