rAs Kids All courses
Robotics with Python · Module 6 of 8
📱 Shared phone

Proportional Control, No Panic

Correct in proportion to how wrong you are — small error, small nudge; big error, big shove.

error × Kp = correction 〰️ → ──
Two traces side by side: one wobbling wildly, one settling smoothly onto the line.

🎒 What you need

✋ Do this

  1. Define error properly: how far the sensor reading is from where you want it. Write that one line of code first, and print it.
  2. Replace your on-off rule with: correction = Kp * error. Start with a small Kp. Run it.
  3. Log three columns for every run: Kp, lap time, and how much it wobbled from one to five.
  4. 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.
  5. 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.
  6. 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.