IR Temperature Sensor


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: IR Temperature Sensor

    i cant comment on the code much , but its a bit easier to read



    Code:
    Temperature:
    
    i2cread SDA, SCL, SAdef, LocAmbTemp, [AmbTemp] 'read amb temperature Ta & save in AmbTemp
     gosub SwapAmbBytes:                            'I2C reads the highest byte first; Go swap the bytes
    
    i2cread SDA, SCL, SAdef, LocObjTemp, [ObjTemp] 'read object temperature (Tobj) & save in ObjTemp
    gosub SwapObjBytes:
    
    if AmbTemp >= ObjTemp then Temperature               'Object is not heating, continue to loop
    if (ObjTemp - AmbTemp) >= ThresTemp then ObjHeating  'differance between Amb & Obj temperature has exceeded threshold temp
    
    
    Reset:                 'Reset time count and turn motion sensor off if (ObjTemp - AmbTemp) is less that threshold temp.
    cnt = 1
    low 6                  'turns motion sensor off
    goto Temperature
    
    
    ObjHeating:
    high 6                 'obj is heating; turn motion detector on (by setting RB6 high) to check for motion in room .
    
    for cnt = 1 to MaxTime 'measure time by counting # of loops of approx one sec each.
    
      If portb.1 = 1 then Temperature 'motion occured in room, do a reset
    
       i2cread SDA, SCL, SAdef, LocAmbTemp, [AmbTemp] 'read amb temperature Ta & save in AmbTemp
       gosub SwapAmbBytes:
       i2cread SDA, SCL, SAdef, LocObjTemp, [ObjTemp] 'read object temperature (Tobj) & save in ObjTemp
       gosub SwapObjBytes:
    
     if AmbTemp >= ObjTemp then Temperature           'Object is not heating, start new loop
    
     if (ObjTemp - AmbTemp) < ThresTemp then Temperature 'differance between Amb & Obj temperature is less than threshold temp
    
    next cnt
    
    Alarm: 'object temperature has exceeded threshold temp for more than the MaxTime, so sound alarm
      high portb.0
      pause 2000
      low portb.0
      pause 15000
      if portb.5 = 0 then Temperature
      goto Alarm 
    
    end
    
    ' ---------- Sub Routines  ----------
    
     SwapAmbBytes: 'swap the MSB and LSB of the amb and obj temperatures
       
        swap AmbTemp.byte1, AmbTemp.byte0
     return
    
    
    SwapObjBytes: 
       swap ObjTemp.Byte1, ObjTemp.byte0 
    return

  2. #2
    Join Date
    Aug 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: IR Temperature Sensor

    Thank you for reformatting my code. It is much easier to read, but probably still too difficult for someone else to diagnose my code.

    My IR sensor uses an SMBus interface. Since the SMBus interface is very simular to my micro I2C interface, I think the two should be compatible. I can monitor the serial data stream from the IR sensor with a logic analyzer and see that the ambient and object temperature data is about what it should be. But the serial data stream includes other data than the temperature data. I would like to see what is being loaded into the AmbTemp and ObjTemp RAM locations. To do this, I need to be able to transfer the 16 bit data out of the AmbTemp, and ObjTemp RAM, locations onto two of the 8 bit ports to read the parallel data. I would appreciate any help.

    Thank you, TravisM

Similar Threads

  1. Replies: 7
    Last Post: - 23rd November 2011, 16:22
  2. Sensor temperature MCP9800-1-2-3
    By steneor in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th June 2008, 01:01
  3. Precise temperature sensor
    By Christopher4187 in forum Off Topic
    Replies: 0
    Last Post: - 7th June 2006, 18:39
  4. adc temperature sensor
    By rastan in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th May 2006, 12:21
  5. more-than-8 bit temperature sensor I2C
    By picster in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th March 2006, 20:29

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