It may be already asked question in somewhere but I am struggling!

I have a four wheel robot which I want to drive it to perform 90-degree left/right turn, I am using the MPU6050 3dof to get angles, however everything is ok when the DC motors are off and the readings from the MPU6050 are pretty good.

But when the DC motors are on, the readings start to be increase randomly. I tried to use a different power supply to the DC motors and the Arduino, but with no solution. At the end when I reset the Arduino everything was back to be normal even if the DC motors are on!

the bellow image is my schema Any help will be appreciated and I am open for any suggestion.

New contributor
Mostafa Abbas is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • You said " I tried to use different power supply to dc motors" -- please provide details. Your diagram shows a 9V battery, which can hardly supply enough current to operate two motors and an Arduino. Be sure that you include all relevant details in your question. – jose can u c Sep 14 at 13:38
  • @josecanuc , thank you for your reply and I'm sorry I wasn't accurate in my question, however, for now, I am using an 11.3v battery for the dc motors and 7.3v for the Arduino , the rest of the image is the connections for my setup as well as I connected the GND of the motor with the GND of the Arduino – Mostafa Abbas Sep 14 at 15:36

There are two basic things you need to do:

  1. Use proper pullup resistors on your I2C lines (2.2kΩ) instead of relying on the (terrible) internal pullups of the ATMega
  2. Add capacitors to the motors.

For point 2 you need two or three small ceramic capacitors (10nF to 100nF) per motor.

  • Connect one from each terminal to the motor's body
  • Optionally connect a third between the two terminals of the motor

This will reduce the EMI produced by the motor, and the improved pullups should reject EMI easier.

(Even if this doesn't entirely fix your underlying issue, it's certainly something that you should do regardless.)

  • well, thank you for the suggestions, is it ok if I do both points? – Mostafa Abbas Sep 14 at 15:37
  • Yes. You should do both points. – Majenko Sep 14 at 15:41
  • I have a question if you could answer it, why when I press the reset button on the Arduino everything is normal and the readings from MPU6050 back to be normal? – Mostafa Abbas Sep 14 at 16:44
  • No idea. EMI causes strange things. – Majenko Sep 14 at 16:44
  • it didn't work! i added the capacitors as you said and pullup resistors but nothing changed! the problem still only with first power when reset the arduino from the RESET button everything back to be normal – Mostafa Abbas yesterday

You can just change ground port for your MPU6050 or for your motors(experiment with different choices). You have another ground port near pin13. As far as I know some of them are for analog devices and some of them are for digital (to avoid interference). Adding capacitors may not help. If none of the methods will help, try to add an inductor to your circuit.

Please, try that and write here if these were helpful or not.

Update: As per this site the problem is caused by data cables.

Thank you a lot !

Didn't have to change frequency. I just eliminated SDA and SCL wires and plugged a chip with MPU-6050 directly into Arduino and it works without any problems. Thanks to you this issue is solved :)

In addition I would like to mention that Arduino standard pin cables are very noisy, so all connected modules which use high data rates or which are very sensitive to data errors (for example, nRF24L01+) will have strange behavior.

  • I will try that , why when I press the reset button everything goes normal ? – Mostafa Abbas Sep 15 at 10:38
  • Oh, maybe your dc motors cause brownouts. Use capacitors for your motors as in previous answer. When your dc motors start to operate your arduino goes crazy right? I mean it remains crazy until you reset it ? – Faig Sep 15 at 10:46
  • The best thing you can do is to add another battery for your dc motors to check if it is ok then. – Faig Sep 15 at 10:52
  • The only thing is happening is that the readings of the mpu6050 goes crazy but the arduino is working but the readings as i said go crazy – Mostafa Abbas Sep 15 at 11:59
  • I used another battery with the following : 11.3 v for dc motors 7.3 v for Arduino goes from Vin and GND as well as another wire goes from GND of dc drive L298n to GND of the Arduino. – Mostafa Abbas Sep 15 at 12:14

Your Answer

Mostafa Abbas is a new contributor. Be nice, and check out our Code of Conduct.
 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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