A closed loop control system is a circuit or mechanism that continuously measures its actual output, compares it to a desired target, and automatically adjusts its input to minimize the difference. In a real circuit or installation, this changes a "dumb" fixed-output actuator into a responsive, self-correcting system by adding a sensor and a feedback path to the microcontroller. Think of it like a car's cruise control: you set the target speed (setpoint), the speedometer measures your actual speed (feedback), and the ECU adjusts the throttle (actuator) to handle hills and wind resistance.
The Core Mechanics: Setpoint, Error, and Feedback
Every closed-loop architecture shares the same fundamental signal path, whether you are building a DIY reflow oven or programming an industrial PLC. The loop consists of four main stages:
- Setpoint (SP): The target value you want to achieve (e.g., 210°C for a 3D printer hotend).
- Process Variable (PV): The actual measured value from your sensor (e.g., 185°C read via a 100kΩ NTC thermistor).
- Error (e): The mathematical difference between the two ($e = SP - PV$). In this case, $210 - 185 = +25°C$.
- Control Algorithm & Actuator: The microcontroller processes the error (usually via a PID algorithm) and outputs a control signal, like a PWM duty cycle to an IRLZ44N MOSFET, to drive the heater cartridge.
The "closed" part of the name refers to the physical wiring and logic loop: the output of the plant (the heater) affects the environment, which is read by the sensor, which feeds back into the microcontroller, closing the circle. According to foundational control system theory from National Instruments, this feedback mechanism is what allows systems to reject external disturbances—like a fan blowing on your hotend or a sudden drop in mains voltage.
Worked Numeric Example: Tuning a 3D Printer Hotend PID
To understand how the math actually drives the hardware, let us look at a Proportional-Integral-Derivative (PID) controller driving a 12V, 40W heater cartridge via an ESP32's 12-bit PWM output (0-255 scale).
Scenario: You command the hotend to 210°C. The thermistor currently reads 180°C. The error is +30°C.
- Proportional Term (P): This reacts to the current error. If your $K_p$ (proportional gain) is tuned to 8.5, the P-term calculation is $8.5 \times 30 = 255$. Since 255 is the maximum 8-bit PWM value, the microcontroller drives the MOSFET at 100% duty cycle. The heater is fully on.
- Integral Term (I): This reacts to accumulated past error. If the heater has been stuck at 180°C for 10 seconds due to a massive cooling fan blowing on it, the I-term slowly winds up, adding extra PWM percentage to force the temperature higher.
- Derivative Term (D): This reacts to the rate of change. As the temperature rapidly climbs from 195°C to 208°C in two seconds, the D-term recognizes the fast approach and actively subtracts from the PWM output to apply the brakes, preventing overshoot.
The Real-World Gotcha (Integral Windup): When the error is large (30°C), the P-term already maxes out the PWM at 255. If your code does not limit the I-term, the integral will keep accumulating while the heater is maxed out. By the time the hotend finally hits 210°C, the massive stored I-term will keep the heater at 100%, causing the temperature to overshoot dangerously to 235°C, potentially melting your PTFE tube. Proper closed-loop code must include anti-windup clamping to stop the I-term from accumulating when the actuator is saturated.
Where You Meet Closed-Loop Systems in Practice
You are likely already using closed-loop systems on your workbench, even if you have not mapped out the block diagrams. Here is where they show up in maker and trade environments:
- 3D Printer Hotends and Heated Beds: Firmware like Marlin uses PID tuning (often via the M303 G-code command) to calculate the exact $K_p$, $K_i$, and $K_d$ constants for your specific heater and thermistor combination.
- Solar MPPT Charge Controllers: Unlike cheap PWM controllers that just clamp the solar panel voltage to the battery voltage, a Maximum Power Point Tracking (MPPT) controller uses a closed-loop algorithm (like Perturb and Observe) to constantly adjust the duty cycle of a synchronous buck converter. It measures panel voltage and current via shunt resistors, hunting for the exact impedance match that yields maximum wattage.
- Brushless DC (BLDC) Motor ESCs: Electronic Speed Controllers for drones use closed-loop commutation. They read the back-EMF (electromotive force) from the floating motor phase or use Hall-effect sensors to determine the exact rotor position, firing the MOSFET bridge at the precise microsecond needed to keep the motor spinning smoothly under varying propeller loads.
- Variable Frequency Drives (VFDs): In industrial settings, a VFD uses closed-loop vector control to maintain exact torque and speed on a 3-phase AC induction motor, reading phase currents and adjusting the PWM switching frequency in real-time.
Open-Loop vs. Closed-Loop: What People Commonly Confuse
The most common mistake beginners make is assuming that any automated system is closed-loop. A timer is not a closed-loop system.
If you wire a relay to an ESP32 to turn on a slow cooker for exactly 45 minutes, that is open-loop. The microcontroller has no idea if the food is actually cooked; it only knows that 45 minutes have passed. If you start with frozen meat instead of thawed meat, the open-loop system fails because it cannot measure the output (food temperature) and adjust the time.
Similarly, a basic sprinkler system that runs for 15 minutes every morning is open-loop. It will happily water your lawn during a rainstorm because it lacks a soil moisture sensor to provide feedback. To convert it to closed-loop, you must add a capacitive soil moisture sensor to the analog input and program the logic to skip the watering cycle if the soil volumetric water content is already above 30%.
Frequently Asked Questions
What is the difference between open loop and closed loop control systems?
An open-loop system executes a pre-programmed command without checking the result (like a toaster on a timer). A closed-loop system continuously measures the actual output via a sensor and adjusts its power to hit a specific target (like an air fryer with a thermistor). Closed-loop systems are more complex and require tuning, but they are immune to external disturbances that would ruin an open-loop process.
Is a standard home thermostat a closed loop system?
Yes. A traditional HVAC thermostat measures the ambient room air temperature (Process Variable) and compares it to your dialed-in setting (Setpoint). If the room is 68°F and you want 72°F, the error is +4°F, and the thermostat closes the relay to fire the furnace. Once the sensor reads 72°F, the error drops to zero, and the relay opens. Modern smart thermostats add derivative and integral logic to anticipate heat loss and prevent the room from overshooting the target.
Why does my closed loop motor controller oscillate or overshoot?
Oscillation (hunting) in a closed-loop DC motor or temperature controller is almost always caused by the Proportional gain ($K_p$) being set too high, or a lack of Derivative ($K_d$) damping. If $K_p$ is too aggressive, the system applies 100% power when it is far from the target, and by the time it reaches the setpoint, the physical momentum or thermal mass carries it past the target. The controller then aggressively applies reverse power or cooling, causing it to undershoot, creating a continuous sine-wave oscillation. Lower your $K_p$ and increase your $K_d$ to stabilize the loop.






