Open loop and closed loop: what feedback does
Feedback means measuring the result again and feeding it back into the input. The difference between open and closed loop, using motor speed as the example.
Open loop
You only set the input ("60% PWM gives roughly 3000 rpm") and never check the result. It is simple and cheap, but when a load is applied or the battery voltage drops, the speed drops with it. Stepper-motor positioning and a toaster timer are open loop.
Closed loop
A sensor measures the actual speed, the difference from the target (the error) is calculated, and the input is changed in the direction that reduces the error.
target → (+) → controller → plant (motor) → output
↑(-) │
└──────── sensor ←──────────────┘
3D labRun what you have read so far→What feedback gives and what it costs
| You gain | The cost |
|---|---|
| Robustness to disturbances (load changes) | You need a sensor |
| The target is held even if the plant differs a little | Poor tuning causes oscillation or divergence |
| The response can be made faster | Sensor noise gets into the output |
In embedded systems
A control loop is, in the end, code that runs at a fixed period. Read the sensor → calculate the error → controller → update the output, every period. If the period jitters, so does control performance, so it runs from a timer interrupt or a high-priority task.