For the latest releases of Minibit and BitBot XL, 4tronix have added DriveStraight technology in the hardware and Makecode extensions.
This works using a Flash memory chip which stores the calibration details of the motors at three different speeds: 30%, 60% and 90%. This information is used to generate the actual speeds used for each motor to give the best chance of moving straight ahead when required.
Because this data is stored in permanent memory, it only needs to be calibrated once and then it will automatically be used from then on. You don’t have to do anything in your programs for it to be used and it doesn’t matter if you change the Microbit at any point. The calibration data is specific to the robot it is created on – it isn’t related to the Microbit at all. So you can swap between Microbits including v1 and v2 types.
You may find that the calibration data changes over time as the motors wear differently. If it gets too far out, then simply run the calibration program again.
DriveStraight is built into the latest Makecode extensions. It isn’t available in Python, although you can access the Flash memory from Python and use it yourself.
On the Minibit, you also have user access to the rest of the Flash memory. You can use this for what you like: storing sequences, remembering particular LED settings, etc. This feature will be added to the BitBot code shortly.
BitBot XL calibration code >here<
Minibit calibration code >here<
Calibrating the Motors
Note that this code only works on BitBot XL v1.2 or later, or Minibit v1.3 or later.
Process: The calibration program starts at speed 30 (displaying 3 on the Microbit LEDs). You then set the left or right speeds until it is driving straight. Then give the robot a good shake and it will change to speed 60 (displaying 6). Set this speed, shake again to change to speed 90 (displaying 9). Once this speed is set correctly, shake again and it will return to speed 30. You can then switch off and all the values are stored. If you run the program again, you will start from the un-calibrated values and must follow all the steps again.
- Load the program into the Microbit and plug it into the robot
- Switch on the robot. It will display 13 (indicating a v1.3 Minibit) or 5 (indicating a v1.2 BitBot XL), then change to show 3 (meaning speed 30)
- Press A or B buttons to affect the turning left or right, then press both A+B simultaneously and the robot will display the current calibration value, then move forward for 2 seconds at speed 30.
- If it is still not moving straight, press the appropriate button one or more times to straighten it up, then press A+B again to test it
- When you’re happy that it is moving straight, give the robot a shake and it will store the values for speed 30 and move onto Speed 60.
- Repeat for speed 60 and speed 90
- When you’re happy that all three speeds are set correctly, then switch off. Don’t switch it back on again without changing the software in the Microbit, because the first action of the calibration program is to reset the calibration values.