Reading temperature using multi DS18B20


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Oct 2007
    Location
    Vancouver, BC, Canada
    Posts
    33

    Default Reading temperature using multi DS18B20

    - chip use: pic16F876A running @ 20MHz, 2x20 alphanumeric LCD, DS18B20, MAX233

    - software: when first power up the PIC scans for the DS18B20 and store ID ROM in the PIC's ram for later use. When the reads temperature and display the reading to the 2x20 LCD, also send out the temperature reading to RS232 for data logging.

    -schematic included.

    Please give credit to Mr. E, Jimbab, Bruce... as I copied some of their subroutines and modified.

    Comments are welcome.

    Thanks for reading.

    In the zip file, you will find the pbp program and a pdf file for schematic.
    Attached Files Attached Files
    ________________
    KV

  2. #2
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Thumbs up great piece of work!

    Hi KV,

    Thanks for a great piece of work!

    Thanks also to, Mr. E, Jimbab, Bruce and others. The helpers on this forum are heroes to all of us.

    This is really nice to have the whole package. Schematic, and code working together. A real contribution to the forum. Thanks for the extra work of putting it together and posting it for all.

    Great,
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  3. #3
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi KVLC

    An exception to the rule The whole kaboosh

    Glad I logged on

    got some 18b20's around, makes me want to fire them up.

    youve put a lot of thought into this, great preparation! and presentation.

    A real gem

    Thankyou

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by duncan303 View Post
    An exception to the rule
    True statement...Think I'm going to order a few more and have a play with them...

    The example is fine, looks great...

    How long do you suppose it'll take before somebody asks for code rewritten for different PICs, running at different speeds, adding in their own applications, using different versions of the '1820 (DS1820, DS18S20, etc.)...

  5. #5
    Join Date
    Nov 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default I can't find your schematic - please

    Your DS18B20 program is fantastic, and I would like to experiment with it.
    You mention in your header, I should also see schematic 876DS18B20_ID_ROM_A.PBP.SCHDOC, but I can't find it anywhere. I can figure out most of the schematic from the code, but I will be using a serial LCD for my display, and need to know the type of LCD you used so that I might convert the codes.
    Thanks again for a really well thought out piece of code

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Everything is in the PDF file in the ZIP file.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Nov 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default Thanks for the reply but..

    Sorry, I just don't see the part number for the LCD used . Thanks

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Any 2x20 character LCD based on Hitachi HD44780 controller, or equivalent, would do.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Nov 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default I will try those codes

    Thanks, I'll use the Hitachi codes for the conversion to my serial LCD

  10. #10
    Join Date
    Jan 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    I have problem to simulate the codes with proteus 7.4sp3. Program stuck at searching DS screen! Any idea friends ? And I dont need to use MAX233.What should I do with the codes ?
    Last edited by solidus; - 22nd January 2009 at 00:25.

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Proteus don't stuck... proteus sucks

    Try it on real world hardware.. sure enough it will work!

    However, you may try to upload your files here (code, proteus files and compiled .HEX) so if anyone have waste cash on Proteus would be able to check it for you.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Oct 2007
    Location
    Vancouver, BC, Canada
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Updated:
    I use part of the OP program to control a broken oil heater, this time I use solid state relays.
    the attachment included with the .pbp file and schematic in .pdf also 2 non-modified Instant Interrupt routines from Darrel Taylor << Thanks.
    Attached Files Attached Files
    ________________
    KV

  13. #13
    thinktank's Avatar
    thinktank Guest


    Did you find this post helpful? Yes | No

    Wink PIC16F877 based Temperature Controller

    I wish to implement a PIC16F877 based temperature controller. A LM35DZ temperature sensing IC is connected to RA0 and 10bit A/D value is used to obtain voltage values at regular intervals. The value of the obtained temperature ( LM35DZ is calibrated to 10mV/0 C) is displayed on a HD44780 LCD module which is connected on PortB and using 4-bit data lines (RB4 to RB7). The deviation from the set-point temperature is used to compute a PID output and this output is used to generate PWM control signals. Both CCP modules of the PIC16F877 are used CCP1 being connected to the gate of the heater driving NMOSFET (IRL1004) and CCP2 also to the gate of the fan driving NMOSFET. The duty cycle has to be varied in proportionto the amount of deviation.

    If you have any constructive advice do not hesitate to offer it or if anyone can hook me up with a similar design or relevant source code. I am familiar with both C and Basic programming languages. My regular email is [email protected] .Thanks in advance.

  14. #14
    Join Date
    Sep 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Reading temperature using multi DS18B20

    I am having some troubles understanding the read temperature portion of this code. Take the following exerpt from the code:
    W1:
    OWIN DQ,4,[busy] ' Check for still busy converting
    IF busy = 0 THEN W1' Still busy?, then loop
    owout dq,1,[$55,S[(L*8)+0],S[(L*8)+1],S[(L*8)+2],S[(L*8)+3],S[(L*8)+4],S[(L*8)+5],S[(L*8)+6],S[(L*8)+7],$BE]
    OWIN dq, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]' Read two bytes / end comms
    HotOrCold:
    IF Cold_Bit = Real_Cold THEN ' If Cold_Bit = 1, it's below "0" LcdDeg C
    Sign = "-" ' Display - symbol for negative temp
    Dummy = 625 * ~R_Temp+1' Multiply to load internal registers with 32-bit value
    TempC = DIV32 10 ' Use Div32 value to calculate precise LcdDeg C
    endif

    if cold_bit = 0 then
    Sign = "+"
    Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
    TempC = DIV32 10 ' Use Div32 value to calculate precise LcdDeg C
    TempC = (R_Temp & $0FF0) >> 4 ' Mask middle 8-bits, shift into lower byte
    Float = ((R_Temp.Lowbyte & $0F) * 625) ' Lower 4-bits of result * 625
    endif

    1. Okay so, under HotOrCold:, about 10 lines down you are assigning TempC to DIV32 10. No problems there. Then you assign TempC to (R_Temp & $0FF0) >> 4. Does this not just overwrite the value of TempC that you just assigned?

    2. Under HotOrCold: again. 3 lines down. What is the "~" for? Couldn't find any documentation on this from the picbasic help file. And what does the +1 do?

  15. #15
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Reading temperature using multi DS18B20

    I think I can answer your last question...

    ~ is Bitwise NOT... meaning to invert each bit

    For the other question I can not help... I have yet to understand exactly what the DIV32 function does.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  16. #16
    Join Date
    Sep 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Reading temperature using multi DS18B20

    Thanks! That clears that up. Do you know why the +1 on the end?

    The DIV32 command allows you to divide the 32 bit number held in internal registers. But that's not really important here. More importantly, why do we assign TEMPC, then reassign it again on the next line of code without using it.

  17. #17
    Join Date
    Apr 2011
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Reading temperature using multi DS18B20

    Thanks for posting your code. I was having difficulty with negative readings and converting to an integer. I saw what I was doing wrong, corrected my code and now I can read negative temperatures.
    thanks,

Similar Threads

  1. Please help with code for DS18B20
    By fratello in forum mel PIC BASIC Pro
    Replies: 109
    Last Post: - 28th April 2013, 22:12
  2. Multi DS18b20 Code help.
    By sccsltd in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th December 2009, 07:13
  3. DS18S20 reading negative temperature
    By srob in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th December 2007, 22:21
  4. DS18B20 error reading
    By Gaetano in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th August 2007, 17:21
  5. Reading 5 DS18B20 Problem
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2005, 21:51

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