10
\$\begingroup\$

I am trying to observe I2C lines coming from an Arduino using a cheap oscilloscope (6022BE-25MHz.)

The signals I see do not resemble a square wave - it looks more like a sawtooth wave.

Does anyone know what could cause this?

enter image description here

  • Is it the scope that is the problem?
  • Is it related to the I2C lines?
\$\endgroup\$
6
  • 3
    \$\begingroup\$ did you forget to use pull-up resistors? \$\endgroup\$ Oct 23 at 20:58
  • 2
    \$\begingroup\$ Show us your circuit schematic -- it does look like it needs a stronger pull-up,attention paid to reducing the capacitance on the lines, or a slower clock rate (if you're doing something like trying to make it work over a long cable run, which induces lots of capacitance). \$\endgroup\$
    – TimWescott
    Oct 23 at 21:20
  • 2
    \$\begingroup\$ It's related to your choice of I2C pullup resistors, and you haven't told us that, in conjunction with the I2C wiring capacitance (inc. the scope probe) \$\endgroup\$ Oct 23 at 21:25
  • \$\begingroup\$ Thanks for quick replies. It is just two Arduino Uno's talking with each other using SDA SCL lines. \$\endgroup\$ Oct 23 at 21:38
  • 1
    \$\begingroup\$ If you take a capacitor and charge it via a resistor, have a look at the voltage across the capacitor on an oscilloscope. You will see that the voltage rises in a curve - and the same shape of curve will be seen if you discharge the capacitor via a resistor. The Wikipedia article RC time constant might be of interest to you. \$\endgroup\$ Oct 24 at 17:05
24
\$\begingroup\$

I2C bus clock and data pins are driven in open-drain (open-collector) mode.

So it will not be a square wave.

The falling edge will be a sharp step, but the rising edge will be a shark-fin like RC charge waveform.

So what you see is normal, but the waveform rise time may be too slow.

You should investigate if the bus is within specs for all chips, but it does look like the rise time could be somewhat faster so you may require stronger pull-ups.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ I like this better. +1. You address not only what Peter did but also the idea that it may not just be a "paste in smaller pullup" but instead that the bus may not itself be within spec. The addition is important. \$\endgroup\$
    – jonk
    Oct 23 at 21:25
  • 3
    \$\begingroup\$ Adding 10k to both SDA and SCL lines worked charmingly. Very simple and logical solution. Good explanation. \$\endgroup\$ Oct 23 at 21:43
  • 1
    \$\begingroup\$ @mozcelikors I2C is an industry standard. I highly suggest reading documentation of the protocol itself before using it. There is more to it than merely having pull-ups on SDA and SCL. It will help you immensely to understand how it actually works. \$\endgroup\$ Oct 25 at 14:59
  • \$\begingroup\$ @Kubahasn'tforgottenMonica Do you have a good link that explains the protocol ? I have read several docs already but might still be missing a lot. \$\endgroup\$ Nov 1 at 5:38
9
\$\begingroup\$

You require a stronger (lower value) pull-up resistor on the I2C line to charge any cpacitance on the line more quickly.

Whatever is driving the I2C line can pull the line Low very strongly, but does not drive the line High, depending on a pull-up resistor to take it High.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ @mozcelikors Yes. The Arduino probably has a weak internal pullup (I have no experience with Arduinos but this is common and you can check the datasheet for your part). But it's too weak. Try something like a 4.7k pullup on SCL and SDA. You can play with higher or lower values until you get a rise time you're happy with. Lower values = stronger pull = faster rise = higher power consumption / current. \$\endgroup\$
    – TypeIA
    Oct 23 at 21:49
  • 2
    \$\begingroup\$ @mozcelikors By the way, many MC datasheets don't list the exact value of the weak internal pullups/downs because they aren't exact values at all, the process/manufacturing variance on silicon is very high. \$\endgroup\$
    – TypeIA
    Oct 23 at 21:52
  • \$\begingroup\$ A Lower frequency is also an option. \$\endgroup\$ Oct 25 at 19:29
5
\$\begingroup\$

If your oscilloscope probe has 10x mode, try enabling it. You may also need to adjust 10x compensation trimmer if you haven't done that before.

With typical oscilloscope probes, 1x mode has about 100 pF capacitance while 10x mode has about 15 pF. A 100 pF capacitance connected to I2C is similar to about 1 meter of extra cable, which slows down the rise times.

\$\endgroup\$
0
2
\$\begingroup\$

The oscilloscope traces show that SCL and SDA signals have a time constant that's way beyond what'd be required at the frequency your run the bus at. I'm seeing approximately a 20us time constant.

The circuit as you describe it should have a capacitance between SCL/SDA and ground less than 100pF. Together with I2C's recommended pull up on the order of 10kOhm, we should be seeing a time constant of 1E-10F * 1E4Ohm = 1E-6s = 1us.

But we're seeing 20us time constant (roughly) instead. So, you're not telling us something. Either you have connected ~2nF of capacitance between each line and a low impedance node (either power supply rail for example), or you don't have the 10kOhm pull-ups in place.

If you didn't stick extra capacitors there, it looks like you have about 200kOhm-1MOhm pull-up resistance - one to two orders of magnitude too high, depending on what the parasitic capacitance is on those lines.

Such pull-up resistance would be in the range of weak pull-ups on microcontroller GPIO pins. So it looks like you're trying to run I2C with nothing but weak pull-ups in the microcontroller. That's not enough. Connect 10-15kOhm between SCL and I/O supply voltage, and similarly for SDA.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.