DS18B20 thermostat


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: DS18B20 thermostat

    Could you please make a test for me?

    Inside the test code part, put a Serout command to monitor the two values MTemp and setpoint

    [code]
    MTtemp >>4
    if MTtemp <= setpoint then
    high heater
    else
    low heater
    endif
    Serout TX, T9600,[dec MTemp, dec setpoint] 'Please put at the preffered place on your LCD
    [code]

    Ioannis

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: DS18B20 thermostat

    Are you comparing the temp sensor output data to the value "78" or "780"? If I understand the data format of the temp sensor read code, the data is (temperature * 10) so that you have a resolution of 0.1 deg. Which means 78.0 degrees is 780 decimal returned by the temp sensor read code.

    Also in your compare code you are right shifting the temp sensor reading by 4 which is like dividing by 16. This changes the decimal value 780 to 48 which is not what I think you wanted to do. You need to actually divide the temp sensor data by 10 decimal, and then compare. Or multiply the test value by 10 and then compare.

    I think what is confusing you is the DEC function. The DEC take a value and returns the specified decimal digit. Kind of like this: [value / (10 ^ n) ] // 10.
    Last edited by falingtrea; - 18th April 2013 at 19:12. Reason: added additional info
    Tim Barr

  3. #3
    Join Date
    Dec 2011
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: DS18B20 thermostat

    You are absolutely right falingtrea, I just figured that out. Several things I was doing wrong and will explain later, but right now I am taking my wife out to dinner.
    Thanks!

  4. #4
    Join Date
    Dec 2011
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: DS18B20 thermostat

    Ok, many many things I did wrong here. First was that I was trying to shift it >>4 to get the number in the lowbyte then trying to compare. Now the code is:
    Code:
     MTtemp = (MTtemp + 3200)
     IF MTtemp/100 <=  HeaterSetTemp THEN 
    HIGH MainHeater
    ELSE
    LOW MainHeater
    ENDIF
    I figured since I was trying to compare a word (data from DS18B20) to a byte (HeaterSetTemp) that I should shift the data >>4 and put it in the lowbyte then compare, but since I'm not working with a negative tempature reading I guess it doesn't really matter since all the leading bites are all zeros. The values displayed on the LCD was let’s say: MTtemp=6610 which is 66.10*F. I divided by10 to get rid of the .10 then compaired to 78 (HeaterSetTemp). Works perfect! The other problem was... it seems that I forgot to set the HeaterSetTemp variable to point to anything, so the HeaterSetTemp that was displayed was 146. I don't know where that came from since after looking at the code the HeaterSetTemp var was not pointed to anything, I would think it should have showed "0". For testing I did:
    Code:
    HeaterSetTemp = 78
    I thank you to both Ioannis and falingtrea for forcing me to display the data to see what I was dealing with. I should have done that in the first place and I knew that, but I guess I was looking for and easy fix, as a manager for a team of technicians I am huge on proper diagnosing and preach it all the time... but I failed to follow my own words this time.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: DS18B20 thermostat

    No problem. Glad you did solve it.

    Ioannis

Similar Threads

  1. 4 Channel Thermostat using PID loops
    By malc-c in forum Code Examples
    Replies: 36
    Last Post: - 18th March 2013, 10:17
  2. Thermostat for refrigerator
    By fratello in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th August 2012, 22:58
  3. Thermostat
    By koossa in forum Off Topic
    Replies: 15
    Last Post: - 16th November 2010, 10:06
  4. Pulse proportional thermostat
    By malc-c in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th December 2009, 02:00
  5. using the DS18B20
    By lerameur in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2006, 13:09

Members who have read this thread : 0

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