Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
Probably getting a bit old technology now, but is anyone aware of a problem when trying to read a negative temperature with a DS18B20 on a colour maximite.
I'm using "Temperature = DS18B20(OTMP)", which returns correct values with decreasing temperatures down to 0, but then jumps to a negative value and starts to increase, which I suspect maybe the function not dealing with the 2's compliment negative values correctly.
Edited by Cherokeecruiser 2017-11-28
Boppa Guru Joined: 08/11/2016 Location: AustraliaPosts: 816
Posted: 08:02am 27 Nov 2017
Copy link to clipboard
Print this post
Does it jump to the same negative value each time? if so, you could use a small subroutine to display a corrected value from that negative number each time apart from that, no ideas sorry Edited by Boppa 2017-11-28
Should have thought about that for a millisecond or 2 longer before I posted.
You are correct - it jumps from 0 to -128 then starts back towards zero. Simply subtracting any negative temperature value from -128 and problem solved!
If Temperature < 0 then TEMPERATURE = -128 - TEMPERATURE
Cheers
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4126
Posted: 01:39pm 27 Nov 2017
Copy link to clipboard
Print this post
Did it originally work at zero?
If yes, the new one looks off by one.
E.g. -128 will map to 0 but probably ought to be -1.
John
Boppa Guru Joined: 08/11/2016 Location: AustraliaPosts: 816
Posted: 03:33pm 27 Nov 2017
Copy link to clipboard
Print this post
Hey no worries, I spent most of my professional life doing `fixes' So I often look at what fixes it, rather than going overboard on why its not right
Still always interested in why things work, just not adverse to doing a `bush mechanic' on something if it works...
(and one of the reasons I love using the micromites- they use basic, which is the bodgers best computer language lol) I'd love to spend the time learning C for the audrinos, but while I can make a micromite do it at less cost and half the time programming it, I'm happy
I agree - I think that it is actually 1 bit off, so depending on the resolution (9 - 12 bits) it could be up to half a degree off - I'm using 12 bit resolution so suspect it is off by 0.0625°C - (I needed a quick fix to make it function, and can live with that error.)
I think this might be better
If TEMPERATURE < 0 then TEMPERATURE = (-128 + 1_bit_resolution) - TEMPERATURE