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.

  • 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 Sep 16 at 17:15

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.

Temporary and harsh workaround: You could reset your Arduino after first initialization process (at the end of setup) then, save a flag("1") to EEPROM so it will not reset each time you start Arduino (warning: EEPROM cells can be rewritten only 10000 times).

if(EEPROM.read(0))
{
  EEPROM.write(0,1);
  //put your reset code here
}

if(EEPROM.read(1))
{
  EEPROM.write(0,0); //make it back "0" for next start
}
  • Comments are not for extended discussion; this conversation has been moved to chat. – Majenko Oct 3 at 8:54

Your Answer

 

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.