I am using 2 identical DC motors and a castor wheel. The motors are connected to L293D motor driver and are controlled by RPi.

The robot is not going straight. It veers off to the right. I am running both the motors at 100% PWM.

What I tried to correct the error:

  1. I adjusted the PWM of the wheel going faster to 99%, but the robot just turns to the other side;
  2. I adjusted the weight on the robot and the problem still persists.

I once tried to run the motor without any load. Is that the cause of this, as I was later told that, running a DC motor without any load damages them?

If that is not the cause, then please tell me how to solve this problem without using any sensors for controlling it.

  • $\begingroup$ In a differential drive configuration which I image is what you use, this is very likely to happen. A small difference between the two motor will cause the robot to rotate. $\endgroup$
    – Demetris
    Commented Jan 26, 2016 at 18:17
  • 7
    $\begingroup$ Welcome to open loop control. You need sensors of your own (your eyes) to detect the problem yourself, how do you think will the robot be able to detect it without additional sensors? Closing the control loop with sensors is the way to go. $\endgroup$ Commented Jan 26, 2016 at 18:37
  • 1
    $\begingroup$ Stepper motors might work if you want to avoid sensors. $\endgroup$
    – user11714
    Commented Jan 27, 2016 at 7:54
  • $\begingroup$ @bdares - If there are no sensors, how does the robot know when to course correct? If one wheel hits an area of low friction (dust, for example) and slips, the robot turns and will never correct. $\endgroup$
    – Chuck
    Commented Jan 27, 2016 at 14:31
  • $\begingroup$ When you say no sensors, could this mean no external sensing or are you also excluding encoders on the wheels? because that is the typical solution to this problem. $\endgroup$
    – JamesRyan
    Commented Jan 27, 2016 at 14:59

7 Answers 7


I'm posting this as an answer because it is the answer.

You can't.

As @BendingUnit22 mentions, you are attempting "open loop" control. Noise and variations will mean that your robot will never drive a perfectly straight line.

The motors could have different winding resistances (different drive currents/torque), the wheels could be different sizes, the wheels could have different traction characteristics, the caster bearing could be "stiff", the caster might not be perfectly straight when the vehicle starts, the floor might have varying surface friction characteristics (read: dust or carpet) - the list goes on and on.

The only way to account for the things outside your control (what I mention above + more) is to use feedback sensors.

You can try to get better open-loop performance by correcting the problems I listed, but there are even more and you simply can't control everything.

  • 6
    $\begingroup$ Exactly! The issue lies in the statement "I am using 2 identical DC motors". They're never perfectly identical, and as @Chuck mentions, there's a whole host of other considerations. The only thing certain in robotics is that error and noise will come up. $\endgroup$ Commented Jan 26, 2016 at 20:27
  • 2
    $\begingroup$ Using two wheels on the same axis should still yield much better results than just using two of the same motor, shouldn't it? $\endgroup$ Commented Jan 27, 2016 at 12:31
  • $\begingroup$ @JanDvorak - I'm not entirely sure what you mean when you say, "Two wheels on the same axis," but I believe it is understood/implied that the two wheels are on the same geometric axis. If you mean the same control axis (as in one motor) or axle (again implying one motor), then I would point out that it's not possible to perform differential drive steering with a locked axle. For one motor to control both wheels to different speeds requires a differential (and other equipment), and the differential effectively breaks the axle into two pieces and you're back at square one. $\endgroup$
    – Chuck
    Commented Jan 27, 2016 at 13:38
  • $\begingroup$ I did mean one axle, sorry. I did not know there was a requirement to be able to go not straight? $\endgroup$ Commented Jan 27, 2016 at 13:41
  • 2
    $\begingroup$ @JanDvorak - I believe OP's robot is a micromouse-style vehicle. Even if it only had to go straight, and used one axle, all of the other sources of error still apply. If one wheel is 0.1% larger in diameter than the other then it will travel a path length that is 0.1% farther than the smaller tire per revolution. Say, for example, the nominal wheel size is 10cm and the wheel spacing is 10cm. The larger tire is 10.01cm and travels 0.0314cm farther per revolution. For the wheel base, the robot turn 0.12 degrees per wheel revolution. 0.01cm could easily be from dust on one tire. $\endgroup$
    – Chuck
    Commented Jan 27, 2016 at 13:48

Since the open-closed loop issue is already mentioned, I will give a comment to the "I once tried to run a dc-motor without a load".
Yes you might damage your motor with this but you can also damage or destroy your motor with a load. The destruction is coming from the current and the resulting temperature. If there is no smoke and some obvious smell coming from the motor it is most likely not damaged. From my experience I can tell that hobby-scale dc-motors will start to degrade at temperatures way over 100°C. And you will definetly notice such temperatures

I did think about this again and I might got an idea which your collegue might have been talking about. There are a special kind of AC-Motor. These are non-excited synchronous motors. Basically they are build for self destruction. If you power them up, they will start accelerating until they disassemble themselves. But if you place a heavy load on them, they can't reach this state, just because of the huge moment they have to apply to the load. So you can use them for reasonable purposes. Anyway you definetly do not of a motor like this in your application.

  • 1
    $\begingroup$ I think too that, especially with hobby motors, by the time you heat it up enough to notice it's hot or smells funny you've probably already burnt the insulation off the windings. Like a lot of electric equipment, it either works fine or it's broken. There aren't a lot of in-between cases. $\endgroup$
    – Chuck
    Commented Jan 27, 2016 at 0:19
  • $\begingroup$ There was no such smoke or any visible damage. So maybe it is not damaged as I ran it for less than half a minute. $\endgroup$
    – Mouse
    Commented Jan 28, 2016 at 15:25

What you are describing is called open loop control, and to do this you need two motors which are exactly the same, two wheels exactly the same, the robot center of gravity to be in the center between the wheels, a perfect symmetrical electrical circuit, and finally a perfect uniform level surface to run on.

To accomplish this you typically order tens or hundreds of each part, and then perform significant testing to find two motors that are the closest match to each other in terms of power and speed vs voltage and PWM. Do the same for the wheels, the motor controllers and other parts.

This process is called binning - after these tests you sort them according to their capability or characteristics. It's considered much more expensive in both time and resources to do properly than changing to a closed loop model, and doesn't even account for poor ground conditions.

It is, however, one way to achieve your requirements without additional sensors.


Though it will never be perfect, there may be a simple way to get it to go more straight.

If at 100%-100% the car always turns left, and at 100%-99% the car always turns right, you should be able to improve on that by trying values in between.

Start with 100%-99.5% and continue with 100%-99.75% or 100%-99.25% depending on the outcome. This should soon converge to a situation where you will go straight 'on average'.


I faced the same problem: I used DC motors and L293D motor. Like everyone else said you need to use a sensor. I used MPU6050 gyroscope sensor, which is cheap and somewhat inaccurate but is good enough for driving straight. Implementing a sensor can be cheap and simple as shown on (which uses Arduino, but the same concept can be used on Raspberry Pi):


I have also tried adjusting PWM to each motor, which does NOT work, since the surface/ground the car runs on changes.


Well, if the problem does not lie in differences in hardware nor software for each wheel, then it is probably a problem with natural imperfections in either the way you built the robot or the way the motors were produced. The connections might not be solid or the RPI might not be outputting the same current. You probably want to be using speed controllers. Try that first.

If that doesn't work, your manufacturer probably didn't make identical motors and you'll probably just have to calibrate the motors. It might mean scaling the value of the stronger motor so 100% power to the strong motor matches the weak one.

  • 2
    $\begingroup$ Using identical motor controllers will not solve the issue at hand. The issue lies at the core of robotics, which is "how do I correct the error?" $\endgroup$ Commented Jan 26, 2016 at 20:29
  • $\begingroup$ I've heard that DC motors can run slightly slower backwards as forwards. Also, any imbalance in the weight might cause some shifting to a side. Not to mention other things like friction etc. Doing anything "identical" won't work. Steppers might do a little better, but then you shouldn't drive too fast or anything... $\endgroup$
    – aaa
    Commented Feb 10, 2016 at 19:46

Wheels with dc motors should b on front. And coster wheel at back. Then it will move straight only in forward direction

  • $\begingroup$ Welcome to Robotics Arslan. On Stack Exchange we are are looking for comprehensive answers that provide some explanation and context. Very short answers cannot do this, so please edit your answer to explain why it is right, ideally with citations. Answers that don't include explanations may be removed. $\endgroup$
    – Mark Booth
    Commented Mar 8, 2017 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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