18B20 Thermometer Question


Results 1 to 2 of 2

Threaded View

  1. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The factory default resolution the DS18B20 is 12-bit. If you're just testing for
    over 4.4 deg C, then after reading the temp, try this;

    TEMP = TEMP >> 4 ' Middle 8-bits into low byte. (see data sheet)
    IF TEMP.LowByte >= 4 THEN HIGH Whatever_PIN

    The lower 4-bits of TEMP is the remainder in 0.0625 deg C increments. By
    shifting TEMP >> 4 you're just shifting out the lower 4-bits, and using the
    whole temp result which is the middle 8-bits of 16-bit word TEMP.

    If you need better resolution, then test the lower 4-bits of TEMP first, then
    shift >> 4 to get the whole number.

    Remainder VAR BYTE
    Whole VAR BYTE

    Remainder = (TEMP.LowByte & $0F) ' Mask & keep lower 4-bits in TEMP
    TEMP = TEMP >> 4 ' Shift middle 8-bits into low byte
    Whole = TEMP.LowByte ' Middle 8-bits of TEMP in Whole

    IF (Whole > 4) AND (Remainder = 7) THEN HIGH PIN ' IF > 4.4 deg C THEN

    7 * 0.0625 = 0.4375 deg C.
    Last edited by Bruce; - 5th April 2006 at 02:21.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. General digital thermometer question Thermistor
    By Neosec in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st June 2008, 03:32
  2. Remote PIC input question
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2007, 16:44
  3. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 10:45
  4. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 07:49
  5. Timer / CCP Question
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2005, 09:22

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