Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C messages are sent too close to each other #1176

Closed
Prototyx opened this issue May 2, 2024 · 4 comments
Closed

I2C messages are sent too close to each other #1176

Prototyx opened this issue May 2, 2024 · 4 comments

Comments

@Prototyx
Copy link

Prototyx commented May 2, 2024

Hello,

I made a donkey car with a RPi 4 (CM4) connected to an Arduino UNO via I2C.

IMG_4056

Basically my Arduino UNO is replacing the PCA9685. I have my ESC and my servo attached to some PWM pins on my arduino.

It seems that there is one thread for the steering, and another one for the throttle. And each thread send their command via I2C too close to each other.

Issue : I2C messages too close to each other
image

Is there a way to not have both thread sending I2C commands at the same time ? I think PCA9685 can manage 2 I2C messages very close to each other but on for my Uno it seems very difficult. I have a lot of I/O Errors. When I do the calibration for only the steering or throttle it works well.

Solution :
image

Thanks for your help.

@Prototyx Prototyx changed the title I2C messages are sended too close to each other I2C messages are sent too close to each other May 2, 2024
@Ezward
Copy link
Contributor

Ezward commented May 6, 2024

@Prototyx Are those signals the pwm outputs? It looks like those signals are on the same pin. If those are the PWM outputs then you need to send the steering and throttle pwm on two different pins.

I would be surprised if it was an I2c issue; it's a serial protocol that can handle bus contention. What error are you seeing? Are you seeing it in the donkeycar console or the arduino serial console? Can you copy the output here?

PS: the car looks really cool; very compact. Nice.

@Ezward
Copy link
Contributor

Ezward commented May 8, 2024

@Prototyx what type of Arduino are you using? Is it 5v or 3.3v? How are you handling the logic-level conversion between the RPi and the Arduino if the Arduino is 5v? The reason I ask is that it is my understanding that some logic-level conversions can 'round' the edges of a logic level change and so could possibly affect I2c communication.

@Prototyx
Copy link
Author

Prototyx commented May 8, 2024

Hello, The arduino is 5V (it's Atmega328p, same as uno board). I am using a logic level converter between the Arduino and RPi designed for I2C communications (PCA9306).
I made some investigations today :

  • I2C in Fast mode (400kbit/s) --> A lot of I/O errors
  • I2C in Standard mode (100kbit/s) --> Something like 1 error per minute

When I put the scope on I2C lines, in fast mode the frequency is not stable at all, I think the RPi has to deal with others tasks with higher priority and decreases the frequency, maybe it is for this reason that it causes a lot of errors, because the arduino is not able to manage this frequency variation.

Anyway, after decreasing the I2C speed, I was able to drive the car without problem, and I did my first autonomous session. I was very impressed !

@Ezward
Copy link
Contributor

Ezward commented May 12, 2024

@Prototyx Thank you for detailing the resolution. I'm closing this issue.

@Ezward Ezward closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants