0

My Raspberry Pi car bot will not drive straight at all.

After examining and listening to the two motors, I noticed that the right wheel is a lot faster. I have matching wheels and the same code structure for commanding my wheels to turn. I have my motors hooked to an H-bridge also. I am not using PWM or anything fancy that I am aware of. I have watched many YouTube videos of programming robots to drive and my code is not that much different.

Why are my wheels turning at different speeds when programmed the same way? How should I fix this?

Glorfindel
  • 297
  • 1
  • 4
  • 10
sirshakir
  • 1
  • 1
  • I have read forms about how real cars drift off when you drive straight. I get that but my pi robot is not driving straight at all. The right wheel is just too much faster compared to left wheel even thought its wired the same. – sirshakir Nov 27 '18 at 23:20
  • 1
    isolate the problem ..... first, switch the motor connections at the H-bridge .... does the problem move? – jsotola Nov 28 '18 at 02:12
  • You need to understand if your problem comes from the motor, the power circuitry or the code. then if you don't use any controller loop you will never drive straight as the motor/wheel will never have exactly the same behavior. – N. Staub Nov 28 '18 at 12:27
  • Welcome to Robotics, z Eyeland. I'm marking this question as a duplicate of another "my car doesn't drive straight" question. You can read more detail in my answer there, but essentially there are very small things, typically manufacturing differences, that you can never account for. You will never get both sides exactly the same. You need some form of feedback to keep the robot going straight. – Chuck Nov 29 '18 at 15:33
  • I will add, though, that your wheels should be going close to the same speed. Your robot "should" go approximately straight for a while and then always veer off-course. If you have some kind of problem where your robot is driving in tight circles or something similar then you likely have some flaw in the software or wiring. You have to load the motors, though (put the robot on the floor). Unloaded motor speeds can vary a lot due to relatively minor variations in internal friction in the motor. – Chuck Nov 29 '18 at 15:36
  • 1
    Thanks all. I solved the problem using PWM. I am amazed how identical motors can be different. Figured my motors should ride somewhat straight without PWM such as Chuck stated above. – sirshakir Nov 29 '18 at 17:11

1 Answers1

0

Did you implement a controler? It is common that the same model motors are not exactly the same and if you just give an input each one is going to behave differently. If you have feedback from the motors you can implement an PID controler and see the results. It's pretty easy to implement a couple of code lines.

nionios
  • 311
  • 2
  • 9