I2c troubleshooting

79 views
Skip to first unread message

Pito Salas

unread,
Jul 8, 2024, 11:11:06 AM (10 days ago) Jul 8
to hbrob...@googlegroups.com
Hi all,

I have a situation that maybe you have some insights on. My robot is driven by a teensy 4.0. The i2c pins are connected via a “Qwik” connector (I think that’s what it's called.) to an i2c board. 

I have a short program which tries each i2c address and looks for one that returns 0 to Wire.endTransmission() which indicates that something is detected at that address. If the same call returns 4 that means that there’s some kind of hardware error. 

#include <Wire.h>
#include <Arduino.h>
#include <core_pins.h>


void setup()
{
Wire.begin();

Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nBranbot Test Suite");
}


void loop()
{
byte error, address;
int nDevices;

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();

if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");

nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan

}


And here is what a “4” is supposed to mean:

Screenshot 2024-07-08 at 11.06.29 AM.png(From https://www.arduino.cc/reference/en/language/functions/communication/wire/endtransmission/)

With that context, I am seeing the following:

- without anything connected to the i2c bus, the script simply checks all the addresses, sees no errors or devices, and reports “no i2c devices”

- with an i2c cable connecting to an i2c device the script reports an error on every single address. I’ve tried two different devices as well as different cables.

I measured the voltage on the i2c connector and it is 3.3V (for the red and black power wires.) 

In some places I see mention of a pull up resistor but I am pretty sure I have not needed that in the past.

Any theory/suggestions?

Thanks!

PIto

Sergei Grichine

unread,
Jul 8, 2024, 11:31:36 AM (10 days ago) Jul 8
to hbrob...@googlegroups.com
Hi Pito,

I had a good run with Teensy 4.0 last month, emulating PCA9685 with I2C. Here are my suggestions:

1. you absolutely need pull-up resistors for I2C SDA and SCL. Put 2.2 to 6.8 K to the 3.3 V line. Your Qwik bus isn't 5V, btw, no smoke from Teensy? 

2. Use a more advanced I2C library - https://github.com/Richard-Gemmell/teensy4_i2c  - it has a "Wire" wrapper if you don't want to do anything unusual.


// Teensy 4.0 Wire:  SDA: 18 SCL: 19
//            Wire1: SDA: 17 SCL: 16


If you have a Raspberry Pi nearby, use "i2cdetect -y 1" for a quick test.

--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/6EE08C87-E9E4-4ACD-B128-FB5C1BCF1B95%40brandeis.edu.


--
Best Regards,
-- Sergei

Mark Womack

unread,
Jul 8, 2024, 11:36:22 AM (10 days ago) Jul 8
to hbrob...@googlegroups.com
I echo Sergei's suggestion for pull-up resistors in the SDA and SCL lines. I've only ever gotten I2C to work with the pull-up resistors.

-Mark

Dan

unread,
Jul 8, 2024, 11:39:21 AM (10 days ago) Jul 8
to 'Pito Salas' via HomeBrew Robotics Club
The I2C SCL and SDA lines are open-drain/open-collector design. This means that if you do not put a pullup on the lines then they will either float high or be slightly pulled up by the master's weak pullup on its I2C pins. With no device on the line they may appear high during a bus transaction. Therefor no error may happen and the master will see no devices. If you then put a device on without the correct pull-up that device will pull the lines low. That will cause a bus error.

The correct impedance needs to be calculated to determine the correct pullup resistor. If you do not know how to do this you could try to put 10k resistors on the SDA and SCL lines to VDD. 

WARNING: Be sure both the master (your teensy) and the slave device work on the same voltage. If they do not you will need a voltage translator.

Also note that if there is some incorrect pullup on the lines then the rise edge will not be vertical and just slope upwards causing a bus error.  You should use an oscilloscope to look at the lines. Or at least use a logic analyzer to view the signal. If you have neither and you are just hacking around try lowering the data rate to 100k. In fact in the past I have lowered the rate even lower to get a response from incorrectly calculated  pullup. resistors.



Sergei Grichine

unread,
Jul 8, 2024, 11:50:26 AM (10 days ago) Jul 8
to hbrob...@googlegroups.com
In some cases a Wire/I2c library might initialize the SCL/SDA pins with PULLUP flag. The problem is that 10K built-in microcontroller pull-ups are not enough for longer lines and multiple devices. 

Some devices come with 10K pull-ups already, so even if you have five of them the resulting pull-up resistance will be a very reasonable 2 K.

I always use ~4.7...6.8 K pull-ups, just as a matter of good practice.

And always make sure some device doesn't introduce 5V VCC or 5V logic levels on a 3.3 V bus! MPU9250, for example, has a 5V/3V jumper which you need to solder for 3.3V operation.

Pito Salas

unread,
Jul 8, 2024, 12:05:53 PM (10 days ago) Jul 8
to hbrob...@googlegroups.com, Timothy Hebert
Thanks everyone! In response to all the points:

I mentioned that I tried two different i2c devices separately and each showed the same issue. The boards are the Adafruit 9250 IMU and the other is the Adafruit LED driver . They both mention an “internal pull up resistor of 100”. But it’s outside of my expertise whether that is sufficient or not. 

Note also that I measured 3.3V on the i2c.

There has been no smoke and the Teensy appears to be working normally. I can upload new firmware without errors etc. etc.

With that new info, the consensus is that I need to add pull-up resistors. And that my partner in crime who knows the right end of a soldering iron, will be able to follow your hints here to put them on?

Thanks

Pito




<Screenshot 2024-07-08 at 11.06.29 AM.png>(From https://www.arduino.cc/reference/en/language/functions/communication/wire/endtransmission/)

With that context, I am seeing the following:

- without anything connected to the i2c bus, the script simply checks all the addresses, sees no errors or devices, and reports “no i2c devices”

- with an i2c cable connecting to an i2c device the script reports an error on every single address. I’ve tried two different devices as well as different cables.

I measured the voltage on the i2c connector and it is 3.3V (for the red and black power wires.) 

In some places I see mention of a pull up resistor but I am pretty sure I have not needed that in the past.

Any theory/suggestions?

Thanks!

PIto


-- 
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/6EE08C87-E9E4-4ACD-B128-FB5C1BCF1B95%40brandeis.edu.

-- 
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/122561491.21658.1720453154388%40mail.yahoo.com.


-- 
Best Regards,
-- Sergei

-- 
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.

David Hough

unread,
Jul 8, 2024, 12:20:28 PM (10 days ago) Jul 8
to hbrob...@googlegroups.com
Most people figure out which is the right end of a soldering iron within
two attempts.

On 08/07/2024 09:05, Pito Salas wrote:
> Thanks everyone! In response to all the points:
>
> I mentioned that I tried two different i2c devices separately and each showed the same issue. The boards are the Adafruit 9250 IMU <https://www.adafruit.com/product/4554> and the other is the Adafruit LED driver <https://www.adafruit.com/product/4886> . They both mention an “internal pull up resistor of 100”. But it’s outside of my expertise whether that is sufficient or not.

Pito Salas

unread,
Jul 8, 2024, 12:21:39 PM (10 days ago) Jul 8
to hbrob...@googlegroups.com
Only once they figure out how to turn it on :)

Marco Walther

unread,
Jul 8, 2024, 12:35:42 PM (10 days ago) Jul 8
to hbrob...@googlegroups.com, Pito Salas, Timothy Hebert
On 7/8/24 09:05, Pito Salas wrote:
> Thanks everyone! In response to all the points:
>
> I mentioned that I tried two different i2c devices separately and each
> showed the same issue. The boards are the Adafruit 9250 IMU
> <https://www.adafruit.com/product/4554> and the other is the Adafruit
> LED driver <https://www.adafruit.com/product/4886> . They both mention
> an “internal pull up resistor of 100”. But it’s outside of my expertise
> whether that is sufficient or not.
>
> Note also that I measured 3.3V on the i2c.
>
> There has been no smoke and the Teensy appears to be working normally. I
> can upload new firmware without errors etc. etc.
>
> With that new info, the consensus is that I need to add pull-up
> resistors. And that my partner in crime who knows the right end of a
> soldering iron, will be able to follow your hints here to put them on?

It looks like at least the https://www.adafruit.com/product/4554 has 10k
pull-up's (see attached screen shot for the tutorial). So, there should
be no need for more? And with the connectors, it would be very hard to
reverse the pins?!

-- Marco
> <mailto:hbrobotics+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hbrobotics/467AC027-9FCC-4597-A027-3B7798BED487%40gmail.com <https://groups.google.com/d/msgid/hbrobotics/467AC027-9FCC-4597-A027-3B7798BED487%40gmail.com?utm_medium=email&utm_source=footer>.
Untitled.png

Michael Wimble

unread,
Jul 8, 2024, 12:47:04 PM (10 days ago) Jul 8
to hbrob...@googlegroups.com
Just to add to the mix, my teensy 4.1 with foot long, shielded cables needed 3.3k resistors for good wave shapes driving 8 devices.

> On Jul 8, 2024, at 9:35 AM, Marco Walther <marc...@gmail.com> wrote:
> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/677eaee0-96db-49ec-9699-4113e7455017%40gmail.com.
> <Untitled.png>

Chris Albertson

unread,
Jul 8, 2024, 12:50:03 PM (10 days ago) Jul 8
to hbrob...@googlegroups.com
If in the past you did not need a pull-up resister, it was because the resister was already installed in the I2C device.     Sometime they had built-in resisters but the problem with that is if you have two devices then you have two resisters, so they usualy have a way to disable the built-in resister, even if that is to unsolder it.   You need ONE resister.

There is also the potential problem of 5 volts vs 3.3 volts.  The Teensy is 3.3 the I2c device must be the same, or you need to level shift the signal

<Screenshot 2024-07-08 at 11.06.29 AM.png>(From https://www.arduino.cc/reference/en/language/functions/communication/wire/endtransmission/)

With that context, I am seeing the following:

- without anything connected to the i2c bus, the script simply checks all the addresses, sees no errors or devices, and reports “no i2c devices”

- with an i2c cable connecting to an i2c device the script reports an error on every single address. I’ve tried two different devices as well as different cables.

I measured the voltage on the i2c connector and it is 3.3V (for the red and black power wires.) 

In some places I see mention of a pull up resistor but I am pretty sure I have not needed that in the past.

Any theory/suggestions?

Thanks!

PIto


--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/6EE08C87-E9E4-4ACD-B128-FB5C1BCF1B95%40brandeis.edu.


--
Best Regards,
-- Sergei

--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.

Pito Salas

unread,
Jul 8, 2024, 3:51:33 PM (9 days ago) Jul 8
to hbrob...@googlegroups.com
Marco (or others):

Do you have an arduino sketch that looks for working i2c devices? I have one (which was included) but I wonder if I need some additional lines to initialize the i2c ports. I can put one together myself but better if I get one that is known to work from you if you have one. As simple as possible without dependencies would be best.

Pito

> On Jul 8, 2024, at 12:49 PM, Chris Albertson <alberts...@gmail.com> wrote:
>
> If in the past you did not need a pull-up resister, it was because the resister was already installed in the I2C device. Sometime they had built-in resisters but the problem with that is if you have two devices then you have two resisters, so they usualy have a way to disable the built-in resister, even if that is to unsolder it. You need ONE resister.
>
> There is also the potential problem of 5 volts vs 3.3 volts. The Teensy is 3.3 the I2c device must be the same, or you need to level shift the signal
>
>> On Jul 8, 2024, at 8:27 AM, Sergei Grichine <vital...@gmail.com> wrote:
>>
>> Hi Pito,
>>
>> I had a good run with Teensy 4.0 last month, emulating PCA9685 with I2C. Here are my suggestions:
>>
>> 1. you absolutely need pull-up resistors for I2C SDA and SCL. Put 2.2 to 6.8 K to the 3.3 V line. Your Qwik bus isn't 5V, btw, no smoke from Teensy?
>>
>> 2. Use a more advanced I2C library - https://github.com/Richard-Gemmell/teensy4_i2c [github.com] - it has a "Wire" wrapper if you don't want to do anything unusual.
>>
>> My code is here, just in case: https://github.com/slgrobotics/Misc/blob/master/Arduino/Sketchbook/Teensy_PCA9685/PCA9685Emulation.cpp [github.com]
>> <Screenshot 2024-07-08 at 11.06.29 AM.png>(From https://www.arduino.cc/reference/en/language/functions/communication/wire/endtransmission/ [arduino.cc])
>>
>> With that context, I am seeing the following:
>>
>> - without anything connected to the i2c bus, the script simply checks all the addresses, sees no errors or devices, and reports “no i2c devices”
>>
>> - with an i2c cable connecting to an i2c device the script reports an error on every single address. I’ve tried two different devices as well as different cables.
>>
>> I measured the voltage on the i2c connector and it is 3.3V (for the red and black power wires.)
>>
>> In some places I see mention of a pull up resistor but I am pretty sure I have not needed that in the past.
>>
>> Any theory/suggestions?
>>
>> Thanks!
>>
>> PIto
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/6EE08C87-E9E4-4ACD-B128-FB5C1BCF1B95%40brandeis.edu [groups.google.com].
>>
>>
>> --
>> Best Regards,
>> -- Sergei
>>
>> --
>> You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/CA%2BKVXVN6O20w%3DbJpRjyE6yuxE%2BTJ4veVHi6%3DBy5ZM6Pa2j3qFQ%40mail.gmail.com [groups.google.com].
>
>
> --
> You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/E19CFA77-87E2-4AED-B424-179401727024%40gmail.com [groups.google.com].

Sergei Grichine

unread,
Jul 8, 2024, 4:57:33 PM (9 days ago) Jul 8
to hbrob...@googlegroups.com
Pito,

If the pull-ups aren't the culprit, I'd only suggest what I put in my first response:

2. Use a more advanced I2C library - https://github.com/Richard-Gemmell/teensy4_i2c  - it has a "Wire" wrapper if you don't want to do anything unusual.
// Teensy 4.0 Wire:  SDA: 18 SCL: 19
//            Wire1: SDA: 17 SCL: 16

Pito Salas

unread,
Jul 9, 2024, 11:21:18 AM (9 days ago) Jul 9
to hbrob...@googlegroups.com, Timothy Hebert
(I deleted the thread from the email because it is still available online)

The next step is installing the pull-ups. The teensy is on headers so it is easy to remove from our board.

What I heard from this thread is that we should put a 2.2 to 6,8K pullup resistor from SDA(18) and SC (19) to the 3.3 V line.

Agreed?

Pito

Pito Salas

unread,
Jul 9, 2024, 11:28:26 AM (9 days ago) Jul 9
to hbrob...@googlegroups.com, Timothy Hebert
Sorry… One more thing: Marco pointed out

It looks like at least the https://www.adafruit.com/product/4554 has 10k 
pull-up's (see attached screen shot for the tutorial). So, there should 
be no need for more? 

What do we make of that? While the tutorial indeed says that I have not been able to see mention of the on board pull-ups in the specification for the board. And at any rate, the error I am seeing (err code 4) happens on the other i2c board as well.

Pito

Ralph Hipps

unread,
Jul 10, 2024, 12:18:08 PM (8 days ago) Jul 10
to HomeBrew Robotics Club
10k pullups are a bit weak, but might work fine if the environment isn't too noisy or there aren't many loads on the bus.

if you run faster I2C or have many slaves I would use stronger pulls, like 2k or 3k.

I worked on a customer's board once that needed 500 ohm pulls to overcome noise, but that was a worst case scenario.

R.

Jeremy Williams

unread,
Jul 10, 2024, 1:38:22 PM (8 days ago) Jul 10
to hbrob...@googlegroups.com
Just in case this was missed, for devices that have the pull-ups already installed, you need to use software to activate them. 

I believe the teensie you are using has this.

For example:

void setup()   {                
  Serial.begin(38400);
  pinMode(8, INPUT_PULLUP);
}

void loop()                     
{
  if (digitalRead(8) == HIGH) {
    Serial.println("Button is not pressed...");
  } else {
    Serial.println("Button pressed!!!");
  }
  delay(250);
}

For inputs, the built in one should be sufficient imo. 


--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.

Pito Salas

unread,
Jul 10, 2024, 2:51:05 PM (8 days ago) Jul 10
to hbrob...@googlegroups.com, Timothy Hebert
Hi Jeremy

Thanks. Yes I have enabled the pullups that way. It didn’t seem to help. But then I added physical pull-ups and that also didn’t solve the problem. We have eliminated almost all variables in trying to troubleshoot this. Now we are going back and looking at the connection between the pins on the teensy and the actual connector (Qwiic) to see if there is a short or other problem there. Just to list

- use a new and better i2c arduino library (in case the default one was somehow causing the problem) - No difference
- use a totally different known-to-work i2c board in case we had somehow fried the ones on the robot - No difference
- use a different i2c cable/connector - No difference
- reroute the i2c connectors in various ways - No difference
- enable the built in pullups - No difference
- add outboard physical pullups - No difference
- explicitly set the speed of the i2c - No difference
- explicitly set the SDA and SDL pins - No difference

We’ve eliminated all the above variables. It is of course possible that we did one of those steps incorrectly….

Thanks!

Pito
> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/CAJHxCZG4v4Mru4gO-7p3rbED%2Bh-VXj96-%3DnsX8sd%2B0LZ1QyM3A%40mail.gmail.com.


Marco Walther

unread,
Jul 10, 2024, 4:56:55 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com, Pito Salas, Timothy Hebert
On 7/10/24 11:50, Pito Salas wrote:
> Hi Jeremy
>
> Thanks. Yes I have enabled the pullups that way. It didn’t seem to help. But then I added physical pull-ups and that also didn’t solve the problem. We have eliminated almost all variables in trying to troubleshoot this. Now we are going back and looking at the connection between the pins on the teensy and the actual connector (Qwiic) to see if there is a short or other problem there. Just to list
>
> - use a new and better i2c arduino library (in case the default one was somehow causing the problem) - No difference
> - use a totally different known-to-work i2c board in case we had somehow fried the ones on the robot - No difference
> - use a different i2c cable/connector - No difference
> - reroute the i2c connectors in various ways - No difference
> - enable the built in pullups - No difference
> - add outboard physical pullups - No difference
> - explicitly set the speed of the i2c - No difference
> - explicitly set the SDA and SDL pins - No difference
>
> We’ve eliminated all the above variables. It is of course possible that we did one of those steps incorrectly….

And you did check that you 'did not twist' the SDA/SCL wires, right? The
Quiic connectors are nicely keyed, but the Teensy does not have one.

-- Marco

Sergei Grichine

unread,
Jul 10, 2024, 5:00:48 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com, Timothy Hebert
How about testing the SCL and SDA pins directly (as generic GPIO, LED Blink sketch) to see if they are alive?

Using a spare Teensy 4.0? I bought two, one had a problem (not I2C related) and the seller replaced it.

Just in case, here is my Teensy doc, Volume 1, professionally rendered:  ;-)

image.png

and the same in flesh:

image.png


Pito Salas

unread,
Jul 10, 2024, 5:13:00 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com, Timothy Hebert
> How about testing the SCL and SDA pins directly (as generic GPIO, LED Blink sketch) to see if they are alive?

Sounds interesting… But how would I do that?

Sergei Grichine

unread,
Jul 10, 2024, 7:16:20 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com, Timothy Hebert
Just use a standard Blink.ino script, tweak it to point to pins 18 and 19, connect LED+200 Ohm resistor or oscilloscope.

It is only through the Wire library those pins become SCL/SDA - otherwise they should behave like GPIO pins.

On Wed, Jul 10, 2024 at 4:13 PM Pito Salas <pito...@gmail.com> wrote:
> How about testing the SCL and SDA pins directly (as generic GPIO, LED Blink sketch) to see if they are alive?

Sounds interesting… But how would I do that?

--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.

Pito Salas

unread,
Jul 10, 2024, 7:53:56 PM (7 days ago) Jul 10
to Marco Walther, hbrob...@googlegroups.com, Timothy Hebert
Hi Marco

Bingo! Indeed the wiring from the teensy to the Qwiic connector which was hidden from view twisted those two and now, happiness!

Thanks everyone!

PIto

Michael Wimble

unread,
Jul 10, 2024, 8:04:11 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com, Marco Walther, Timothy Hebert
Huzzah!

> On Jul 10, 2024, at 4:53 PM, Pito Salas <pito...@gmail.com> wrote:
>
> Hi Marco
> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/81F6FB71-CE45-4EA9-BE65-6CF934F7F1A7%40gmail.com.

Dan

unread,
Jul 10, 2024, 8:21:36 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com
Pito...As a firmware programmer working on driver routines for the last 39 years I can't stress the importance of a logic analyzer.
They are under $20.00 on ebay...some as low as $10.00...Stop wasting time with guessing and look at the signal.
Daniel

Pito Salas

unread,
Jul 10, 2024, 8:47:12 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com
Hi Dan

As a software guy for 39 years I am a beginner again working with wires and signals and reading spec sheets But can you recommend one that would be good to get? I can spend a little more than $20 if that matters. Thanks for the tip!

Pito
> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/1574133353.3500843.1720657290667%40mail.yahoo.com.

Dan

unread,
Jul 10, 2024, 9:11:49 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com
Hi Pito,


You will not regret getting this. You will end up using it with every peripheral that you hook up.
On of the best uses is when you try to debug a UART (serial) port. With an analyzer you can see the baud rate being transmitted/received. Sometimes it is not what you expected. But it sure shows you where the problem is.  Also you can see how long in nanosecond resolution a slave took to respond from a command. This is crucial when trying to determine how much data you can really send and receive in a real world situation.

Also, with I2C it is important to adjust the high and low periods of the clock. For fun read this:


If you need help with how these work, get one and email me. I'll be happy to help.

Daniel




Michael Wimble

unread,
Jul 10, 2024, 9:33:29 PM (7 days ago) Jul 10
to 'Dan' via HomeBrew Robotics Club
I tend to use an oscilloscope because I’m seldom interested in combinatorial visualization but I’m very concerned with the shapes of signals, especially rise times, ringing, induced noise, etc. So, what I use it this:

Dan

unread,
Jul 10, 2024, 10:15:48 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com

Nice...A few of my clients had scopes with protocol analyzers built in....Very pricey but you're right...it is the best way to look for those hidden gotchyas.

Marco Walther

unread,
Jul 10, 2024, 11:03:56 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com
On 7/10/24 19:15, 'Dan' via HomeBrew Robotics Club wrote:
>
> Nice...A few of my clients had scopes with protocol analyzers built
> in....Very pricey but you're right...it is the best way to look for
> those hidden gotchyas.

I started out with a LHT00SU1 (now around $20), it works very well on
Linux with sigrok (all kinds of protocol's ...), but I also have a Rigol
DS1054Z (with some not so official upgrades;-) for the really hard cases;-)

-- Marco

>
> On Wednesday, July 10, 2024 at 06:33:29 PM PDT, Michael Wimble
> <mwi...@gmail.com> wrote:
>
>
> I tend to use an oscilloscope because I’m seldom interested in
> combinatorial visualization but I’m very concerned with the shapes of
> signals, especially rise times, ringing, induced noise, etc. So, what I
> use it this:
> 41ODlntD7VL._SR600,315_PIWhiteStrip,BottomLeft,0,35_PIStarRatingFOURANDHALF,BottomLeft,360,-6_SR600,315_ZA1%2C352,445,290,400,400,AmazonEmberBold,12,4,0,0,5_SCLZZZZZZZ_FMpng_BG255,255,255.jpg
> Siglent Technologies SDS1202X-E 200 mhz Digital Oscilloscope 2 Channels,
> Grey <https://a.co/d/05BmiVcF>
> a.co <https://a.co/d/05BmiVcF>
>
> <https://a.co/d/05BmiVcF>
> <mailto:hbrobotics+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hbrobotics/C98B0B76-3A28-437D-B052-E0A7029195E8%40gmail.com <https://groups.google.com/d/msgid/hbrobotics/C98B0B76-3A28-437D-B052-E0A7029195E8%40gmail.com?utm_medium=email&utm_source=footer>
> .
>
> --
> You received this message because you are subscribed to the Google
> Groups "HomeBrew Robotics Club" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hbrobotics+...@googlegroups.com
> <mailto:hbrobotics+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hbrobotics/1681962306.3527801.1720664142373%40mail.yahoo.com <https://groups.google.com/d/msgid/hbrobotics/1681962306.3527801.1720664142373%40mail.yahoo.com?utm_medium=email&utm_source=footer>.

Jeremy Williams

unread,
Jul 10, 2024, 11:19:45 PM (7 days ago) Jul 10
to hbrob...@googlegroups.com
Are all voltage sources using a connected (common) ground?

Pito Salas

unread,
Jul 11, 2024, 7:32:36 AM (7 days ago) Jul 11
to hbrob...@googlegroups.com
Ok, I’m convinced! I’m ordering one of those $20 logic analyzers. How would I have used to discover that I had the sda and scl lines had been reversed? Could I have used one for that particular bug?

Pito Salas
Computer Science
Brandeis Univeristy


> On Jul 10, 2024, at 11:03 PM, Marco Walther <marc...@gmail.com> wrote:
> To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/a6930071-70b4-4cf3-9936-b7f5b8ed7363%40gmail.com.

Ralph Hipps

unread,
Jul 11, 2024, 9:24:13 AM (7 days ago) Jul 11
to hbrob...@googlegroups.com
if the LA had protocol awareness you would have seen garbage transactions, which would be an indicator that something fundamental is messed up, like the wiring.

it might also support easily swapping the signals and retesting, which would have been useful.

it's a common mistake in I2C to have the wires swapped, so I always triple check that.

Thanks, Ralph



You received this message because you are subscribed to a topic in the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hbrobotics/FGb6cd-uO_E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/1ADA73D0-3B8B-43BF-9CEF-F5DF2216C38F%40gmail.com.

Dan

unread,
Jul 11, 2024, 9:46:20 AM (7 days ago) Jul 11
to hbrob...@googlegroups.com
That is easy. The clock looks like a square wave of 10 per byte. The data is not (unless it is something like 0xAA (10101010). The probe lines are usually different colors. 
I2C always sends the address of the slave device first as 7 bits followed by the read/write bit(read = 1). So if the slave address is 0x12 the address on the data line will be either 00100101 (x25) or 00100100(x24) for a write.
You should hook up the logic analyzer and take a peek at the data even if things are working. It will give you a good baseline and some confidence with the analyzer.

Steve " 'dillo" Okay

unread,
Jul 11, 2024, 11:13:43 AM (7 days ago) Jul 11
to HomeBrew Robotics Club
On Wednesday, July 10, 2024 at 5:21:36 PM UTC-7 Dan wrote:
Pito...As a firmware programmer working on driver routines for the last 39 years I can't stress the importance of a logic analyzer.
They are under $20.00 on ebay...some as low as $10.00...Stop wasting time with guessing and look at the signal.
Daniel

As a systems engineering generalist for the past 30-ish years, I'm gonna cut a few milliseconds quicker to the chase and suggest this:
https://www.crowdsupply.com/excamera/i2cdriver

Does it do everything a full-on Logic Analyzer or Oscilloscope does ?--No, it does not. It has no frequency range settings, it doesn't have triggers or sampling. It doesn't store presets.

What it does do though is enumerate the I2C devices plugged into it, gives you a little graph of the pulse-train and the voltage and current being used.
Which tells you right away if the problem is with the device itself, or with your code or wiring.

Get the Analyzer like Dan is suggesting and then set aside a weekend to figure out how to really use it *after* you've solved your current I2C problem.

'dillo

Chris Albertson

unread,
Jul 11, 2024, 1:18:50 PM (7 days ago) Jul 11
to hbrob...@googlegroups.com

What would you see with a logic analyzer? Assuming you are not expert in I2C, What you do is dig out the data sheet for the I2C chip you are using and on it some place will be a diagram that shows the pulses on the two wires and it will have some timing notes too. As a first step you simply compare the data that was captured to the diagram and see if it is even close.

A person who is very famiaaly with I2C would not need the diagram from the data sheet. But it is usless advice to say “first become an expert, then debug the circuit”. So I always start with the manufacturer’s dta sheet.

Where the anayler really helps is that it can show you the data. The software inside the analyzer will decode the I2C data and turn it into something you can read, text, numbers of whatever.

But I2C is really different fom other kinds opf serial data and the oscilloscope might be a more usfull tool. Analysers do not show the analog wave, ‘scopes do and many times with I2C you have an analog domiine problem. But, of course the ’scope can’t decode the waves into data. You need both

Back to teaching. I remember I was a university student in the late 70s. Classes that covered theory are 100% needed, one of the best classes I took at UCLA was a lab where they had a ton of broken computer-related electronics and we were told to “fix a much of this stuff as you can.” We had access to a ton of high-quality test gear and an instructor who would show how to use the gear if we’d ask and make suggestions on how to productivly debug the broken stuff.

Today, of course if a part is broken, they just say “it is the logic board” and replace it and $600 later ypu laptop PC works again. But back then they would replace the 5 cent capacitor or $2 blown chip.

Marco Walther

unread,
Jul 11, 2024, 1:37:29 PM (7 days ago) Jul 11
to hbrob...@googlegroups.com, Pito Salas
On 7/11/24 04:32, Pito Salas wrote:
> Ok, I’m convinced! I’m ordering one of those $20 logic analyzers. How would I have used to discover that I had the sda and scl lines had been reversed? Could I have used one for that particular bug?

I did not try this, so the next is just a guess!! With the pull-up
resistors as they are, you would have seen 'valid' states with an analog
probe (a real high or a real low, no 'floating' around the middle). With
a digital probe/LA, depending on which side of the 'twist' you would
have connected the LA, it might show 'a perfect i2c request - but never
a response' or 'some signals on the wires which can not be decoded'.

But as a matter of principle, I suspect my wires & connectors very early
on;-) And that solves the bulk of my problems;-)

Hope that helps;-)
-- Marco

Stephen Williams

unread,
Jul 11, 2024, 2:34:24 PM (7 days ago) Jul 11
to hbrob...@googlegroups.com
On 7/11/24 8:13 AM, Steve " 'dillo" Okay wrote:


On Wednesday, July 10, 2024 at 5:21:36 PM UTC-7 Dan wrote:
Pito...As a firmware programmer working on driver routines for the last 39 years I can't stress the importance of a logic analyzer.
They are under $20.00 on ebay...some as low as $10.00...Stop wasting time with guessing and look at the signal.
Daniel

As a systems engineering generalist for the past 30-ish years, I'm gonna cut a few milliseconds quicker to the chase and suggest this:
https://www.crowdsupply.com/excamera/i2cdriver

Those look really nice!  More tools to order!  Thanks.


sdw

Does it do everything a full-on Logic Analyzer or Oscilloscope does ?--No, it does not. It has no frequency range settings, it doesn't have triggers or sampling. It doesn't store presets.

What it does do though is enumerate the I2C devices plugged into it, gives you a little graph of the pulse-train and the voltage and current being used.
Which tells you right away if the problem is with the device itself, or with your code or wiring.

Get the Analyzer like Dan is suggesting and then set aside a weekend to figure out how to really use it *after* you've solved your current I2C problem.

'dillo
--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.

Chris Albertson

unread,
Jul 11, 2024, 3:25:07 PM (7 days ago) Jul 11
to hbrob...@googlegroups.com
These things are cheap enough that you can afford to buy several of them so you can leave it connected to a robot you are building.

Not only are they good for serial communication debugging but let’s say you are trying to make a servo run using PWM.  It will measure the pulse width of the PWM.    This is how I found that the common I2C based PCAxxx PWM chip was very inaccurate.  Not a bug just a “feature” of that chip.      For $10 you can leave the analyser on the robot as it runs and logs up to 8 signals to disk.  I can see the lag in the PID algorithm from encoder to PWM.

Also, it is a “free” why to use print statements for debugging.   I can define one spare pin as a serial out and “print” to that pin and the logic analyser will decode the pin to text and I can see the debug prints in context with the signal pins all with u-second level timing marks.

Other times print statements will slow the code too much, so the analyser can record the raw digital signals with no code changes.   

It you are teaching, buy a dozen of them and loan therm to students or if students must buy their own tools, tell them “This goes in the kit along with your multimeter and screwdrivers."



Reply all
Reply to author
Forward
0 new messages