A closed loop control is a system that continuously measures its actual output, compares it to a desired target, and automatically adjusts its input to eliminate the difference. Unlike open-loop systems that blindly send a fixed command and hope for the best, a closed-loop architecture uses real-time sensor feedback to fight off physical disturbances like temperature drift, mechanical load changes, and voltage sag.
The Core Mechanism: Feedback and Error Correction
In a physical circuit, closed loop control changes your design philosophy entirely: it shifts the burden of accuracy away from expensive, temperature-stable analog components and places it onto cheap digital computation and feedback sensors. Instead of buying a $40 precision voltage reference that drifts 5mV over temperature, you use a $2 microcontroller, a $1 shunt resistor, and a software algorithm to achieve the same stability.
The architecture always follows a specific signal path. The controller reads the Process Variable (PV) from a sensor, subtracts it from the Setpoint (SP) to calculate the error, and passes that error through a control algorithm (usually PID) to adjust the actuator.
Where You Meet This in Practice
You interact with closed loop control constantly on the bench and in the field. Here is where it shows up in standard maker and trade applications:
- 3D Printer Hotends: A thermistor reads the block temperature (PV). The Marlin firmware calculates the error against your 210°C target (SP) and runs a PID algorithm to output a PWM duty cycle to the heater cartridge, compensating for the cooling fan turning on.
- Solar MPPT Charge Controllers: The controller constantly perturbs the solar panel voltage and measures the resulting current. It closes the loop around the maximum power point, adjusting the buck converter's duty cycle to keep the panel at its optimal impedance match despite passing clouds.
- Drone Flight Controllers (ESC): The flight controller commands a specific RPM to the Electronic Speed Controller. The ESC uses the motor's back-EMF zero-crossings as feedback to commutate the stator coils at the exact right microsecond, closing the loop on rotor position.
Worked Numeric Example: Tuning a 12V DC Motor Speed Controller
Let's look at the math on the bench. You are building a conveyor belt driven by a 12V DC motor. You need it to run at exactly 1500 RPM. You are using an ESP32, an L298N motor driver, and a quadrature encoder for feedback. You decide to start with a simple Proportional (P) controller.
- Define the Setpoint: Target speed = 1500 RPM.
- Read the Process Variable: The encoder reads the current speed at 1200 RPM (the belt has a heavy box on it, causing drag).
- Calculate Error: Error = Setpoint - PV = 1500 - 1200 = +300 RPM.
- Apply Proportional Gain (Kp): You set Kp to 0.2. The P-term output is 300 × 0.2 = 60.
- Update the Actuator: Your base PWM value to overcome static friction is 100. The new PWM command is 100 + 60 = 160 (out of 255).
The ESP32 updates the PWM pin to 160. The motor gets more voltage, torque increases, and the speed climbs to 1450 RPM. The error drops to 50 RPM, the P-term drops to 10, and the system settles. For a deeper dive into adding Integral and Derivative terms to eliminate that remaining 50 RPM offset, review the Arduino PID library documentation.
Real-World Scenario Walkthrough: When the Loop Goes Unstable
Closed-loop systems are powerful, but they can violently oscillate if tuned poorly. Here is a failure mode I see frequently when builders rush through sensor integration.
Setup: You are building a custom LiFePO4 battery charger using an ESP32, a buck converter module, and an INA219 I2C current sensor. The goal is to hold a constant charge current (CC) of exactly 10.0A. You write a simple proportional control loop to adjust the buck converter's feedback pin voltage via a DAC.
Numbers: You set your Proportional gain (Kp) aggressively high at 5.0 to 'make it respond fast'. The target is 10.0A. The sensor reads 9.5A. The error is +0.5A. The controller multiplies 0.5A × 5.0 = 2.5A, and aggressively increases the DAC output to command 12.5A.
Outcome: The current spikes to 12.8A. The controller panics, calculates a massive negative error, and slashes the DAC output. The current drops to 6.5A. The loop begins oscillating wildly between 6A and 13A at roughly 4 Hz. The battery BMS triggers an overcurrent fault and disconnects.
What Went Wrong: You ignored the phase lag introduced by the sensor. The INA219, configured for maximum resolution, has a conversion time of roughly 500µs. Combined with the I2C bus latency and the buck converter's LC filter response time, your control loop is reacting to data that is 'old'. When Kp is high, this delay causes the controller to overcorrect before the physical system has time to respond to the previous command. The fix is twofold: lower Kp to 0.5, and implement a software low-pass filter (like an exponential moving average) on the INA219 readings to smooth out high-frequency noise before it hits the PID math.
Common Confusions: Closed Loop vs. Open Loop vs. Feedforward
People commonly confuse 'closed loop' with 'automated'. A timer-based sprinkler system is automated, but it is strictly open loop—it waters the grass whether it is raining or not, because it has no soil moisture sensor feeding back into the decision. Here is how the three main control topologies compare:
| Topology | Uses Feedback? | React to Disturbances? | Best Use Case |
|---|---|---|---|
| Open Loop | No | No (Blind execution) | Simple timers, basic stepper motor moves without encoders. |
| Closed Loop (Feedback) | Yes | Yes (Corrects after error occurs) | Temperature control, motor speed, voltage regulation. |
| Feedforward | No (Uses disturbance measurement) | Yes (Acts before error occurs) | Often combined with closed-loop; e.g., adding extra heater power the exact moment a cooling fan turns on. |
For a comprehensive mathematical breakdown of how these topologies handle steady-state error and transient response, refer to standard PID controller theory resources.
FAQ: Troubleshooting Closed-Loop Instability
Why is my system oscillating around the setpoint?
Oscillation is almost always caused by a Proportional gain (Kp) that is too high, or unfiltered sensor noise. The controller is overreacting to tiny changes. Lower your Kp by 50% and add a moving average filter to your sensor reading array.
Why does my motor never quite reach the target RPM?
This is called steady-state error. A purely Proportional controller requires an error to exist in order to output a corrective signal. To eliminate the final 2% of error, you must add an Integral (I) term to your algorithm, which accumulates the error over time and forces the output to push until the error is truly zero.
My actuator is hitting its maximum limit (saturation). What do I do?
If your PWM is hitting 255 (100%) and you still have error, your physical plant is undersized for the load. No amount of software tuning can fix a motor that lacks the torque or a heater that lacks the wattage. You must upgrade the hardware or reduce the setpoint.






