Shop OBEX P1 Docs P2 Docs Learn Events
Completely baffled — Parallax Forums

Completely baffled

Paul MPaul M Posts: 95
edited 2011-04-07 02:10 in Propeller 1
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?

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-04-06 06:29
    I've had the same thing happen where an I2C devices works on one system and not another. Then I start troubleshooting with my scope and blam signal.

    Check out this I2C reference.
    http://www.i2c-bus.org/i2c-primer/
  • Paul MPaul M Posts: 95
    edited 2011-04-06 07:31
    Thanks for the link Mike.

    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??
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-04-06 08:54
    Paul:
    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.
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2011-04-06 09:01
    Check the quality of the ground and power supply. Sometimes the scope ground will introduce some extra stability on that in a breadboard environment.
    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-
  • Mike GMike G Posts: 2,702
    edited 2011-04-06 09:59
    Do you have a common ground rail? The Propeller ground, power ground, and I2C device ground are all connected together?
  • kwinnkwinn Posts: 8,697
    edited 2011-04-06 16:17
    This may also be a bad connection (cold/no solder joint, bent IC pin in a socket, cracked feedthru, etc) somewhere in the area you are connecting the wire/scope probe. Connect the scope probe, the signal is fine, and the circuit works. This type of problem has taken up many hours of troubleshooting over the years. Try using a toothpick or other non conductive probe in the same area. If it starts working then a bad connection is most likely the problem.
  • Paul MPaul M Posts: 95
    edited 2011-04-07 01:32
    Thanks for all the suggestions.
    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.
  • Paul MPaul M Posts: 95
    edited 2011-04-07 02:10
    I think I've discovered the problem.
    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.
Sign In or Register to comment.