ONLY FOR EXTERNAL ENCODERS!
If you are using Feedback 360° servos, go to Feedback 360 Encoder Calibration 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.
- If you have not already completed the Electrical Connections tutorial, do that first and then return here.
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!
- Log into your BlocklyProp account, and run and connect the BlocklyProp client on your computer.
- Set the ActivityBot's power switch to 1, and connect it to your computer via the USB cable.
- Start a new Propeller C project for the Activity Board.
- From the ROBOT block menu, place the ActivityBot calibrate block in the workspace.
- Click the Load and run (save to EEPROM) 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 by sliding the power switch to 0.
- Disconnect the ActivityBot from its programming cable and set it in a 1-meter square (3 ft. x 3 ft.), 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.
- Leave it alone until the P26 and P27 lights turn off (about 2 minutes). After that, calibration is complete, and you can turn the power off again.
- IMPORTANT: Complete the Try This section on this page before doing anything else with your ActivityBot.
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 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.
How it Works
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.
Did You Know?
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!
- Set the ActivityBot's power switch to 0, and reconnect the USB cable.
- Create a new project and drag an ActivityBot display calibration block into the workspace.
- Set the power switch back to 1, then click the Load and run (save to EEPROM) button.
- Check the Terminal output.
- If the Terminal output says "...calibration completed successfully", you can skip to the Your Turn section because the servos, encoders, and power are all connected correctly. So, your ActivityBot is ready to run navigation programs.
- If the results in the Terminal say "...one or more problems were detected", it means that there is probably a mistake in the servo, encoder, or power connections.
(If this is the case, your ActivityBot IS NOT READY to run navigation programs yet.)
- Make a note of the details the Terminal reported. Then, find those details on the Troubleshooting page, and follow the instructions it provides for solving the problem.
- When you find and fix the first problem, you will need to rerun the calibration program (above). Then, rerun this test. Repeat until you get the "...calibration completed successfully" message.
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.).
- Build the project shown below.
- Reconnect your ActivityBot to your computer with the USB cable, and set the power switch to 1.
- Set the COM port, then click the Load and run (save to EEPROM) button.
- After the program is loaded, set the power switch to 0 and disconnect the USB cable.
- While holding the reset button down, set the power switch to 2, and place the robot down on a hard, smooth floor.
- Release the reset button, and monitor the robot’s travel.
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.
How it Works
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 page.