Hi,
(Before you say it - I don't need accuracy. +/-5 deg. C would be ok.)
I wanted to ask for the equations deriving the calibration equations for internal temperature sensor (few PN junctions in series with CC drive), but I think I got them. I'll still post this for
sanity check and
optimisation suggestions (I know there are a lot of optimisation gurus here!)
I tried consulting
AN1333, but
microchip overcomplicate things. I don't really care about diodes voltage. All I care is the relation between ADRES and temperature. So that could be done with one simple equation:
(1)
Temp = A + ADRES*BAnd because I want to avoid floating point and division I want to do it like this (B=B1/B2):
Temp = A + ADRES*(B1/B2), where B2 is exact power of two (2^8 or 2^16 would be even better - no shifting required). In other words if A is 473 and B is -3.61,then B1 would be -3.61*65536 = -236585 and B2 would be 65536. So the equation would be:
Temp = 473 - 236585*(ADRES << 16) (of course I'll use union to set the high bytes of a unsigned long to ADRES instead of shifting 16 times)
So I need to calibrate A and B1 from two temperature points.
Let's say I measured:
ADRES1 = 133 at T1 = 5 deg. Cand
ADRES2 = 151 at T2 = 70 deg. CI need to calculate A and B1 (or we can say it's B1 = B<<16). So I derived this:
A = T1 - ADRES1*BB = (T2-T1)/(ADRES2-ADRES1)or B1 = B << 16
Let me know if I'm wrong or if something can be optimized. Now it would be nice if I can avoid division in calibration - I'm not sure if I can get all the code into a PIC12F1571. But I'll worry about that when I'm out of ROM.