Shop OBEX P1 Docs P2 Docs Learn Events
4x identical I2C busses — Parallax Forums

4x identical I2C busses

CircuitsoftCircuitsoft Posts: 1,166
edited 2013-06-13 20:06 in Propeller 1
In my upcoming project, I need to simultaneously read data from 8 LIS3DH accelerometers spread across 4 identical I2C busses. I'm wondering if I can connect all the SCK lines together, and have a single driver read all 8 chips. Does anyone have any ready code to do that?

Comments

  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-11 13:06
    Maybe not code for the LIS3DH, but for reading identical registers from multiple I2C busses?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-06-11 18:19
    There is no problem with having a single clock line and multiple data lines provided none of the devices attempt to stretch the clock. None of the devices I've worked with are capable of clock stretching (holding SCL low) so I can't see a problem with this as the devices synchronize to the master (Prop) anyway. Just checked the LIS3DH and it's a standard I2C device, no stretching. The code works the same way as any current I2C driver does but it would make sense to have a global variable for each channel so the data can be accessed easily.

    Since the LIS3DH can run at 400kHz it makes sense to modify a PASM driver to handle 4/8 channels and this shouldn't be too difficult to do yourself perhaps. You probably need to bypass the LIS3DH's FIFO to prevent skewing. At full I2C bus speed you only have 2.5us between clocks so the channels could be read and written between hub and cog during START/STOP. Of course you could go much slower if you are not in a hurry and access the I2C directly from Spin. Is there a minimum update rate your system requires?
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-12 11:44
    I'm hoping to go as fast as possible. This is for measuring vehicle dynamics on a racetrack, so (hopefully 200Hz or so) acceleration data will be interleaved with 20Hz GPS data and processed later on a PC. I'm using I2C transceivers (PCA9600) that should be good to 1MHz or so, and it wouldn't surprise me if the LIS3DH could go faster than 400KHz, though adjustable speed would probably be good. I was hoping to use the FIFOs on the devices by sending a "start" command to the I2C broadcast address to have them start filling the FIFOs, and to restart the sampling at each run. This is for autocross, so each run will only be ~30-45 seconds - a long track is 2 minutes. I couldn't see any "trigger" command in the datasheet that could be broadcast, so I may just skip the FIFOs, interleave top/bottom data, and interpolate later.
  • RickInTexasRickInTexas Posts: 124
    edited 2013-06-12 19:12
    I'm wondering if I can connect all the SCK lines together.
    ...

    I'm hoping to go as fast as possible.

    I see that the LIS3DH supports SPI, so it would be certainly be fast, and perhaps you could clock them all from one line, sending them identical commands, etc. and then read each chips SPI out separately.

    I haven't worked through this but it sounds good in theory!

    What are you using for 20hz GPS?

    RickInTexas
  • RickInTexasRickInTexas Posts: 124
    edited 2013-06-12 19:12
    Duplicate post. Duplicate post.
  • SRLMSRLM Posts: 5,045
    edited 2013-06-12 21:27
    I'm hoping to go as fast as possible. This is for measuring vehicle dynamics on a racetrack, so (hopefully 200Hz or so) acceleration data will be interleaved with 20Hz GPS data and processed later on a PC. I'm using I2C transceivers (PCA9600) that should be good to 1MHz or so, and it wouldn't surprise me if the LIS3DH could go faster than 400KHz, though adjustable speed would probably be good. I was hoping to use the FIFOs on the devices by sending a "start" command to the I2C broadcast address to have them start filling the FIFOs, and to restart the sampling at each run. This is for autocross, so each run will only be ~30-45 seconds - a long track is 2 minutes. I couldn't see any "trigger" command in the datasheet that could be broadcast, so I may just skip the FIFOs, interleave top/bottom data, and interpolate later.

    I'm running my I2C bus at ~450kHz, and so far it's proven to be 100% reliable with 400kHz max rating devices. I've been able to get it faster than that, but so far haven't needed to.
    What are you using for 20hz GPS?

    I'm guessing the Venus GPS: https://www.sparkfun.com/products/11058
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-06-13 01:55
    Maybe not code for the LIS3DH, but for reading identical registers from multiple I2C busses?

    How about adding a i2c 8-channel switch (PCA9548A) that uses 2 prop-pins for 8 identical address devices? Its quite easy to use.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-13 17:20
    MacTuxLin wrote: »
    How about adding a i2c 8-channel switch (PCA9548A) that uses 2 prop-pins for 8 identical address devices? Its quite easy to use.
    That would break my timing requirements. I'm happy to use more pins to get tighter timing from the devices.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-13 20:06
    I see that the LIS3DH supports SPI, so it would be certainly be fast, and perhaps you could clock them all from one line, sending them identical commands, etc. and then read each chips SPI out separately.
    ...
    RickInTexas
    Well, first of all, I've already designed hardware around I2C using PCA9600 buffers. I'm considering a redesign to use SPI, but the data needs to run over 20+ feet of CAT5 cable, through the engine compartment of a car. Not sure how to transport SPI in a manner that's somewhat noise immune. I would like clock out, data out, data in 1, data in 2, and power/ground over one CAT5. Not sure how to transport that.
Sign In or Register to comment.