Calibrate Your ActivityBot

Before running any other example programs, your ActivityBot needs to be calibrated.  This is a one-time calibration that the abdrive library needs for measuring and correcting disances and speeds, using information from the ActivityBot encoders.

The calibration collects requested speed vs. measured speed data and stores it in a part of the ActivityBoard’s EEPROM memory, where it can retain data even after you turn the power off.  That way, the calibration data is available every time you turn the robot back on. 

When your program asks for a certain wheel speed, the abdrive library will use the calibration data from EEPROM to start driving the motors at speeds close to what your program asks for.  That way, abdrive doesn’t have to make large corrections, just small ones, which improves overall accuracy.




Test Code


The calibration program takes less than 2 minutes to collect all of its data.  You will need a smooth and obstacle-free floor area that’s roughly one meter square.  While the calibration program is running, the ActivityBot will go in circles at various speeds, using only one wheel at a time.  It will let you know when its done by turning off its P26 and P27 lights (below the breadboard).  The above video shows an ActivityBot correctly performing the calibration.

IMPORTANT! Your ActivityBot Library needs to be installed in the correct location BEFORE attempting to run this, or any other, ActivityBot program.

The ActivityBot library folder should be in ...Documents\SimpleIDE\Learn\Simple Libraries\Robotics. If you install the library folder yourself, unzip the library folder and then make sure to close and then re-open SimpleIDE before continuing on to allow the software to cache the library location.

Return to Software and Programming for the library download and additional instructions, if necessary.

  • Set the ActivityBot's power switch to 1
  • Click SimpleIDE’s Open Project button
  • Open ActivityBot Calibrate from ...Documents/SimpleIDE/Learn/Examples/ActivityBot
  • Click the Load EEPROM & Run button.  (Important: this program needs to be in EEPROM)
  • When the program is finished loading, the P26 and P27 lights will turn on.  When they come on, turn off the robot's power (Slide PWR switch to 0)
  • Disconnect the ActivityBot from its programming cable and set it in a 1 meter, obstacle-free, smooth floor area
  • Set the power switch to 2 and move back to give it room to spin in place and slowly roam while it gathers wheel speed data. 


What if it Didn't Work?
If your robot didn't move when you started the calibration program, or it started going backwards first instead of forwards, or if it started and stopped right away or just twitched, go to the Troubleshooting page for help.

Re-starting the Calibration Program
If you need to re-start the calibration process, you can push the reset button any time while the P26 and P27 lights are on. Once the calibration process is complete, the program image gets modified so that it cannot run a second time. This keeps it from trying to re-calibrate the next time you turn power on to load a new program.  If you want to re-run the calibration, you will need to use SimpleIDE to load ActivityBot Calibrate into EEPROM again. 


How it Works

This example program turns on the P26 and P27 LEDs with high(26) and high(27).  It then calls the abcalibrate library’s cal_activityBot function, which takes the robot through the sequence of motions you just observed.  While performing the maneuvers, the cal_activityBot function builds a list of wheel speeds that correspond to the various drive levels it applies to the servos.  It stores those values in EEPROM so that every ActivityBot navigation program can use them to find out what drive level is needed for going a given speed.  When the cal_activityBot function is done, the program turns off the P26 and P27 lights with low(26) and low(27).

  ActivityBot Calibrate.c

  Calibrate the ActivityBot's servos and encoders

#include "simpletools.h"
#include "abcalibrate.h"    

int main()
  cal_servoPins(12, 13);
  cal_encoderPins(14, 15);

Did You Know?

Encoder Ticks - Each ActivityBot encoder shines infrared light at the ring of 32 spokes in the wheel next to it.  If the light passes between the spokes, the encoder sends the Propeller a high signal.  If it bounces off a spoke and reflects back to the encoder’s light sensor, it sends a low signal to the Propeller.  Each time the signal changes from high to low, or low to high, the Propeller chip counts it as an encoder tick.

Sensing Direction — The Propeller chip knows what direction the servos turn based on the signal it uses to make the servo move.  All it needs from the encoder is to know how fast it’s turning. It does this by counting encoder ticks over a period of time.  The libraries keep track of all this for you, so your programs just need to tell the robot robot how far or how fast to go.



Interpolation — The cal_activityBot function builds a table of data points for motor drive level and the actual speed the wheels turned.  Navigation programs will use those data points to figure out how hard to drive a wheel to get a certain speed.  If the speed the program asks for is between two data points, the navigation library will figure out the best drive value between two of the known values.  For example, if the table has data points for 60 and 80 encoder ticks per second, and your program asks for 70 ticks per second, the navigation library will use a motor drive level that’s half way between the 60 and 80 ticks per second levels.  This process is called interpolation and the data set is called a linear interpolation table.


Try This

Want to see the interpolation table?  It’s the data that shows drive levels and measured wheel speeds in encoder ticks per second. 

You can use the program below to view it.

  • In SimpleIDE, open ActivityBot Display Calibration from ...Documents/SimpleIDE/Learn/Examples/ActivityBot.
  • Set the PWR switch to 1.
  • Then, click the Run with Terminal button to see the interpolation table values in the SimpleIDE terminal.
#include "simpletools.h"
#include "abdrive.h"

int main()                   



The interpolation table data can be very helpful for troubleshooting if your robot does not drive as expected after calibration.