PDA

View Full Version : How do I compare two temperatures



critix
- 3rd January 2011, 12:49
Welcome
I want to do a little 16F628A LCD thermometer with sensor DS1820.
Want to read temperature, read and if temp is now lower than previously read, display the down arrow, a sign that the low temperature, if higher, up arrow, a sign that rose. if so, I put the sign -.
I made the display of temperature, but do not know how to check whether increased or decreased, given that temperature is shown in the format xx.xx
Can you help me with some examples?

Thanks in advance

Acetronics2
- 3rd January 2011, 14:12
Hello, Critix


Just use the SEARCH function ( the little white window @ upper right of your screen )

Every example you need already " threaded " ...

Have a Happy new Year !

Alain

aratti
- 3rd January 2011, 15:39
I made the display of temperature, but do not know how to check whether increased or decreased, given that temperature is shown in the format xx.xx
Can you help me with some examples?


Now let assume that your unformatted temperature reading is contained in a variable named New_Temp, then make available an additional variable (same type) and call it Old_Temp.

Write a subroutine that you will call all the time you want to check the temperature variation.



Temp_Sub:
IF New_Temp > Old_Temp Then LCDOUT "up arrow"
IF New_Temp = Old_Temp Then LCDOUT " "
IF New_Temp < Old_Temp Then LCDOUT "Dn arrow"
Old_Temp = New_Temp
Return


..... and you are in business.

Cheers

Al.

malc-c
- 3rd January 2011, 23:26
You beat me to it.

I use a similar process for monitoring the temperatures in my Vivariums, and sounding an alarm if they exceed a set range. Basically



IF Temperature > alarmhigh then AlarmPin = 1
IF Temperature < alarmlow then AlarmPin = 1


The variables used are word type so in my code for the thermostat 23.6C would be stored as 236. Likewise a high threshold would be 350 (35.0c)

aratti
- 4th January 2011, 13:42
IF Temperature > alarmhigh then AlarmPin = 1
IF Temperature < alarmlow then AlarmPin = 1


Malcom, you have a typo in your two lines of code!

Al.