Feedback
Have you ever tried to get shower water to exactly the right temperature? What do you do when it’s too cold? Why do you have to do it again and again?
A robot has to drive along a straight line. But the floor is bumpy and the wheels sometimes slip — the left wheel might be turning a bit faster than the right. After 10 seconds the robot has drifted to the right.
The fix: every 100 milliseconds ask the robot “where are you now?”, compare that with the target, measure the difference and correct the motors. If this loop runs 10 times a second, the robot looks like it never drifts — really it’s making small corrections all the time.
The feedback loop: Target → Action → Measure → Calculate the error → Correct → Repeat. This loop runs dozens of times a second. Robots use feedback for everything: following a line, keeping a temperature, staying balanced. A PID controller is the most common way to do this correction with math.
1️⃣ Target: go straight (error = 0) 2️⃣ Light sensor: left side dark, right side bright → “I drifted left” 3️⃣ Error = left_sensor - right_sensor = +30 (drifted left) 4️⃣ Correction: speed up the right motor, slow down the left motor 5️⃣ At the next measurement the error → gets closer to 0 6️⃣ Go back to step 1 — repeat forever
When you ride a bike, you try not to lose your balance. When you lean a little to the right, you steer left — that’s feedback! Your eyes measure the tilt (sensor), your brain decides (controller), your hands turn the handlebars (motor).
Hold a pencil and close your eyes. Try to draw a straight line. Now open your eyes and do the same — how much easier was it? Your eyes give you feedback!
A PID controller uses three terms: P (proportional), I (integral), D (derivative). Research what each one does. Why isn’t P alone enough?
What is the order of a feedback loop?