Completely baffled
Paul M
Posts: 95
I have an I2C compass module connected to a prop - Memsic MMC2120MG on a module from Sure Electronics. As I couldn't get it to work straight away I connected a scope to the SCL and SDA lines. I soon discovered a bug and got everything working.
Now the strange bit - I disconnected the scope probes and it stopped working.
It's something to do with just the SCL line. Connecting a scope probe, DVM probe or even just a length of unterminated wire will get it working!
There are 4k7pullups on the module and adding another 4k7 in parallel does not help. However a 2k2 does work.
Any explanations?
Now the strange bit - I disconnected the scope probes and it stopped working.
It's something to do with just the SCL line. Connecting a scope probe, DVM probe or even just a length of unterminated wire will get it working!
There are 4k7pullups on the module and adding another 4k7 in parallel does not help. However a 2k2 does work.
Any explanations?
Comments
Check out this I2C reference.
http://www.i2c-bus.org/i2c-primer/
I didn't mention that my test is breadboarded and I know these layouts can sometimes cause problems. The odd thing is that adding an unterminated piece of wire or even a scope not plugged in gets things working. I would have thought that this would be adding capacitance to the lines and this should makes things worse.
I have redone the breadboard layout and discovered:
1. adding 100R in series with the SCL wire works
2. that if I make the SCL wire (from the prop to the module) about 10 times longer than the SDA wire or, vice versa, it works also (no 100R this time)
3. if the 'long' wire is just too short for it to work, then grabbing the wire gets things going again!
From what I have read, increasing the series resistance and/or the capacitance should degrade the signals??
It sounds to me like there is to much noise on the SCL line, as both of your fixes (increasing capacitance, and adding resistance to the existing capacitance) would have the effect of filtering the noise a little. Perhaps your device is way to sensitive to noise. I actually put capacitors on the outputs of my resistor DACs for VGA when using a breadboard, because it cleans it up just enough.
Make sure your bypass cap is VERY close to the power pin on the i2c device. Might also check the code provided me yesterday by JonnyMac - works well and streaches the clock to wait on an ACK.
Jim-
The setup I have (for testing and development) is a <prop breakout board>to<ribbon cable(100mm)>to<breadboard>to<>breadboard wires(50mm)>to<compass chip on pcb>
I am actually using JonnyMac's code "jm_i2c.spin" from the Obex - I used it previously for anothe I2C device - very useful for low level debugging
In answer to the suggestions:
1. it is definitely not a faulty connection problem as I have changed everyrhing on the breadboard layout.
2. ground rails are all common and correct. Power supply is bypassed etc.
3. although I stated before that I thought it was related only to SCL I have found that it will work if I put the 100R series resistor in either the SCL or SDA line(haven't tried one in each line yet)
4. connecting just the scope probe to SCL without the ground wire connected and, without the probe actually connected to the scope is all that is needed.
5. connecting just the scope probe to SDA doesn't work but if the scope ground wire is added (still not connected to scope) hey presto!
6. just an unterminated length of wire (300mm) on SCL works but not if on SDA
In my (relatively limited) experience, breadboard layouts, the ensuing rats nest and long pieces of wire usually cause problems by introducing noise not the other way round.
I found that using non adjacent pins for the SDA and SCL lines fixes the problem.
I then substituted bread board wires (plugged straight into the pcb socket on my breakout board) for the ribbon cable. Now I can use any pair of pins.
I guess it must be to do with the interwire capacitance of the ribbon cable - a bit surprising since the data rate is not particularly high.
I guess I can now be reasonably sure it will work when the module is plugged into a proper pcb socket.
Thanks again for all the suggestions.