Calibration & Tuning Guide
Getting a Science Olympiad EV car dialed in comes down to a few simple concepts:
1. Push Calibration (Measuring Distance)
Instead of doing theoretical wheel diameter math that changes when the tires compress under the car's weight, you can create a simple calibration mode in code:
- Turn the motors OFF (
digitalWrite(PIN_M1_EN, HIGH)andPIN_M2_EN, HIGH) so the wheels spin freely. - Place the car at a tape mark and reset your encoder counts to zero.
- Push the car forward exactly 1.0 meter by hand.
- Read how many encoder counts were recorded on each wheel.
- Divide the average encoder counts by the distance (1 meter) to get your ticks per meter.
Save that number in your code or in flash storage (Preferences.h) so you can calculate your target distance easily:
Target Ticks = Target Meters × Ticks Per Meter
2. Gyro Calibration (Zeroing the Bias)
All gyros have a tiny bit of drift even when sitting completely still on the floor. If you don't zero this out before a run, the car will think it is turning when it's actually rolling straight.
- While sitting motionless at the starting line, take gyro readings for 1 to 2 seconds.
- Average those readings together to find your zero offset.
- During the run, subtract that offset from every reading.
3. Driving Straight (Heading Correction)
Even with identical steps sent to both motors, no car rolls in a perfectly straight line on its own because of floor seams, weight balance, or slight differences in wheel grip.
When the car is driving:
- Track your heading angle by adding up your gyro readings over time.
- If the car drifts to the right (heading > 0), slow down the left wheel (or speed up the right wheel) slightly until it points straight again.
- If the car drifts to the left (heading < 0), slow down the right wheel slightly.
Tip: Start with very small speed corrections. If the correction is too aggressive, the car will wobble back and forth like a snake.
4. Stopping Without Skidding
Never stop a stepper car by suddenly commanding the motors to zero speed. The car's weight and momentum will cause the rubber tires to skid on the gym floor, which will mess up your final distance and score.
- Accelerate smoothly over the first meter of the run.
- When you are getting close to your target distance, gradually ramp your motor speed down.
- The car should come to a smooth, controlled stop right on the mark with full tire traction.