Results 1 to 9 of 9

Thread: Thermal sensor help

  1. #1
    Join Date
    Nov 2007
    Posts
    397
    Images
    71
    Rep Power
    51

    Thermal sensor help

    Hey,
    I want to use a devantech thermal array sensor with a basic stamp 2pe, but I am having some problems. I know what pins to connect to on the stamp (pin 8 is SDA and pin 9 is SCL). I havent done anything with I2C before so I dont have a cool how to write a program for the basic stamp to input values. Does anyone have any experience with this sensor controller combination? I could sure use the help.

  2. #2
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    176

    Re: Thermal sensor help

    Whatcha tryin' to detect with it? Is it for a firefighting 'bot (in which case, I'd probably build a sliding window and "remember" the highest temperatures I've seen as a threshold), or are you trying to find people (I'd be looking for 20-29deg C), or something else cool?

    According to the spec sheet, it provides 10 registers that contain:

    Register 0, Software Rev
    Reg 1 Ambient Temp Deg C
    Reg 2 Pixel 1 Deg C
    Reg 3 Pixel 2 Deg C
    Reg 4 Pixel 3 Deg C
    [...]
    Reg 9 Pixel 8 Deg C

    You know how to hook up the hardware, right? Remember your pullup resistors.

    Onward to the most basic of coding and then we can discuss your use of it if it's not enough of a hint.

    I don't have a Basic Stamp handy, but something like this should about do the job of simply demonstrating how to capture the data from it:

    Code:
    SDA   CON 8           'Serial Data [SDA] is on pin 13, Serial Clock [SCL] is on pin 14
    Ver   VAR Byte       ' Version information is in the first byte
    Am_C  VAR Byte        ' Ambient Temperature in Deg C is in second byte 
    P1    VAR Byte        ' Pixel Temps Follow in Deg C
    P2    VAR Byte
    P3    VAR Byte
    P4    VAR Byte
    P5    VAR Byte
    P6    VAR Byte
    P7    VAR Byte
    P8    VAR Byte
    'A tight loop displaying the registers to the PC debugger console as fast as we can.
    DispLoop:
      I2CIN SDA, $d1, 0, [Ver, Am_C, P1, P2, P3, P4, P5, P6, P7, P8 ]
      DEBUG 2,0,2, "Rev", DEC Ver, "    "
      DEBUG 2,0,3, "Ambient C", DEC Am_C, "    "
      DEBUG 2,0,4, "P1 P2 P3 P4 P5 P6 P7 P8"
      DEBUG 2,0,5, DEC3 P1, "  ", DEC3 P2, "  ", DEC3 P3, "  ", DEC3 P4, "  ", DEC3 P5, "  ", DEC3 P6, "  ", DEC3 P7, "  ", DEC3 P8
      GOTO DispLoop
    Last edited by Adrenalynn; 06-16-2008 at 02:50 PM.

  3. #3
    Join Date
    Nov 2007
    Posts
    397
    Images
    71
    Rep Power
    51

    Re: Thermal sensor help

    hey thanks for the help. I am going to be using it to detect a flame. At this point though I am just interested in returning values to see how the sensor reacts. I tried the code, but it just returns a values of 255 for every pixel. here is the output.

    255 255 255 255 255 255 255 255
    Rev255
    Ambient C255
    P1 P2 P3 P4 P5 P6 P7 P8

  4. #4
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    176

    Re: Thermal sensor help

    Huh. The registers are uninitialized...

    Can you post a diagram of how it's hooked-up, make sure it's spitting data out at all?

    I have a slightly different one here, optimized for human body heat, but I actually don't have a working BASIC Stamp - which is bizarre given my obsession with microcontrollers. I'm reading my from a SAM7 right now, but have also used the ATMega. I just got a spiffy Atmel AVR programmer the other day, so I'll probably be moving it over to something like the socket3300 series...

    Anywho - let's check-out your connections, then try to debug code.
    I Void Warranties´┐Ż

  5. #5
    robot maker Guest

    Re: Thermal sensor help

    here is a test program for bs2,since i have one and doing some testing on tpa81 and cmps-03 for my robots
    '************************************************* **********
    '** **
    '** I2C Routines for the Basic Stamp BS2/BS2e/BS2sx **
    '** with the TPA81 Thermal sensor module **
    '** **
    '** Copyright 2006 - Devantech Ltd **
    '** Commercial use of this software is prohibited **
    '** Private and educational use only is permitted **
    '** **
    '** Written by Gerald Coe - March 2006 **
    '** **
    '************************************************* **********

    ' Connect P8 (pin13) of the BS2 to the TPA81 SDA
    ' Connect P9 (pin14) of the BS2 to the TPA81 SCL
    ' Use 4k7 pull-up resistors from SCL and SDA to 5v supply
    SDA CON 8 ' I2C data
    SCL CON 9 ' I2C clock
    SDAin VAR IN8
    SDAout VAR OUT8
    SDAdir VAR DIR8
    Ver VAR Byte
    Ambient VAR Byte
    Pix1 VAR Byte
    Pix2 VAR Byte
    Pix3 VAR Byte
    Pix4 VAR Byte
    Pix5 VAR Byte
    Pix6 VAR Byte
    Pix7 VAR Byte
    Pix8 VAR Byte
    I2cBuf VAR Byte ' I2c read/write buffer
    I2cAddr VAR Byte ' Address of I2C device
    I2cReg VAR Byte ' Register number within I2C device
    I2cData VAR Word ' Data to read/write
    I2cAck VAR Bit ' Acknowledge bit
    DEBUG 2,0,1, "BS2/BS2e/BS2sx - TPA81 Demonstration "
    DEBUG 2,0,2, "Firmware Version "
    DEBUG 2,0,3, "Ambient "
    DEBUG 2,0,4, "Pix1 Pix2 Pix3 Pix4 Pix5 Pix6 Pix7 Pix8"
    I2cAddr = $D0
    I2cReg = 0
    MainLoop:
    GOSUB I2cTPA81Read ' read data from TPA81
    DEBUG 2,17,2, DEC Ver, " "
    DEBUG 2,8,3, DEC Ambient, " "
    DEBUG 2,0,5, DEC3 Pix1, " ", DEC3 Pix2, " ", DEC3 Pix3, " ", DEC3 Pix4, " ", DEC3 Pix5, " ", DEC3 Pix6, " ", DEC3 Pix7, " ", DEC3 Pix8
    GOTO MainLoop

    '--------------------------------------------------------------------------------------------
    ' I2C subroutines follow
    '--------------------------------------------------------------------------------------------
    I2cTPA81Read:
    I2cAck = 1 ' send Ack
    GOSUB I2cStart
    I2cBuf = I2cAddr
    GOSUB I2cOutByte ' send device address
    I2cBuf = I2cReg
    GOSUB I2cOutByte ' send register number
    GOSUB I2cStart ' repeated start
    I2cBuf = I2cAddr | 1
    I2cAck = 1 ' send Ack
    GOSUB I2cOutByte ' send device address (with read set)
    GOSUB I2cInByte
    Ver = I2cBuf ' read the data
    GOSUB I2cInByte
    Ambient = I2cBuf
    GOSUB I2cInByte
    Pix1 = I2cBuf
    GOSUB I2cInByte
    Pix2 = I2cBuf
    GOSUB I2cInByte
    Pix3 = I2cBuf
    GOSUB I2cInByte
    Pix4 = I2cBuf
    GOSUB I2cInByte
    Pix5 = I2cBuf
    GOSUB I2cInByte
    Pix6 = I2cBuf
    GOSUB I2cInByte
    Pix7 = I2cBuf
    I2cAck = 0 ' send Nak
    GOSUB I2cInByte
    Pix8 = I2cBuf
    GOSUB I2cStop
    RETURN

    I2cByteWrite: ' writes I2cData.lowbyte to I2cReg at I2cAddr
    GOSUB I2cStart
    I2cBuf = I2cAddr
    GOSUB I2cOutByte ' send device address
    I2cBuf = I2cReg
    GOSUB I2cOutByte ' send register number
    I2cBuf = I2cData.LOWBYTE
    GOSUB I2cOutByte ' send the data
    GOSUB I2cStop
    RETURN

    I2cWordWrite: ' writes I2cData to I2cReg at I2cAddr
    GOSUB I2cStart
    I2cBuf = I2cAddr
    GOSUB I2cOutByte ' send device address
    I2cBuf = I2cReg
    GOSUB I2cOutByte ' send register number
    I2cBuf = I2cData.HIGHBYTE
    GOSUB I2cOutByte ' send the data - high byte
    I2cBuf = I2cData.LOWBYTE
    GOSUB I2cOutByte ' send the data - low byte
    GOSUB I2cStop
    RETURN

    I2CByteRead:
    GOSUB I2cStart
    I2cBuf = I2cAddr
    GOSUB I2cOutByte ' send device address
    I2cBuf = I2cReg
    GOSUB I2cOutByte ' send register number
    GOSUB I2cStart ' repeated start
    I2cBuf = I2cAddr | 1
    GOSUB I2cOutByte ' send device address (with read set)
    I2cAck = 0 ' send Nak
    GOSUB I2cInByte
    I2cData.LOWBYTE = I2cBuf ' read the data
    I2cData.HIGHBYTE = 0
    GOSUB I2cStop
    RETURN

    I2CWordRead:
    GOSUB I2cStart
    I2cBuf = I2cAddr
    GOSUB I2cOutByte ' send device address
    I2cBuf = I2cReg
    GOSUB I2cOutByte ' send register number
    GOSUB I2cStart ' repeated start
    I2cBuf = I2cAddr | 1
    I2cAck = 1 ' send Ack
    GOSUB I2cOutByte ' send device address (with read set)
    GOSUB I2cInByte
    I2cData.HIGHBYTE = I2cBuf ' read the data
    I2cAck = 0 ' send Nak
    GOSUB I2cInByte
    I2cData.LOWBYTE = I2cBuf
    GOSUB I2cStop
    RETURN

    I2cOutByte:
    SHIFTOUT SDA, SCL, MSBFIRST, [I2cBuf]
    INPUT SDA
    HIGH SCL ' clock in the ack' bit
    LOW SCL
    RETURN

    I2cInByte:
    SHIFTIN SDA, SCL, MSBPRE, [I2cBuf]
    SDAout = 0
    SDAdir = I2cAck
    HIGH SCL ' clock out the ack' bit
    LOW SCL
    INPUT SDA
    RETURN

    I2cStart ' I2C start bit sequence
    HIGH SDA
    HIGH SCL
    LOW SDA
    LOW SCL
    RETURN

    I2cStop: ' I2C stop bit sequence
    LOW SDA
    HIGH SCL
    HIGH SDA
    RETURN

  6. #6
    robot maker Guest

    Re: Thermal sensor help

    what is the model of of the sensor you are using (eltec) or another type

    Quote Originally Posted by Adrenalynn View Post
    Huh. The registers are uninitialized...

    Can you post a diagram of how it's hooked-up, make sure it's spitting data out at all?

    I have a slightly different one here, optimized for human body heat, but I actually don't have a working BASIC Stamp - which is bizarre given my obsession with microcontrollers. I'm reading my from a SAM7 right now, but have also used the ATMega. I just got a spiffy Atmel AVR programmer the other day, so I'll probably be moving it over to something like the socket3300 series...

    Anywho - let's check-out your connections, then try to debug code.

  7. #7
    robot maker Guest

    Re: Thermal sensor help

    here is a test program for bs2



    Quote Originally Posted by sthmck View Post
    hey thanks for the help. I am going to be using it to detect a flame. At this point though I am just interested in returning values to see how the sensor reacts. I tried the code, but it just returns a values of 255 for every pixel. here is the output.

    255 255 255 255 255 255 255 255
    Rev255
    Ambient C255
    P1 P2 P3 P4 P5 P6 P7 P8

  8. #8
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    176

    Re: Thermal sensor help

    Quote Originally Posted by robot maker View Post
    here is a test program for bs2
    Where?

    And do you see a problem with mine?
    I Void Warranties´┐Ż

  9. #9
    robot maker Guest

    Re: Thermal sensor help

    no why, sorry post it twice

    Quote Originally Posted by Adrenalynn View Post
    Where?

    And do you see a problem with mine?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •