Using the TMP100 series of I2C temperature sensor from Texas Instruments


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Nice one Aberco.

    Promoted to article here: http://www.picbasic.co.uk/forum/cont...as-Instruments
    http://www.scalerobotics.com

  2. #2
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101


    Did you find this post helpful? Yes | No

    Default

    Bug report on the conversion routine... should be:
    Code:
    TempL = TempL + 16 'adding 1 temperature unit
    Wiki article was fixed

    Code:
    TempDec = 0
    IF TempL.7 = 1 THEN TempDec = 5000
    IF TempL.6 = 1 THEN TempDec = TempDec + 2500
    IF TempL.5 = 1 THEN TempDec = TempDec + 1250
    IF TempL.4 = 1 THEN TempDec = TempDec + 625
    can also be replaced by:

    Code:
    TempDec = TempL * 625
    Not sure what takes the longest to compute, use whichever you like.
    Last edited by aberco; - 27th September 2010 at 16:36.

  3. #3
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101


    Did you find this post helpful? Yes | No

    Default

    And more code cleaning... I don't need yet the part to display to LCD so that's why I haven't paid much attention to it. Works the same way but with much less resources.

    Code:
    TempSign VAR Byte
    TempDec VAR Word
    
    '*******************************************************
    'Convert temperature to LCD
    '*******************************************************
    ConvertTemp:
    
    IF TempH.7 = 1 THEN
            TempSign = "-"
            TempL = TempL ^ %11110000 'bitwise invert on the 4 MSB
            TempL = TempL + 16 'adding 1 temperature unit
            TempH = TempH ^ %11111111 'bitwise invert 
            IF TempL = 0 THEN
                    TempH  = TempH + 1
            ENDIF 
    ELSE
            TempSign = "+"
    ENDIF
    
    TempDec = TempL * 625
    
    LCDOUT $FE,1, TempSign, #TempH, ".", #TempL, "°C"
    
    RETURN

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