Shop OBEX P1 Docs P2 Docs Learn Events
I2C Identification question — Parallax Forums

I2C Identification question

TappermanTapperman Posts: 319
edited 2015-01-08 12:53 in Propeller 1
Hello All,

Is there a way to 'snoop' (as the Master) for any slaves present? Has someone already written code to do so? And measure how far away they are?

... Tim

Comments

  • r.daneelr.daneel Posts: 96
    edited 2015-01-08 12:35
    I don't know about snoop, but you could broadcast i2c addresses in a loop and check for an acknowledgement - the i2c protocol requires ack/nak after each 8 bits of data. If you get no acknowledgement you know (or assume) nothing with that address is on the bus and move on. I have no idea if you can tell how far away the device is though - I wouldn't have thought that was possible (easily anyway).
  • ChrisGaddChrisGadd Posts: 310
    edited 2015-01-08 12:44
    There are many I2C pollers that will tell you the addresses of any devices on bus; my own version is here: http://obex.parallax.com/object/700. It displays the addresses and makes a stab at identifying what kind of device it is, based on common addresses.
    No idea how to determine the distance.
  • DomanikDomanik Posts: 233
    edited 2015-01-08 12:52
    Tapperman wrote: »
    Hello All,

    Is there a way to 'snoop' (as the Master) for any slaves present? Has someone already written code to do so? And measure how far away they are?

    ... Tim
    I did a snoop that worked for all the devices I tried. Just like r.daneel said, a simple loop x01 to x7F. x00 is a general purpose ALL SA.

    IMHO distance measurement is not possible with standard mode 0, 10k pullups--- about 99% sure. Unless you can figure out a way to use mode 1 to get the bus to act as a TDR.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-01-08 12:53
    Is there a way to 'snoop' (as the Master) for any slaves present?


    Easy-peasy -- you simply do a start, then write the control byte (slave id) for the device you're looking. If you get an ACK, it's there, A NAK means it's not. My I2C object has a method called present() that can poll a specific device id and return true or false.

    I ran the attached program on a PAB and it correctly identified the boot EEPROM (id is $A0) as being attached.

    And measure how far away they are?


    No.
Sign In or Register to comment.