Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:24 10 Nov 2025 Privacy Policy
Jump to

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.

Forum Index : Microcontroller and PC projects : Colour MM DS18B20 negative temperature

Author Message
Cherokeecruiser
Newbie

Joined: 25/02/2015
Location: Australia
Posts: 25
Posted: 06:08am 27 Nov 2017
Copy link to clipboard 
Print this post

Hi

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: Australia
Posts: 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
 
Cherokeecruiser
Newbie

Joined: 25/02/2015
Location: Australia
Posts: 25
Posted: 01:12pm 27 Nov 2017
Copy link to clipboard 
Print this post

Thanks Boppa

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 Kingdom
Posts: 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: Australia
Posts: 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
 
Cherokeecruiser
Newbie

Joined: 25/02/2015
Location: Australia
Posts: 25
Posted: 10:55pm 27 Nov 2017
Copy link to clipboard 
Print this post

JohnS,

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


 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025