MMA7455 issue with long data & clock signal wires
dferneyh
Posts: 11
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.
Any recommendations for line drivers or whatever?
.....Dave.
Comments
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.
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.
To clarify Mike's statement, connect only one end of the wire to ground. Leave the other end disconnected.
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.
-Phil
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.
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.
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
-Phil
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.
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
He also says this in a code paste ?
[" // start the SPI library
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV128)"];
It's got me, then. But he's also using only two pins. So ... maybe the OP can come back and clarify?
-Phil
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
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.
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.
-Phil
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
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
I'll give that a try, timing tbd as my day job allows.