Maxwell – Robot Servo Linearity

In thinking through the servo motor programing strategy I realized that the servos may be non-linear. Research (via Google, of course) uncovered a simple Basic Stamp test program in the BOE-BOT guide to robotics on the Parallax website. Maxwell isn't a BOE-BOT, but is close enough that the programs run with very few modifications.

The basic approach is to put the controller into a loop where the timing is known then measure how far the servo rotates during the loop execution, then multiply the rotation by an adjustment factor. In this particular case the program rotates the servo for six seconds while the rotations are counted. The result is then muliplied by a factor of 10 to derive the RPM figure. Their recommendation was to use PULSOUT commands ranging between 650 to 850, but I decided to take a couple of additional measurements extending the range to see how quickly it would become non-linear.

This chart shows the test data for one of Maxwell's servos. The vertical axis represents the PULSOUT parameter passed to the servo while the horizontal axis charts the resulting RPM. It's easy to see that the servo zero is slightly offset from the theoretical null position. If it was zero'ed perfectly the curve would in intersect the origin at (0,750). The offset is relatively minor - small enough that a constant in the control program can adjust for it. The servo is relatively linear from 650 to 850, but rapidly becomes non-linear outside of that range.

The next steps are to -

  1. Run the same linearity test on the left servo
  2. Compare the linearity and zero offsets between the two
  3. Develop a more sophisticated test program to automatically collect the data with more precision and granularity

#1 will happen some time over the next few days. My schedule is pretty full, but the test only takes about 30 minutes to run per servo, so I can fit it in somehow.

#2 involves some analysis of the data in Excel and may be as simple as setting up a couple of additional data columns that add offsets to the collected data then chart the results.

#3 is simple in principle, but may end up presenting some difficult and interesting challenges. My initial thought is to breadboard a sensor similar to those used for line tracing. Position the sensor over the wheel attached to the servo to be tested. The wheel surfaces are a very flat matte black, so attaching a piece of light colored Post'it note may be enough to provide a leading edge to trigger the sensor.

The test program should look something like this:

' ----------------------------------------------

Reset the test data array and counters
' Cycle through the range of PULSOUT values to be tested
For range = low_value to high_value
    ' move the wheel into test position
    Zero the wheel
    Reset the time counter
        Send a PULSOUT command to the servo
        ' in order to keep the timing constant, calculate the complement of
        ' the test value and send that to the other servo so that the elapsed
        ' time for both servos always totals to the same value
        Send a complementary PULSOUT command to the other servo
        Increment the time counter
        Check the sensor
        If the wheel has finished one rotation then update_data
        ' as the values approach and pass through the zero movement point
        ' (around 750) the servo will move extremely slowly or not at all.
        ' In those cases this loop should time out.
        If time_counter = time_out then goto update_data
        Goto Loop
    Store the time counter value in the test data array

' ----------------------------------------------

The advantages of this approach are-

  • Higher precision
  • Automated process
  • Repeatability - a major factor should it become necessary to change servos later

The primary disadvantage is -

  • Test times may turn out to be very long

Note: The Parallax BOE-BOT guide is available on their website and can be downloaded free of charge. I haven't studied it in depth yet, but a quick read-through indicates that there are lots of helpful hints and good information for anyone starting out in robotics.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>