ONLY FOR EXTERNAL ENCODERS!
If you are using Feedback 360° servos, go to Feedback 360 Encoder Calibration [1] instead.
If your ActivityBot has external encoders, you MUST calibrate it before running any other example programs. This one-time calibration is necessary for the Robot blocks to measure and correct distances and speeds, using information from the ActivityBot encoders.
The calibration code takes less than 2 minutes to collect all of its data. You will need a smooth and obstacle-free, floor area that is roughly 1-meter square (3 ft. x 3 ft.). 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 it's done by turning off its P26 and P27 lights (below the breadboard). The video below shows an ActivityBot correctly performing the calibration.
IMPORTANT! USE FRESH BATTERIES FOR THIS STEP!
What if it didn't work?
If your robot did not move when you started the calibration program, or it started going backward first instead of forward, or if it started and stopped right away or just twitched, go to the Troubleshooting [3] page for help.
What if I need to restart or repeat the calibration?
To restart the calibration process, push the reset button any time while the P26 and P27 lights are on.
To repeat the calibration process once it has fully completed, you will need to use BlocklyProp to reload the program. That is because the program modifies itself at the end so that it cannot run a second time. This keeps your ActivityBot from trying to recalibrate the next time you turn power on to load a new program.
Notice that the ActivityBot calibrate block does not have any sockets or plugs for connecting it to other blocks. It is meant to be used by itself without any other blocks in a program, and it takes care of the entire calibration process automatically.
The ActivityBot calibrate block collects requested speed vs. measured speed data and stores it in a part of the Activity Board’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.
Later, when your project includes Robot blocks that set a certain wheel speed, the underlying code will use the calibration data from EEPROM to start driving the motors at speeds close to what your program asks. That way, the code doesn’t have to make large corrections, just small ones, which improves overall accuracy.
Encoders — An encoder converts information from one format to another. The ActivityBot's encoders convert wheel rotation or position into digital information that the Propeller microcontroller can use.
Encoder Ticks are not insects — Throughout this tutorial, you will see the term ticks used to describe the ActivityBot's wheels turning. In this context, a tick means 1/64th of a wheel revolution. When the wheel makes one complete revolution, it has turned 64 ticks. We use ticks per second to note how fast the wheels are turning. Ticks can also refer to distance traveled when considering the circumference of the ActivityBot wheel.
ActivityBot External Encoders — Each ActivityBot external encoder shines infrared light at the ring of 32 spokes in the wheel next to it. If the light passes between these spokes, then the encoder sends the Propeller a high signal. If it bounces off a spoke and reflects back onto the encoder’s light sensor, then 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. You may also see the term encoder increment.
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. BlocklyProp blocks keep track of all this for you, so your programs need to tell the robot only how far or how fast to go.
Interpolation — The calibration code builds a table of data points for motor drive level and the actual speed the wheels turned, and stores it in the Activity Board's EEPROM memory. Other Robot blocks will use those data points to figure out how hard to drive a wheel to get a certain speed. If the speed the block asks for is between two data points, then the underlying C libraries will calculate the best drive value between the two of them. For example, if the table has data points for 60 and 80 encoder ticks per second, and your block asks for 70 ticks per second, the underlying libraries will use a motor drive level that’s halfway between the 60 and 80 ticks per second levels. This process is called interpolation, and the data set is called a linear interpolation table.
There is a block that can check the ActivityBot's calibration data and tell you if there are any mistakes or problems with the ActivityBot's servo, encoder, and battery connections. If this test says the calibration was successful, your ActivityBot will be ready to run navigation programs. If not, then it will tell you what problem(s) it has detected. After finding it and fixing it, make sure to run both the calibration and this test again. Your ActivityBot won't be ready for navigation until it is both calibrated AND passes this test!
Now that your ActivityBot is calibrated, it is time to run a simple test program to make it drive straight forward. The test code below makes both wheels turn forward at 64 encoder ticks per second for 5 seconds. This code should make your ActivityBot roll forward about 1 meter (3 ft.).
Your robot should travel forward for about 1 meter (3 ft.) in a straight line. You may see slight shifts as the robot adjusts its course based on encoder feedback.
The first block is Robot initialize, with the drop-down menu set to ActivityBot. Place this block at the beginning of all projects that use Robot set... or Robot drive... blocks. Next is a Robot drive speed block with the number value 64 attached to both its left and right sockets, making both the left wheel and right wheel rotate forward at a rate of 64 ticks per second. The pause 5000 block lets the ActivityBot drive forward at this rate for 5000 ms (5 seconds). After that, a second Robot drive speed block stops the right and left wheels with the number values 0, 0. We will explore this more on the next page.
What if it Didn't Work? If your robot did not move, or went backward, or moved in a series of short, jerky arcs instead of heading forward, see the Troubleshooting [3] page.
Links
[1] http://learn.parallax.com/node/1710
[2] http://learn.parallax.com/tutorials/robot/activitybot/blocklyprop-robotics-activitybot/electrical-connections
[3] http://learn.parallax.com/tutorials/robot/activitybot/blocklyprop-robotics-activitybot/activitybot-troubleshooting
[4] https://learn.parallax.com/tutorials/robot/activitybot/blocklyprop-robotics-activitybot/activitybot-troubleshooting