Make your own free website on Tripod.com

Calibration of motor speeds

These instructions are for the basic Ebot with two hacked RC servos and no encoders.  These steps are taken after you have some basic software to drive the motors. 

In the general case, your software will put out a pulse width to each servo.  To stop the motors,  the pulse width will be approximately 1.5 milliseconds.  And to go forward, one motor's pulse width will be made greater than 1.5 milliseconds, and the other motor's pulse will be about the same amount less than 1.5 milliseconds.  This is because the motors must turn in opposite directions to move the robot either forward or backward.

If you have tried running your robot forward, you probably found that it doesn't quite go straight, but turns a bit to the left or right.  That is because the two motors will seldom, if ever, be perfectly matched.  So, one of the first goals of calibration is to find pulse width commands for each motor that result in matched performance.

First,  you want the robot to stop and stand still when you tell it to do so.  So program it to put out a 1.5 millisecond pulse to each motor.  Then start it up and see what happens.  If the motors don't run, you have found your commands for STOP.  If one or both motors continues to move slowly, you have to do some adjustment with the pulse widths to get them to stop.

I believe that the usual case will be that reducing the pulse width of the right motor will make it go faster in the forward direction; and increasing the pulse width of the left motor will make it go forward faster.  So, if either if your motors is creeping when it should be stopped, just increase or decrease the pulse width until it stops.  There may be a small range of pulse width where the motor will be stopped.  In order to assure that it stays stopped reliably, you want to find a pulse width that is in the middle of that range.    So, once you find a value that stops, increase the pulse and decrease the pulse until you find the values where the motor starts to move, and then choose a value for STOP that is right in the middle.  You may have different values for each motor.  This is normal.

Write down the pulse widths you will use for STOP for each wheel.

 e.g.     STOPLEFT   = 1.52;
           STOPRIGHT = 1.48;

Note:  the above definitions are in milliseconds.  If you want to drive your robot with a Basic Stamp, the code to implement this would be STOPLEFT = 751  and STOPRIGHT = 749.

A next value to determine might be the pulse widths for maximum forward speed.  The chart for the CS60 motor shows that maximum PWM (100% duty cycle) is achieved at pulse widths of 1.0 millisecond (for one direction) and 2.0 millisecond (for the other direction).

So, set your software to drive the right motor at 1.0 millisecond and the left one at 2.0 milliseconds.  Then put the robot down and turn it on.  It should run in a generally forward direction. (if it runs backwards, just reverse the motor pulse settings and try again).  The thing to look for is: does it go straight forward? or does it turn to the left or right?

Since both motors are set to 100% duty cycle, you can't speed either motor up, so you'll have to change the pulse width to the motor that is going faster and causing the turn to make it closer to 1.5 msec..

 By the way,  I'm ASSUMING that 1.0 and 2.0 milliseconds cause 100% duty cycle on your motors because it did on mine.  There's no guarantee that this is true, especially if you used a different motor.  So feel free to try increasing, or decreasing, a pulse width to get a motor to run faster.  You may even find that your motor reaches maximum speed (100% duty cycle) at pulse widths closer to 1.5 milliseconds (e.g. 1.2 and 1.8 milliseconds rather than 1.0 and 2.0).  You can determine this by sending a range of pulse widths to the motor and measuring how many turns it make per minute at each pulse width.  When making the pulse width farther from 1.5 milliseconds doesn't make the motor turn faster, you've found the pulse width for 100% duty cycle.  Use those values rather than the 1.0 and 2.0 milliseconds.

So, if both motors are running at their maximum speeds, change the pulse width to the motor that is going faster.  If the robot is turning right, increase right motor pulse width from 1.0 to 1.1 milliseconds.  If it is turning left, reduce the left motors pulse width from 2.0 to 1.9.  Try running the robot again, it should turn less rapidly, or even turn in the other direction.  Adjust the pulse width until the two motors run the same speed and the robot goes straight.  One catch is that the pulse widths necessary to match the motors may change as the motor warms up.  So, before making any tests (or entering any contests), it's best to run the motors for a while to get them warmed up.

Once, you've found pulse widths for each motor that result in a straight path, Record these pulses: e.g.

            ForwardFastLeft = 2.0
            ForwardFastRight = 1.15

Do the same procedure to determine the pulse widths necessary to go backwards in a straight line and record them.   You may also want to find pulse widths for one or more slower speeds.  If you wish, you can also determine speeds that will make special maneuvers you may want to do; like turning in a 3 foot diameter circle.

The important thing is, you can record these in your program so that when you want to go fast in a straight line, or any other maneuver, you can just set the motor pulse widths to these values.

Since the basic Ebot has no encoders, tachometers, or any other method of knowing where it is REALLY going,  accurate motor speed control and time are the only two things you have to do good navigation.

And be prepared,  these values won't always make it go straight.  The motor speeds will vary for other reasons than pulse width.  The load on the motor (like if one side hits bumps, or is on a rougher surface.  The motor speeds may change as the motors warm up, or run in.  And battery voltage will affect the speeds.  This is why we will later be adding encoders to the servos so we can measure their true speed and distance traveled and change the pulse width appropriately to compensate

.