error × Kp = correction 〰️ → ──
🎒 What you need
- the simulator from module 5, still set up
- your logged table of times
- paper for a tuning table
✋ Do this
- Define error properly: how far the sensor reading is from where you want it. Write that one line of code first, and print it.
- Replace your on-off rule with: correction = Kp * error. Start with a small Kp. Run it.
- Log three columns for every run: Kp, lap time, and how much it wobbled from one to five.
- Raise Kp steadily. At some point the robot starts oscillating and never settles. Write down that Kp — you have found the point of instability yourself.
- Now drop Kp too low. It drifts off the line lazily and misses corners. Note that number too. Good tuning lives between your two failures.
- Pick your best Kp and run it three times to prove it was not luck. Then explain, in one sentence, what Kp physically means.
💡 Why it works
The P in PID is proportional control, and on many real systems it is enough on its own. Too little gain and the system is sluggish; too much and it oscillates — exactly what you measured. The I and D terms exist to fix two specific leftover problems, steady offset and overshoot, but tuning always starts here, and it always starts with finding the two failure points.
🔥 Challenge
Add a D term: subtract a small multiple of how fast the error is changing. Retune and see whether you can push Kp higher without oscillation. That is damping, and you can feel it working.
📖 New words
errorthe difference between where you are and where you want to be
gainthe multiplier that turns error into correction, often called Kp
oscillationswinging back and forth past the target without settling
📉
Gain Tuner
Tap when you have finished this module.