Closed-loop control is a system architecture where the output is continuously measured and fed back to compare against a target setpoint, automatically adjusting the input to minimize the error. In practical electronics, this changes a 'dumb' fixed-output circuit into a self-correcting system that shrugs off environmental disturbances. When you slap a MOSFET on a heater and feed it a fixed 80% PWM signal, you are blindly hoping the ambient room temperature and the thermal mass of your load stay perfectly constant. They won't. A closed-loop system measures the actual temperature, calculates the deficit, and dynamically modulates the power to hit the exact target.
The Core Mechanism: Error, Feedback, and Correction
Every closed-loop system relies on three fundamental variables:
- Setpoint (SP): The exact value you want to achieve (e.g., 60.0°C).
- Process Variable (PV): The actual measured value from your sensor (e.g., 52.4°C).
- Error (e): The mathematical difference between the two (SP - PV).
What people commonly confuse it with: Makers frequently confuse closed-loop control with open-loop control (like a simple 555-timer PWM driver that outputs a fixed duty cycle regardless of the load). More dangerously, many assume 'closed-loop' strictly requires a digital microcontroller running code. This is false. An analog LM317 voltage regulator is a closed-loop system; it uses an internal op-amp and resistor divider to continuously compare the output voltage against a 1.25V reference and adjusts its internal pass transistor to maintain regulation.
Worked Numeric Example: PID Thermal Controller
Let's look at the math on the bench. You are building a 3D printer heated bed controller using a standard PID (Proportional-Integral-Derivative) algorithm. Your target (SP) is 60.0°C. Your thermocouple reads the current bed temperature (PV) at 52.0°C.
The error (e) is 8.0°C. Let's assume our tuned PID gains are $K_p = 15$, $K_i = 0.5$, and $K_d = 40$. Our controller updates every 1 second ($\Delta t = 1$).
- Proportional (P) Term: Reacts to the current error.
P = Kp × e = 15 × 8.0 = 120 - Integral (I) Term: Reacts to the accumulation of past errors (eliminates steady-state offset).
I = Ki × (Sum of e) = 0.5 × 8.0 = 4.0(assuming this is the first second of the loop). - Derivative (D) Term: Reacts to the rate of change of the error (predicts the future and prevents overshoot).
Assume the previous second's error was 9.0°C. The error is shrinking by 1.0°C/sec.
D = Kd × ((e_current - e_previous) / Δt) = 40 × ((8.0 - 9.0) / 1) = -40
Total Control Effort: P + I + D = 120 + 4.0 - 40 = 84.
If we map this raw output to a 0-255 PWM scale for a Solid State Relay (SSR), the system outputs a 33% duty cycle. Notice how the Derivative term subtracted 40 from the output? Because the temperature is already rising quickly, the D-term 'backs off' the throttle early to prevent the bed from overshooting 60°C. For a deeper mathematical breakdown of tuning these gains, the University of Michigan Control Tutorials remain the gold standard for visualizing pole-zero placements and system responses.
Where You Meet This in Practice
You will encounter closed-loop architectures across almost every sub-discipline of electrical engineering:
- Switch-Mode Power Supplies (SMPS): An optocoupler continuously feeds the secondary-side output voltage back to the primary-side PWM controller (like a UC3842) to adjust the switching duty cycle, maintaining a rock-solid 5V output even if the wall voltage sags.
- DC Motor Speed/Position: An optical or magnetic encoder counts shaft rotations, feeding the data back to an H-bridge driver to maintain exact RPM under varying mechanical loads.
- Audio Amplifiers: Class AB and Class D amplifiers use negative feedback loops to compare the output signal to the input, drastically reducing Total Harmonic Distortion (THD) and flattening the frequency response.
Open Loop vs. Closed Loop: The Decision Matrix
Do you actually need the complexity of a feedback loop? Use this decision tree to choose your architecture and select the exact silicon for the job.
| Application Scenario | If Your Tolerance & Disturbances Are... | Then Choose... | Concrete Part Pick / Value |
|---|---|---|---|
| Basic LED Strip Dimming | Visual tolerance; no external thermal/mechanical disturbances. | Open-Loop (Fixed PWM) | TLC5940 16-channel PWM driver IC. |
| 12V PC Fan Cooling | ±10% speed tolerance; minor ambient temp shifts. | Open-Loop with Lookup Table | MCU GPIO driving a 2N7000 MOSFET based on a simple NTC thermistor table. |
| 3D Printer Nozzle / Bed Temp | ±1.0°C tolerance; high disturbances (part cooling fans, melting filament). | Closed-Loop (PID Control) | MAX31855 (Thermocouple SPI IC) + BTT-SSR-25A (Solid State Relay) driven by ESP32. |
| CNC Router X-Axis Position | ±0.05mm tolerance; high cutting forces causing missed steps. | Closed-Loop (Servo/Encoder) | iSV57T integrated closed-loop stepper driver with ABZ encoder feedback. |
Common Confusions and Troubleshooting Oscillation
Why is my closed-loop system oscillating wildly around the setpoint?
This is the most common failure mode on the bench. Your Proportional ($K_p$) gain is too high, or your Derivative ($K_d$) term is amplifying sensor noise. The Fix: Drop your $K_p$ value by 50% and re-tune. If you are using an analog sensor (like a basic NTC thermistor voltage divider), the ADC noise will destroy your D-term calculation. Add a hardware low-pass filter: a 10kΩ resistor in series with the analog signal line and a 100nF ceramic capacitor to ground right at the microcontroller pin. This physically smooths the noise before the software ever sees it.
Do I need a complex microcontroller to run a PID loop?
No. While the Arduino PID Library makes digital implementation trivial, you can build an analog PI controller using a single LM358 dual op-amp. One op-amp handles the proportional gain via a resistor network, and the second op-amp is wired as an integrator (with a capacitor in the feedback loop) to handle the integral term. This is exactly how legacy industrial 4-20mA process controllers operated before DSPs existed.
What happens if my sensor fails in a closed-loop system?
In an open-loop system, a broken sensor just means you lose your display readout. In a closed-loop system, a broken sensor (e.g., a snapped thermocouple wire reading 0°C) tells the controller the error is massive. The controller will respond by driving the output to 100% indefinitely, potentially causing a thermal runaway or fire. Always implement a software watchdog: if the PV reads below -10°C or above your maximum safe threshold, the code must immediately force the PWM pin LOW and trigger a hardware fault flag.
The Default Recommendation
If your load varies by more than 15% or your environment introduces unpredictable thermal or mechanical drag, default to a PI (Proportional-Integral) controller. Drop the D-term entirely unless you are controlling high-inertia systems (like a heavy flywheel or a massive vat of liquid). Cheap sensors introduce high-frequency ADC noise, and the derivative math amplifies that noise directly into your output actuator, causing chatter and premature component wear. Start with P and I, get the system stable, and only add D if you absolutely need to shave off the final 2% of overshoot settling time.






