6 - Tweaking the servos

If you have previously modified a servo then you may have noticed that their peformance can change depending, not only on how well you centered the pot, but also on external things like voltage levels etc.

To tune the code to your servo then you may need to fiddle with the following lines:-

SERVO g_servoLeft( 'D', 2 , &g_timer, true, 1500, 300);
SERVO g_servoRight('D', 3, &g_timer, false, 1500, 300);

The last 3 parameters do the following:-

true or false - indicates if one of the motors is flipped.

1500 - This represents the value to center the servo. In this case it means 1.5ms which is the default value for centering a servo.

300 - This represents the deviation on either side of the previous value. ie from 1.2ms to 1.8ms.


So to center your servos then change the last parameter to 0. This means that no matter what your code is trying to do it will always go at the speed set by the 1500 parameter. If 1500 doesn't keep your wheel stationary then tweak with the 1500 value until it does. You can then experiment with the second value so that you get the required variation in speed control. I then label each of my servos with the settings that works best for them.


The same thing applies if you are using the PWM version of the motor control.