DS18B20 Temp Comparison

sailgene

Member
Hello Group.

I'm new to the Picaxe chip and want to build a simple project which compares two temperatures using two DS18B20 sensors. The issue is to start a fan which would assist a marine refrigerator when the outside temperature is cooler than the inside of the refrigerator. The fan would simply circulate colder, outside air through the refer.

In term of Celsius, it would be comparing something between 1 and 4 degrees C. As I understand it, the DS18B20 reads or "outputs" in terms of Celsius.

I don't need any LCD displays in this project and so the issue of dealing with a readout display is not important. But if I set up two variables to place the "readtemp" inputs, will the variables be integers representing the temperature? Or do I need to do some conversion math to the variable to create a meaningful number for comparison?

In other words, I was hoping I could have a couple of commands: "readtemp 2, b2" and "readtemp 4, b3" followed later by a command: "IF b3 <= b2 goto fanon". My concern is that the numbers being placed in variables b2 and b3 would not be so meaningful for comparison if they weren't simple integers.

Sorry this is so verbose. Thanks for any help out there.

ps: I'll work on the problem of "below freezing" later....

Gene Darby
 

premelec

Senior Member
Yes READTEMP comes out with whole integer C deg values - though as you've noted below zero there are other considerations - read Manual 2 description of the command.

READTEMP12 is a much more complicated function but gives you much better resolution when you need it... good luck with it!
 

sailgene

Member
Temp Comparisons

Thanks Premelec.

I waded through some of the forum and did find the answer you confirmed. Also learned about "debug" so that when I get the sensors, I can see for myself what information they're putting out.

Now to figure out how to handle temps below freezing....

Thanks again.

Gene
 

MPep

Senior Member
Instead of using DEBUG, I would use SERTXD. IMHO, easy to setup, and you get to read out exactly what you want. Not all the registers that are not important at that time.
 

premelec

Senior Member
Note that the Manual 2 READTEMP description gives clear indication of detection of negative C temperatures and so IF clauses can help you out for the conditions of above or below 0 C.
 

BeanieBots

Moderator
Don't forget to callibrate the sensors against each other.
One might read T+0.5C and the other T-0.5C giving a FALSE indication of a 1C difference in temperature.
 
Top