Shop OBEX P1 Docs P2 Docs Learn Events
MMA7455 issue with long data & clock signal wires — Parallax Forums

MMA7455 issue with long data & clock signal wires

I have a Parallax MMA7455 module connected to an Arduino uno and it works fine with jumper leads 6 inches long. For my project I need to mount the MMA7455 on a moving solar panel which requires about 6 feet of extension wires to the base Arduino. Problem is that when using long wires for Clk & Data signals I get bogus data.
Any recommendations for line drivers or whatever?

.....Dave.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2015-10-10 18:54
    This should work over 6 feet of wire. Use a good quality Ethernet cable which contains 4 twisted pairs. Connect one of each pair to ground. Use the other of two pairs for SCL and SDA. You could use the other of another pair for power for the MMA7455 if you want. It sounds like you're using I2C mode for the MMA7455. You could use the last cable pair for CS and use SPI mode instead and slow it down by using a software ("bit banging") driver. If you were using a Propeller, it would be easy to slow down either mode since all the drivers are software.

    Ideally you'd only connect the ground wire at one end of each of the signal (SCL, SDA, CS) pairs, probably the Uno end. The last (possibly power) pair would have the ground connected at both ends. This is to avoid ground loops in the signal pairs ... probably overkill with a 6 foot cable unless this is physically close to other cables carrying noisy power (like for motors or the solar panel controller).

    Along those lines ... keep the signal cables physically separate from cables carrying power or noisy power or signals.
  • Mike,
    Thanks for the advice, I'll try twisted pair like you suggest.

    I'm using SPI and I did a little research, I'm guessing that I have propagation delay. I have some sample data below using the standard 7455 demo:

    With 6" jumpers: (looking good)
    X: = 7 Y: = -8 Z: = 62
    X: = 9 Y: = -8 Z: = 62
    X: = 8 Y: = -8 Z: = 62
    X: = 10 Y: = -9 Z: = 61
    X: = 9 Y: = -8 Z: = 62
    X: = 9 Y: = -9 Z: = 60
    X: = 9 Y: = -9 Z: = 61
    X: = 9 Y: = -9 Z: = 63

    With 3' wire extension: (looking bad)
    X: = 3 Y: = 18 Z: = 11
    X: = 14 Y: = 29 Z: = 22
    X: = 25 Y: = 40 Z: = 33
    X: = 36 Y: = 51 Z: = 44
    X: = 47 Y: = 62 Z: = 55
    X: = 58 Y: = 73 Z: = 66
    X: = 69 Y: = 84 Z: = 77
    X: = 80 Y: = 95 Z: = 88
    X: = 91 Y: = 106 Z: = 99
    X: = 102 Y: = 117 Z: = 110
    X: = 113 Y: = -128 Z: = 121
    X: = 124 Y: = -117 Z: = -124

    I tied slowing down the SPI clock with the following code addition to the 7455demo code, but I was still seeing the same issue:
    #include <Wire.h> //Include the Wire library
    #include <MMA_7455.h> //Include the MMA_7455 library
    #include <SPI.h>
    MMA_7455 accel = MMA_7455(); // Make MMA7455 object
    char xVal, yVal, zVal; // Return value variables
    void setup() {
    Serial.begin(9600);
    // Use the Serial Monitor window at 9600 baud
    // start the SPI library
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV128);
    etc........

    So next, I'll try the twisted pair & report back.

    .....Dave.


  • Mike Green wrote: »
    Connect one of each pair to ground.

    To clarify Mike's statement, connect only one end of the wire to ground. Leave the other end disconnected.

  • OK tried the twisted pair option - no success. And, correction from my previous post - I am using IC2, CLK & DATA to arduino pins A5 & A4.

    Setup:
    CAT5 socket connected at MMA7455, orange to CLK, blue to DATA. >> 6' regular CAT5 cable >>CAT 5 socket at arduino, orange to A5, blue to A4, with orange/white & blue/white connected to GND.
  • If you're using I2C, put the SCL pull-up (4.7K) on the slave end. On the SDA line, put 10K pull-ups on both ends.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2015-10-10 22:04
    I don't have any other general suggestions for you. I know that the Propeller can do I2C or SPI over a 6' or longer CAT5 cable. I don't know enough about the I/O pins of the Uno or the I2C or SPI peripheral controllers used internally. The Propeller does it all in software so the timing can be finely tuned and the I/O pins are both robust and have good drive capability.

    Here's a "white paper" on I2C bus buffering from Linear. I don't know how useful it will be, but have a look at it.
  • jmgjmg Posts: 15,175
    dferneyh wrote: »
    ...

    I'm using SPI and I did a little research, I'm guessing that I have propagation delay. I have some sample data below using the standard 7455 demo:

    With 6" jumpers: (looking good)
    X: = 7 Y: = -8 Z: = 62
    X: = 9 Y: = -8 Z: = 62
    X: = 8 Y: = -8 Z: = 62
    X: = 10 Y: = -9 Z: = 61
    X: = 9 Y: = -8 Z: = 62
    X: = 9 Y: = -9 Z: = 60
    X: = 9 Y: = -9 Z: = 61
    X: = 9 Y: = -9 Z: = 63

    With 3' wire extension: (looking bad)
    X: = 3 Y: = 18 Z: = 11
    X: = 14 Y: = 29 Z: = 22
    X: = 25 Y: = 40 Z: = 33
    X: = 36 Y: = 51 Z: = 44
    X: = 47 Y: = 62 Z: = 55
    X: = 58 Y: = 73 Z: = 66
    X: = 69 Y: = 84 Z: = 77
    X: = 80 Y: = 95 Z: = 88
    X: = 91 Y: = 106 Z: = 99
    X: = 102 Y: = 117 Z: = 110
    X: = 113 Y: = -128 Z: = 121
    X: = 124 Y: = -117 Z: = -124

    I tied slowing down the SPI clock ...

    Edge issues are not solved by slower clock rates.

    If you have 'good'; and 'bad' examples, try to work backwards to see what needs to happen to turn good into bad,
    The numbers above seem the be slowly ramping in bad and stable in good which is a very strange failure mode ?

    Are those the same test conditions ?

    Another test is to write then read back to non-analog-result registers (ie control registers that are R/W that you know are not going to move) - that confirms the link integrity, and can give clues to the failure mode.
  • jmg,

    test conditions were identical except for the length/type of wire used for CLK & DATA. The "good" result uses ~< 6" lengths of single strand insulated copper wire. Bad results are for 3' o 6' either with regular wires or CAT 5 cable. Interestingly, the bad results are consistently the same. That is each successive line of results increments the X, Y & Z values by exactly 11. That can't be a co-incidence. Also noted that the first z reading is 11.

    So conclusions:
    1. it is a systematic failure.
    2. at some point between 6" and 3' length wires the failure starts to happen.

    ....Dave
  • Where are your pull-up resistors, and what values are they? (See my post above.)

    -Phil
  • jmgjmg Posts: 15,175
    edited 2015-10-11 07:49
    dferneyh wrote: »
    That is each successive line of results increments the X, Y & Z values by exactly 11. That can't be a co-incidence. Also noted that the first z reading is 11.
    INC by 11 is simply strange, and has to be some secondary effect like triggering a self test mode, but the self test they mention seems to shift a fixed values on Z only ?
    More usual cable-issue effects are things like double-clocking, that shift data left or right


    That part looks to have 32 registers, try just reading and dumping all of them in short and long cable cases.

    Also try 100 ohms and 100 pF series at Sensor end to reduce clock ringing.

    Have you checked the SPI cock phase ?
    Outgoing data changes on CLK =\_ and
    incoming data is sampled on CLK _/= ?
    CS is high for a reasonable time ? ( eg Try CSH = CSL, then shorten CSH )
    Check Vcc at remote end and supply decoupling.

    try a 40106 schmitt on CS,CK lines (2 inverters in series to keep same polarity)- they are nice and slow at 3v and will ignore short cable ringing.
  • jmg,

    He's using I2C, not SPI. See his post above:

    http://forums.parallax.com/discussion/comment/1348400/#Comment_1348400

    (He calls it "IC2", but I think his meaning is clear.)

    -Phil
  • jmgjmg Posts: 15,175
    edited 2015-10-11 17:46
    jmg,
    He's using I2C, not SPI. ...
    (He calls it "IC2", but I think his meaning is clear.)
    -Phil

    He also says this in a code paste ?
    [" // start the SPI library
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV128)"];

  • jmg,

    It's got me, then. But he's also using only two pins. So ... maybe the OP can come back and clarify?

    -Phil
  • Phil & jmg,

    attached jpg shows schematic of what I currently have. Because I'm using IC2, I am not using the CS. The sample code from the Parallax/MMA7455 comes with a MMA7455 library - its IC2 based. Would SPI give me a better range than IC2? I found some SPI code samples at http://playground.arduino.cc/Main/MMA7455, but its much much more complex - it will take me some time to come up-to-speed.

    I will try what jmg suggests but I'll have to go get some parts.

    ...Dave
    700 x 500 - 26K
  • jmgjmg Posts: 15,175
    edited 2015-10-11 22:27
    dferneyh wrote: »
    attached jpg shows schematic of what I currently have.

    I don't see any decoupling capacitors - are they on the module ?
    You can lower i2c pullups to as low as 470 or even 330 ohms in most cases, check the Vol/Iol specs on the devices.
    dferneyh wrote: »
    Would SPI give me a better range than IC2? ...

    I will try what jmg suggests but I'll have to go get some parts.
    i2c should be ok to ~6 feet, and the suggestions I gave were for SPI, which is a little easier to buffer than i2c.

    You could still try a Schmitt buffer on SCL, (as I doubt that uses clock stretching) but lower value pullups may be enough.

  • If the 5V is being supplied over the long cable as your schematic shows, I'd add a tantalum or electrolytic filter cap (> 10uF) in addition to the 0.1uF ceramic decoupling cap recommended by jmg. And as jmg suggests, lower-valued pull-ups are good, as long as the driving circuitry can handle them.

    -Phil
  • You have essentially created a current loop transmission line for the DATA line with a 10k resistor on either end, but the CLK line is open ended with a resistor only at one end..... To the MMA7455 it sees the CLK and DATA both as inputs, it doesn't care if it's data or clk.. still an input to the MMA7455. You might try a termination resistor on both ends of equal value so that the system remains balanced .... this helps to minimize antenna effects that can build up with open ended connections.
  • I did 3 experiments:
    1. Using 6' twisted pair CAT5 cable for CLK & DATA with their twin wires grounded at the arduino end. I used 1k pull up resistors at each end of CLK & DATA. I used the series 100pF/100ohm with CLK. I used 0.1uF ceramic & 10uF tant caps on the MMA7455 power. I didn't have a 40106, but tried a 741 op amp configured as non-inverting unity gain on the clock line. Pull down 1k on CS. No success.
    2. I went back to the circuit that worked with 6" jumper wires, it still worked. I tried different lengths of jumper wire for DATA & CLK, keeping the +- power wires at 6". I got a 24" wire to work, where 28" would not. When I lengthened the +-power wires to 24", it stopped working. Finally, the best I could get with jumper wires was 12" for +,-,CLK & DATA. Note: no pull-ups, caps or anything added other than simple jumpers.
    3. If I removed the DATA wire, I get the exact same fail result that I was getting with the longer wire lengths.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-10-12 05:03
    I think that in your experiment #1 you tried to make too many changes at once. Try repeating it, but eliminate the 741 and the series 100pF/100ohm. Also, for I2C operation, the MMA7455 datasheet (Fig. 15, p. 19) shows that /CS should be connected to Vdd not Gnd. So just leave it disconnected, since it's already pulled up to Vdd in the Parallax module.

    -Phil
  • jmgjmg Posts: 15,175
    dferneyh wrote: »
    3. If I removed the DATA wire, I get the exact same fail result that I was getting with the longer wire lengths.
    Do you mean an open SDA line, gives the same failures as a longer wire ? ( the +11 effect ?)

    I see the Parallax Module has Schottky diodes and 2k2 pullups, on SCL and CS, and a TI i2c buffer ? on the SDA line.

    If you can use other than CAT5, try 20w ribbon cable as
    something like
    G.V.G.V.G.SDA.G.V.G.V.G.V.G.G.SCL.G.V.G.V.G
  • Jmg & PhiPi,

    I'll give that a try, timing tbd as my day job allows.
Sign In or Register to comment.