How do I compare two temperatures


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2010
    Posts
    8

    Default How do I compare two temperatures

    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

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    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.

    Code:
    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.
    All progress began with an idea

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    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

    Code:
    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)

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    IF Temperature > alarmhigh then AlarmPin = 1
    IF Temperature < alarmlow then AlarmPin = 1
    Malcom, you have a typo in your two lines of code!

    Al.
    All progress began with an idea

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts