Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Digital Thermometer

Status
Not open for further replies.

quanta

New Member
Dear forumers

Now i can't find the 10k thermistor so i do have the 150k NTC thermistor

now i want to couple this 150k thermistor with 0.1uF capacitor and look into the Myke Predko code and modify it and it cant work and showing too hot

below is the fraction of code and i do not know which to change to get the actual recharging time for that
Loop ; Read Temperature and Loop Back Here

bsf PORTB, 7 ; Charge the Capacitor
bcf INTCON, GIE ; Turn Off Interrupts During Sensor Read
bsf STATUS, RP0 ; Charge the Capacitor
bcf TRISB & 0x07F, 7
movlw 0x032
movwf Value
decfsz Value, f
goto $ - 1

bsf TRISB & 0x07F, 7 ; Allow the Cap to Discharge
bcf STATUS, RP0

clrf Value ; Now, Read the Value
TLoop ; Wait for the Cap to Discharge through
btfss PORTB, 7 ; Variable Resistor
goto HaveValue ; Jump Out if the Value == 0
incfsz Value, f ; Increment the Time
goto TLoop ; Check again if No TimeOut

TooCold ; Value is Too Cold

movlw 13 ; TimeOut, Value is too Low (cold)
movwf Seg0 ; to Display
movwf Seg1
movwf Seg2

goto Display

HaveValue ; We have the Value - Calibrate it

movf Cal, w ; Now, Use Calibration Value for Multiplier
movwf Mul
movf Calhi, w
movwf Mulhi

clrf Prod ; 16 Bit Multiply with Result in "Prodhi"
clrf Prodhi

movlw 8 ; But, Multiplicand is only 8 bits
movwf Count

MulLoop ; Loop Around Here for Each Bit

rrf Value, f ; Do we add Value to the Product?
btfss STATUS, C
goto MulSkip ; Nope, Wait for the Next Bit

movf Mulhi, w ; Do 16 Bit Add to the Product
addwf Prodhi, f
btfsc STATUS, C ; If Carry Set, then Show TooCold Error
goto TooCold
movf Mul, w
addwf Prod, f
btfss STATUS, C ; Have to Carry to High Byte?
goto MulSkip
movlw 1 ; Yes, Are we too Cold?
addwf Prodhi, f
btfsc STATUS, C
goto TooCold

MulSkip ; Now, Just Rotate Everything Over for
bcf STATUS, C ; The Next Bit
rlf Mul, f
rlf Mulhi, f

decfsz Count, f ; Have we looped 8 times?
goto MulLoop

movlw 25 ; Value Must be >= 25
subwf Prodhi, f
btfsc STATUS, C ; "C" is the "Positive Flag"
goto GetReal ; Positive Flag is Set, Value is Okay

TooHot ; Too Hot, Outside the Range

movlw 15 ; Temperature is too high - Error
movwf Seg0
movwf Seg1
movwf Seg2

goto Display

attached is the whole ASM code
 

Attachments

  • thermo.zip
    5.6 KB · Views: 159
quanta said:
Now i can't find the 10k thermistor so i do have the 150k NTC thermistor

now i want to couple this 150k thermistor with 0.1uF capacitor and look into the Myke Predko code and modify it and it cant work and showing too hot

I don't know anything about the code, but a 150k is WAY too big for a PIC's input impedance unless you add a buffer. 2.5k is the largest impedance to get full PIC accuracy. You'd need a low offset opamp, several degrees of inaccuracy can happen with a high offset op amp.

In fact, 10k is too large, but the possible error is only a few degrees in a thermistor. A 4.7k thermistor in series with a 4.7k pullup resistor gives you an acceptable 2.35k impedance. However, one must take into account the self heating involved, there is 1.3 mW of heat generated within the thermistor. If it is in still, free air, not connected to a pipe or anything, this can raise the temp of a thermistor with low surface area by a noticible amount.
 
Oznog said:
I don't know anything about the code, but a 150k is WAY too big for a PIC's input impedance unless you add a buffer. 2.5k is the largest impedance to get full PIC accuracy. You'd need a low offset opamp, several degrees of inaccuracy can happen with a high offset op amp.

You've not looked at the code!, it's not using an internal A2D, but a simple capacitor charging technique.

If the resistance is too large you simply need to reduce the size of the capacitor accordingly, to keep the charging time the same. 150K is no problem for the high impedance PIC inputs.

As for the accuracy of the internal A2D's, it's not so much an accuracy problem as a timing problem, you need to allow time for the internal sample and hold capacitor to charge - with a higher impedance source you need to reduce the time between samples in order to allow it to charge fully. If you don't allow enough time, then you will get substantial (and I mean substantial!) errors.
 
[quote="Nigel GoodwinIf the resistance is too large you simply need to reduce the size of the capacitor accordingly, to keep the charging time the same. 150K is no problem for the high impedance PIC inputs.

[/quote]

MR Nigel,

What is the suitable size of the capacitor???
Thnx
 
quanta said:
[quote="Nigel GoodwinIf the resistance is too large you simply need to reduce the size of the capacitor accordingly, to keep the charging time the same. 150K is no problem for the high impedance PIC inputs.

MR Nigel,

What is the suitable size of the capacitor???
Thnx[/quote]

You've made the resistor 15 times as large, so make the capacitor 15 times smaller :lol:
 
quanta said:
;) thnx

is there a way to modify the code??

Yes, you would have to add a suitable time delay to the section which reads the thermistor value - far easier to use a different value of capacitor, and it will keep the reading speed as designed. Adding a delay would make the reading speed many times slower.
 
Nigel Goodwin said:
As for the accuracy of the internal A2D's, it's not so much an accuracy problem as a timing problem, you need to allow time for the internal sample and hold capacitor to charge - with a higher impedance source you need to reduce the time between samples in order to allow it to charge fully. If you don't allow enough time, then you will get substantial (and I mean substantial!) errors.

Inadequate charging time is only one source of error.
The PIC's ADC stage has an unpredictable leakage of +/- 100 nA and this directly causes offset errors at the pin itself. If we were to have a 75k input impedance (150k thermistor || 150k pullup), there is a max offset error of +/- 7.5mV and all the charging time in the world does nothing to fix it. With a 5v Vref, that's +/- 1.5 lsb of additional offset error in addition to most of the +/- 1 lsb in the spec for sources up to 2.5k. Fortunately, this does not affect the scale, relative readings on the same pin are unaffected as long as charging time is adequate.
 
Nigel Goodwin said:
quanta said:
;) thnx

is there a way to modify the code??

Yes, you would have to add a suitable time delay to the section which reads the thermistor value - far easier to use a different value of capacitor, and it will keep the reading speed as designed. Adding a delay would make the reading speed many times slower.


hmm how long should i put ???
 
quanta said:
Nigel Goodwin said:
quanta said:
;) thnx

is there a way to modify the code??

Yes, you would have to add a suitable time delay to the section which reads the thermistor value - far easier to use a different value of capacitor, and it will keep the reading speed as designed. Adding a delay would make the reading speed many times slower.


hmm how long should i put ???

Long enough to give the same sort of readings as the original design :lol:

It's not as simple to work out, as the capacitor charges in an exponential fashion - if (for some bizarre reason?) you don't want to simply change the capacitor for one the correct value, I would suggest you try different delays until you get it right. Replacing the thermistor with a variable resistor will help you get the correct range while testing.
 
Status
Not open for further replies.

Latest threads

Back
Top