Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: Link 5 teensy 3.1 with 2.4 mhz I2C

  1. #1

    Link 5 teensy 3.1 with 2.4 mhz I2C

    I just noticed that teensy 3.1 supports I2C speed till 2.4 mhz.
    This could be a great solution for my project but i'm wondering if it will work.

    Let's say: i have 5 different pcbs equipped with teensy 3.1 and I want to link them in a daisy chain with I2C running at 2.4 mhz.

    The distance between the first and the last board is approxximately 2 meters.

    Lets say that the first board has got an ethernet module to send osc data to a computer.
    The second and third board will constantly poll the distance value from 12 hcsr04 ultrasonic range finders (each board) and the 4th board is an led controller to run 678 rgb leds (dmx controlled over osc)


    Will the system work without latency?

    Will I2C hang or become unstable like i experienced in another thread?

    Do i need to use cat5 cables between the boards?

    What pullup resistors should i use?

    (I don't have an oscilloscope; that's why i ask.)

    Any experiences?

  2. #2
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    I2C for 2m is iff'y. If you know what you're doing with respect to cable capacitance, grounding, RF-like transmission in this situation, you can likely make it work.
    Latency wouldn't be affected.

    Lacking a 'scope, I think you need to research and duplicate a solution that worked well, where "well" means the bit error rate was measured and was good (say, better than 1 in 10^6 or better, bit errors)

  3. #3
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    The combination of 2.4MHz over 2m and no availability of an Oscilloscope makes this guesswork.
    In my lighting systems use a Teensy 3.0 and 5 of my I2C controlled LED drivers over about 14ft of CAT5 cable at 1MHz

    That works because I use I2C bus extenders (PCA9600).

    I think this could be made work but would likely take some experimentation with the I2C bus frequency and you'd need a cheap oscilloscope so you can see at what frequency you get problems with signal integrity.

    Another approach could be to use the bus extenders ( I have a tested and bread board ready layout at OSH park) and run the bus at 1MHz ( spec limit for the PCA9600). Also, the Teensy 3.1 has two I2C busses and you could run these in parallel. When you lay out your boards I'd recommend using RJ45 sockets and CAT5 cable with plugs. This avoids wiring mistakes ;-)

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,176
    Usually RS485 is best for long wires. Teensy has Serail1.transmitterEnable() to automatically control the DE/RE pin on RS-485 chips, which should make this easier.

    Of course, this does mean adding a 8-pin RS485 chip to each Teensy, which is a bit more complex than just connecting all the SDA, SCL and GND pins, and adding 2 pullup resistors somewhere. But RS-485 gives you the ability to work with very long wires easily and reliably.

  5. #5
    Thank you for the help.

    I thought about rs485 but it takes to long for me to implement and the distance is not so significant to require it.


    I lack of a scope but...
    If i can afford something like the bus pirate; do you think it will be able to help me diagnose the bus at that speed?

  6. #6
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    I doubt that a system on 2m of CAT5 cable with 5 I2C devices on the bus will be able to run the I2C bus anywhere close to 2.4MHz. 400KHz probably, 600KHz maybe...

    If you want to stick with I2C then I'd really recommend using a bus buffer like the PCA9600. You'd need 5, one for each Teensy. It is FM+ compatible so can run at up to 1 MHz and more. I've actually tested it on 5m of Cat5 cable with 5 I2C devices at 1.5 MHz and signals still looked crisp on the oscilloscope. I was very hesitant the first time using it. In retrospect is is very easy to use.
    If you are spinning your own boards I can post an Eagle schematic and board that I know works.

    The image below shows the easiest configuration for the PCA9600 ( only one of the two i2c signals for clarity). The left side of it has a micro connected and on the right side there are two FM+ compatible devices that don't need the PCA9600 buffer. You'd need the left side for each Teensy. That only costs a little board space (the PCA9600 is available in TSSOP8 and that is tiny!!) and maybe $3 in components per Teensy.
    Click image for larger version. 

Name:	image.jpg 
Views:	775 
Size:	28.0 KB 
ID:	2586
    Last edited by Headroom; 08-23-2014 at 05:19 PM.

  7. #7
    Quote Originally Posted by Headroom View Post
    I doubt that a system on 2m of CAT5 cable with 5 I2C devices on the bus will be able to run the I2C bus anywhere close to 2.4MHz. 400KHz probably, 600KHz maybe...

    If you want to stick with I2C then I'd really recommend using a bus buffer like the PCA9600. You'd need 5, one for each Teensy. It is FM+ compatible so can run at up to 1 MHz and more. I've actually tested it on 5m of Cat5 cable with 5 I2C devices at 1.5 MHz and signals still looked crisp on the oscilloscope. I was very hesitant the first time using it. In retrospect is is very easy to use.
    If you are spinning your own boards I can post an Eagle schematic and board that I know works.

    The image below shows the easiest configuration for the PCA9600 ( only one of the two i2c signals for clarity). The left side of it has a micro connected and on the right side there are two FM+ compatible devices that don't need the PCA9600 buffer. You'd need the left side for each Teensy. That only costs a little board space (the PCA9600 is available in TSSOP8 and that is tiny!!) and maybe $3 in components per Teensy.
    Click image for larger version. 

Name:	image.jpg 
Views:	775 
Size:	28.0 KB 
ID:	2586

    Hi yeah that would help.


    what do you mean with spinning your own boards?

    I'm designing my own custom boards if it is what you are meaning....

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,176
    Quote Originally Posted by esapode688 View Post
    I lack of a scope but...
    If i can afford something like the bus pirate; do you think it will be able to help me diagnose the bus at that speed?
    No, the bus pirate or other logic analyzers won't show you the analog problems.

    Even the most expensive Agilent or Lecroy oscilloscope won't magically make things run faster. They can show you how terrible the waveforms are, so you'll be able to see how marginal things look when it's "working" at the upper range of whatever data rate your cable can support.

    Even without any scope, you can at least get it working at low speed (a critically important first step), then try fiddling with higher speeds and lower value pullup resistors.

  9. #9
    Senior Member
    Join Date
    Jan 2013
    Posts
    966

    Eagle I2C bus buffer PCA9600

    Attached are the zipped Eagle files for a little breadboard able I2C bus buffer. This runs the Teensy at 3.3V and the buffered I2C bus at 5V to get a good balance between noise-to-signal ratio and signal rise times. This is recommended either in the spec sheet for the PCA9600 or in an Application Note for the PCA9600 (don't exactly remember where ;-)
    Attached Files Attached Files
    Last edited by Headroom; 08-24-2014 at 02:16 PM.

  10. #10
    Quote Originally Posted by PaulStoffregen View Post

    Even without any scope, you can at least get it working at low speed (a critically important first step), then try fiddling with higher speeds and lower value pullup resistors.
    Thanks Paul; I have a similar system working at 400khz over 1.5 meters. And its Actually Working quite well

    Quote Originally Posted by Headroom View Post
    Attached are the zipped Eagle files for a little breadboard able I2C bus buffer. This runs the Teensy at 3.3V and the buffered I2C bus at 5V to get a good balance between noise-to-signal ratio and signal rise times. This is recommended either in the spec sheet for the PCA9600 or in an Application Note for the PCA9600 (don't exactly remember where ;-)
    Thanks a lot; I'll integrate them in my design and I give you credit of Course


    Would it actually help if I reduce the link lenght to 40 cm by using the second I2C port on each teensy to talk to the next one?

  11. #11
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    From a signal standpoint quality standpoint, yes.
    The software would be a lot more complicated though as you'd loose the significant advantage of a bus system.

Tags for this Thread

Posting Permissions

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