Shop OBEX P1 Docs P2 Docs Learn Events
Reading multiple sensors on one i2c buss — Parallax Forums

Reading multiple sensors on one i2c buss

Chuck MintonChuck Minton Posts: 45
edited 2011-01-13 02:21 in Propeller 1
I am attempting to make a controller for a greehouse.
I am using lm92 temp sensors.
I had to modify the I2Cobject.spin by John Williams, to read the 16bit word.
All works on as should on 1 of the sensors (%10000). ON ( %10010) it is seen as a device but gives varying incorrect reading. On the other two(%10001 and %10011) the devices are not recognized.

Wondering if this is the proper way to check and see if the device is available, and if so read it.
I have a test LED on, and when the device is present it is supposed to turn off the LED as well as collect the data.

Am I addressing these incorrectly??? (Backwards or something?)
CON
  
  _clkmode   = xtal1 + pll16x           ' Feedback and PLL multiplier
  _xinfreq   = 5_000_000                ' External oscillator = 5 MHz

    T1       =%10010000         'TEMPRETURE READING I2C DEVICDES ON SINGLE BUSS
    T2       =%10010001         '4 ADDRESSES AVAILABLE PER DEVICE
    T3       =%10010010
    T4       =%10010011


PUB GETtemp                       ' TEMP SENSOR I2C INITIALIZATION 
      I2C.INIT (15,14,FALSE) 


REPEAT                               'LOOP
   outa[LED2]~~
           
            IF I2C.devicePresent(T1)
               TEMPRETURE[1]:=I2C.readLocation(T1,%00000000,8,8) ' SEND A "ZERO"BYTE TO  READ DEVICE
               outa[LED2]~
            IF I2C.devicePresent(T2) 
               
               TEMPRETURE[2]:=I2C.readLocation(T2,%00000000,8,8) ' SEND A "ZERO"BYTE TO  READ DEVICE
               outa[LED2]~
            IF I2C.devicePresent(T3)  
               TEMPRETURE[3]:=I2C.readLocation(T3,%00000000,8,8) ' SEND A "ZERO"BYTE TO  READ DEVICE
               outa[LED2]~
            IF I2C.devicePresent(T4)  
               TEMPRETURE[4]:=I2C.readLocation(T4,%00000000,8,8) ' SEND A "ZERO"BYTE TO  READ DEVICE
               outa[LED2]~  

is there any issues with timing that could be a problem???

I have the sensor in a 5' cat5 cable. Would like to run 60' if possible in future.

I can put more code up if anyone thinks that would help.

Every things works great with one sensor, so it is not reading the device that is the problem it is specifically reading multiple units.

Thanks
/Chuck

Comments

  • Chuck MintonChuck Minton Posts: 45
    edited 2011-01-11 19:57
    Edited: I added some important things I found to the thread.
  • JonnyMacJonnyMac Posts: 9,235
    edited 2011-01-11 21:50
    I2C stands for "inter-integrated circuit" communications and is intended for on-board use. That said, there are lots of projects in Elector magazine that show how to extend the range.
  • Clive WakehamClive Wakeham Posts: 152
    edited 2011-01-12 00:10
    I have the sensor in a 5' cat5 cable. Would like to run 60' if possible in future.

    I2C devices are not designed for cable runs especially at 3V or 5V.

    You need to be using 12V for cable runs and because of this you need a I2C Buffer which can translate from 5V to 12V >> cable << 12V to 5V.

    Texas Instruments make a few of these products. The P82B96 would be the likely device http://focus.ti.com/docs/prod/folders/print/p82b96.html
  • Chuck MintonChuck Minton Posts: 45
    edited 2011-01-12 21:47
    Thanks for those points: Things I will be considering as I extend the range...esp conv to higher voltage!

    My problem was much more subtle or local. I could read the %1001 0000 device, but can not read the other addresses.
    According to the LM92 Data Sheet:
    The address is as follows:
    1 0 0 1 0 A1 A0
    MSB LSB

    From prodding around I found the answer: For some reason I need to add a "0" to the end of the address. So, the way I got it to work is : 1 0 0 1 0 A1 A2 0.

    Could there be some issue with the I2Cobject...(My Bad! Not by JohnWilliams...rather: I2C SPIN Object by James Burrows May 2006 Version 1.3 )

    The data sheet from National specifically says it is a 7 bit address. Would appreciate notes from anyone who has figured this out!

    Thanks,
    /Chuck
  • Clive WakehamClive Wakeham Posts: 152
    edited 2011-01-13 02:21
    Thanks for those points: Things I will be considering as I extend the range...esp conv to higher voltage!

    My problem was much more subtle or local. I could read the %1001 0000 device, but can not read the other addresses.
    According to the LM92 Data Sheet:
    The address is as follows:
    1 0 0 1 0 A1 A0
    MSB LSB

    From prodding around I found the answer: For some reason I need to add a "0" to the end of the address. So, the way I got it to work is : 1 0 0 1 0 A1 A2 0.

    Could there be some issue with the I2Cobject...(My Bad! Not by JohnWilliams...rather: I2C SPIN Object by James Burrows May 2006 Version 1.3 )

    The data sheet from National specifically says it is a 7 bit address. Would appreciate notes from anyone who has figured this out!

    Thanks,
    /Chuck

    Where as they indicate a 7 bit address (bits 7 to 1), this is the location of the I2C device BUT the final bit (bit0) is the R/W flag. A zero (0) means write and a one (1) means read.

    So according to the data sheet, the LM92 has a range of addresses from 90(hex) write, 91(hex) read [A1=0 and A0=0] up to 96(hex) write, 97(hex) read [A1=1 and A0=1].

    To work out the addresses correctly I just use the calculator provided with Windows and change it Programmer mode and enter the binary digits.
Sign In or Register to comment.