69 PID: Feedback Fundamentals
69.1 Learning Objectives
By the end of this chapter, you will be able to:
- Explain Feedback Concepts: Describe how feedback loops measure output, compare to setpoint, and adjust input
- Classify Feedback Examples: Categorize feedback mechanisms in everyday devices and IoT systems by type
- Differentiate Feedback Types: Contrast positive and negative feedback and predict their effects on system stability
- Design Distributed Feedback: Architect IoT systems that implement feedback across network boundaries with edge fallback
MVU: Minimum Viable Understanding
Core concept: Feedback is when a system uses its output to adjust its input - like checking your speed while driving and adjusting the gas pedal accordingly. Why it matters: Without feedback, systems operate blindly and cannot adapt to changing conditions or disturbances. Key takeaway: Most IoT control applications use negative feedback to maintain stable setpoints, while positive feedback is reserved for specialized applications like signal amplification.
69.2 Prerequisites
Before diving into this chapter, you should be familiar with:
- Sensor Fundamentals and Types: Understanding sensor characteristics and how they measure physical variables is essential for implementing effective feedback control systems
- Actuators: Knowledge of actuator types and control methods is critical since feedback systems ultimately drive actuators
- Processes & Systems: Fundamentals: Familiarity with systems thinking, input-output relationships, and process definitions
For Beginners: Feedback Control
Imagine driving a car and trying to maintain exactly 60 mph. You look at the speedometer (sensor), see you’re at 58 mph (error = 2 mph too slow), so you press the gas pedal a bit (control action). You continuously adjust based on what you see - that’s feedback control.
Everyday Analogy: Your home thermostat is a perfect feedback example. It doesn’t just turn heat “fully on” or “fully off.” Instead, it measures room temperature (output), compares to your target, and adjusts heating accordingly.
| Term | Simple Explanation |
|---|---|
| Feedback | Using output to adjust input, like steering based on where your car is going |
| Set Point | Your desired target value (e.g., 72F room temperature) |
| Error | The difference between where you want to be and where you are |
| Sensor | Device that measures the output (like a thermometer) |
| Actuator | Device that takes action (like a heater or valve) |
Why This Matters for IoT: Feedback enables autonomous operation - your smart home can maintain temperature without you constantly adjusting the thermostat.
For Kids: Meet the Sensor Squad!
Feedback is like having a helper who checks your work and tells you how to do better!
69.2.1 The Sensor Squad Adventure: The Perfect Temperature Room
Lila the LED loved her plants, but they were SO picky! Her tomato plants needed the greenhouse to stay at exactly 75 degrees - not too hot, not too cold.
“How do I know when it’s too hot or too cold?” wondered Lila.
Sammy the Sensor had an idea! “I’ll keep checking the temperature and tell you what’s happening. If it’s too cold, we turn on the heater. If it’s too hot, we turn it off!”
Max the Microcontroller set up the system: “Sammy checks the temperature, tells me the number, I compare it to 75, and decide what to do. It’s like a loop that keeps going around and around!”
And that’s exactly what happened. Every few seconds, Sammy checked, Max decided, and the heater adjusted. The plants stayed happy at exactly 75 degrees!
69.2.2 Key Words for Kids
| Word | What It Means |
|---|---|
| Feedback | When you use information about what happened to decide what to do next |
| Loop | Something that goes around and around, checking and adjusting |
| Sensor | Like your eyes or ears - it notices what’s happening |
| Target | What you’re trying to achieve (like 75 degrees) |
69.2.3 Try This at Home!
The Blindfolded Walking Game:
- Put a pillow across the room as your target
- Close your eyes and walk toward it
- Have a friend say “warmer” or “colder” based on your distance
- That’s feedback helping you reach your target!
69.3 What is Feedback?
Feedback is a fundamental concept where a portion of a system’s output is routed back to influence the input. This creates a self-regulating mechanism that can improve system performance, stability, and accuracy.
69.4 Everyday Feedback Examples
We encounter feedback constantly in daily life:
- Thermostat: Room temperature (output) is measured and compared to the desired temperature (input), adjusting heating/cooling accordingly
- Cruise control: Vehicle speed (output) is monitored and throttle (input) is adjusted to maintain set speed
- Refrigerator: Internal temperature (output) controls compressor on/off cycles (input)
- Shower temperature: You feel water temperature and adjust hot/cold knobs
In IoT systems, feedback enables autonomous operation and adaptation to changing conditions.
69.5 Feedback in IoT Applications
IoT devices leverage feedback for various purposes:
- Environmental Control
- Smart thermostats, greenhouse automation, HVAC systems
- Process Monitoring
- Industrial sensors adjusting manufacturing parameters in real-time
- Safety Systems
- Automatic shutoffs when dangerous conditions detected
- Energy Management
- Battery monitoring systems adjusting charging rates
- Distributed Feedback
- Water quality monitoring where local sensors trigger remote actuators
Distributed IoT Feedback System: Sensor nodes transmit water quality data to cloud platform, where rule engine evaluates conditions and sends commands to remote actuator nodes, creating a closed feedback loop across network boundaries.
This distributed feedback system demonstrates how IoT architectures can implement control loops across multiple devices and network boundaries, with cloud-based decision-making coordinating local sensor and actuator nodes.
69.6 Negative vs Positive Feedback
Understanding the two types of feedback is essential for control system design:
Negative vs Positive Feedback Comparison: Negative feedback opposes changes to stabilize the system (thermostat reducing heat as temperature approaches target). Positive feedback amplifies changes, leading to runaway growth or oscillation.
Negative Feedback (most common in IoT):
- Opposes changes from the set point
- Provides stability and regulation
- Example: Thermostat reducing heat as temperature approaches target
Positive Feedback (less common, specialized uses):
- Reinforces changes from the set point
- Can cause instability or rapid state changes
- Example: Schmitt trigger with hysteresis for noise immunity
Alternative View: Control System Evolution Timeline
This variant shows the historical and conceptual progression from simple on/off control to sophisticated PID control, helping students understand why each advancement was necessary.
69.7 Worked Example: Designing Feedback Control for a Smart Greenhouse
Scenario: A tomato greenhouse uses an ESP32 microcontroller, a DHT22 temperature/humidity sensor, a 1,500W heater (relay-controlled), and a ventilation fan (PWM-controlled). The target temperature is 24C during day and 18C at night. Design the feedback control system, calculate response times, and compare on/off control versus proportional control.
Step 1: Characterize the System (Plant Model)
First, measure how the greenhouse responds to heating input:
Greenhouse thermal characteristics:
Volume: 50 m3 (5m x 5m x 2m)
Air mass: 50 m3 x 1.2 kg/m3 = 60 kg
Specific heat of air: 1,005 J/(kg.C)
Thermal capacity: 60 x 1,005 = 60,300 J/C
Heater power: 1,500 W
Heating rate: 1,500 / 60,300 = 0.025 C/second = 1.5 C/minute
Heat loss rate (winter, outdoor = 5C, indoor = 24C):
U-value (polycarbonate walls): 3.5 W/(m2.C)
Surface area: 70 m2
Heat loss: 3.5 x 70 x (24 - 5) = 4,655 W
Net heating: 1,500 - 4,655 = -3,155 W (heater alone cannot maintain 24C!)
Putting Numbers to It
The thermal time constant determines how fast the greenhouse responds to heating. Using Newton’s Law of Cooling:
\[ \tau = \frac{m \cdot c_p}{U \cdot A} = \frac{60 \text{ kg} \times 1{,}005 \text{ J/(kg·°C)}}{3.5 \text{ W/(m}^2\text{·°C)} \times 70 \text{ m}^2} = \frac{60{,}300}{245} \approx 246 \text{ seconds} \]
This means the greenhouse temperature reaches 63% of a step change in ~4 minutes. For control loop design, sample every \(\tau/10 \approx 25\) seconds. Faster sampling wastes energy; slower sampling risks overshoot.
Problem identified: The heater cannot overcome winter heat loss. Solution: add a second 2,000W heater (total 3,500W). Net heating becomes 3,500 - 4,655 = still negative at peak loss, but with solar gain during day (~2,000W average), total is 3,500 + 2,000 - 4,655 = 845W net positive.
Step 2: On/Off Control (Bang-Bang) Analysis
Simple approach: heater ON when temperature is below setpoint, OFF when above.
On/Off control behavior:
Setpoint: 24C
Sensor reads 23.8C -> Heater ON (3,500W)
Heating rate: (3,500 + 2,000 - 4,655) / 60,300 = 0.014 C/s
Time to reach 24C: 0.2 / 0.014 = 14 seconds
But sensor delay (DHT22): 2 seconds between readings
Thermal lag (sensor to air): ~30 seconds
Relay switching delay: 50 ms (negligible)
Actual overshoot: heater stays on 32 seconds past setpoint
Overshoot amount: 0.014 x 32 = 0.45C
Temperature oscillates: 23.5C to 24.5C (1C band)
Cycle time: ~4 minutes (ON 2 min, OFF 2 min)
| Metric | On/Off Control | Target |
|---|---|---|
| Temperature band | +/- 0.5C | +/- 0.3C |
| Heater cycles per hour | 15 | <5 |
| Energy waste (overshoot) | ~8% | <3% |
| Relay lifetime at 15 cycles/hr | ~2 years | 10+ years |
Problem: On/off control oscillates too widely, shortens relay life, and wastes energy. Tomatoes need +/- 0.3C stability for optimal growth.
Step 3: Proportional Control Design
Instead of full ON/OFF, use PWM to vary heater power proportionally to the error:
Proportional control:
Error = Setpoint - Measured
Heater_PWM = Kp x Error
Proportional band: 2C (heater goes from 0% at setpoint to 100% at 2C below)
Kp = 100% / 2C = 50%/C
At 23C (1C below setpoint):
Error = 24 - 23 = 1C
Heater_PWM = 50% x 1 = 50% = 1,750W
At 23.5C (0.5C below):
Heater_PWM = 50% x 0.5 = 25% = 875W
At 23.8C (0.2C below):
Heater_PWM = 50% x 0.2 = 10% = 350W (gentle maintenance)
Step 4: Compare Results
| Metric | On/Off | Proportional (Kp=50) | Improvement |
|---|---|---|---|
| Temperature stability | +/- 0.5C | +/- 0.15C | 3.3x better |
| Heater cycles/hour | 15 | 0 (continuous PWM) | Infinite relay life |
| Average power used | 1,850W | 1,620W | 12% energy savings |
| Steady-state error | 0C (oscillates) | 0.12C (offset) | Needs integral term |
| Response to door opening | 45 sec to recover | 25 sec to recover | 44% faster |
| Daily energy cost (@$0.12/kWh) | $5.33 | $4.67 | $241/year savings |
Step 5: Implement on ESP32
// Simplified proportional feedback loop
const float SETPOINT = 24.0;
const float KP = 50.0; // %/degree C
const int HEATER_PIN = 25;
const int SENSOR_PIN = 4;
void loop() {
float temperature = readDHT22(SENSOR_PIN);
float error = SETPOINT - temperature;
// Proportional control: 0-255 PWM range
int pwm = constrain(error * KP * 2.55, 0, 255);
analogWrite(HEATER_PIN, pwm);
// Log for monitoring
Serial.printf("Temp=%.1fC Err=%.2f PWM=%d\n",
temperature, error, pwm);
delay(2000); // Match DHT22 sample rate
}Key lesson: The feedback loop transforms a simple heater into an intelligent climate system. On/off control works but oscillates – proportional control smooths the response. The remaining 0.12C steady-state offset (caused by the proportional-only approach needing some error to generate output) is eliminated by adding an integral term (PI control), covered in the PID Control Theory chapter. For this greenhouse, proportional control alone saves $241/year in energy and extends relay life from 2 years to indefinite.
69.8 Interactive: Thermal Time Constant Calculator
Calculate the thermal time constant for a space and determine the appropriate control loop sampling interval.
69.9 Knowledge Check
Key Takeaway
Feedback is the mechanism that transforms passive IoT devices into intelligent, self-correcting systems. The essential loop – measure, compare, correct – applies whether the feedback is local (a thermostat reading room temperature) or distributed across a network (cloud-coordinated sensor-actuator pairs). Negative feedback provides the stability needed for 99% of IoT control applications, while the key design challenge is ensuring the feedback loop remains intact even when network connections fail.
Decision Framework: When to Use Feedback Control in IoT
Step 1: Evaluate the Need for Feedback
| Question | If YES → Feedback Needed | If NO → Open-Loop Acceptable |
|---|---|---|
| Does output depend on unpredictable disturbances? | Wind affects drone position → GPS feedback required | Coffee maker timer (predictable heating time) |
| Must output precisely match a target? | Temperature ± 0.5°C for fermentation → Feedback required | Fan runs at 70% speed (approximate comfort) |
| Are consequences of error severe? | Medical device dosing (patient safety) → Feedback required | Notification LED brightness (cosmetic only) |
| Does environment change over time? | Battery voltage drops (heater power varies) → Feedback compensates | LED blink rate (powered source, consistent) |
Step 2: Choose Feedback Implementation Architecture
| Architecture | When to Use | Latency | Reliability | Cost |
|---|---|---|---|---|
| Local Edge Feedback | Process time constant <10 sec (HVAC, motor control) | <50 ms | Works offline | $15-50 for MCU + sensor |
| Cloud-Coordinated Feedback | Process time constant >60 sec (daily irrigation, weekly reports) | 100-500 ms | Requires connectivity | $0 hardware (cloud compute) |
| Hybrid (Local + Cloud) | Critical control + optimization (building HVAC) | <50 ms local fallback | Resilient | $30-70 per zone controller |
Step 3: Calculate Control Loop Timing
Rule of thumb: Control loop frequency must be 10x faster than process response time.
| Process | Time Constant | Required Loop Frequency | Implementation |
|---|---|---|---|
| Motor position | 100 ms | 10 Hz (100 ms loop) | Edge MCU only |
| Room temperature | 5 min | 0.033 Hz (30 sec loop) | Edge or cloud acceptable |
| Greenhouse climate | 30 min | 0.0056 Hz (3 min loop) | Cloud coordination works |
| Soil moisture (irrigation) | 4 hours | 0.0007 Hz (24 min loop) | Cloud-only sufficient |
Example: Smart thermostat decision
- Process: Room heating/cooling
- Time constant: Typical room reaches 95% of setpoint change in 5-15 minutes
- Disturbances: Door opening, sunlight, occupancy (unpredictable) → Feedback required
- Precision: ± 1°C acceptable for comfort (not critical) → Simple feedback (on/off or P-only)
- Loop frequency: 15 min / 10 = 90 sec loop → Edge MCU can handle, but cloud also viable
- Reliability: Heating should work during internet outage → Edge feedback with cloud telemetry
Decision: ESP32 running local P-control (Kp = 10, 60-second sampling), sending temperature logs to cloud for scheduling and energy analytics. Total cost: $25 (ESP32 + DHT22 sensor + relay).
Common mistake: Running PID in cloud for fast processes (motor control, drone stabilization). Network latency (100-500 ms) exceeds process time constant (10-100 ms), causing instability. Always run feedback locally for processes faster than 10 seconds.
Key Concepts
- Feedback Loop: A control architecture where the system’s output is measured and subtracted from the setpoint to compute error, which drives corrective action — enabling automatic compensation for disturbances and parameter variations
- Error Signal: The difference between desired setpoint and measured process variable (e = r - y), the fundamental input to a PID controller that drives all three control terms
- Process Variable (PV): The measured physical quantity being controlled (temperature, pressure, speed, pH) that the PID controller drives toward the setpoint through actuator manipulation
- Manipulated Variable (MV): The actuator output controlled by the PID algorithm (heater power, valve position, motor speed) that influences the process variable through the plant dynamics
- Steady-State Error: The residual difference between setpoint and process variable that persists after transient response settles — a pure proportional controller always has steady-state error; adding integral action eliminates it
- Disturbance: An uncontrolled input that causes the process variable to deviate from setpoint — a PID feedback loop automatically detects and corrects for disturbances through the error signal without requiring knowledge of disturbance magnitude
- Open-Loop Gain: The product of all gains around the control loop (controller × plant × sensor), determining how aggressively the system responds to error — gains above the stability limit cause sustained oscillation or divergence
Common Pitfalls
1. Designing Feedback Without Understanding Plant Dynamics
Tuning PID gains without characterizing the process (step response test, frequency response sweep) and understanding its time constant, delay, and gain. Blind gain adjustment leads to trial-and-error oscillations that could damage equipment. Always characterize the plant first.
2. Ignoring Sensor Dynamics in Feedback Design
Treating the sensor as instantaneous. Temperature sensors with thermal mass, pressure transducers with fluid columns, and current sensors with filtering all introduce dynamics that add phase lag to the feedback loop. Include sensor time constants in stability analysis.
3. Not Distinguishing Between Regulation and Setpoint Tracking
Using the same PID tuning for both disturbance rejection (holding constant setpoint against disturbances) and setpoint tracking (following a changing reference). Aggressive integral for fast setpoint tracking causes overshoot in disturbance rejection. Tune separately for the primary use case.
4. Assuming More Feedback is Always Better
Adding multiple nested feedback loops (cascade control) without understanding the inner/outer loop bandwidth separation requirement. The inner loop must be at least 3–5× faster than the outer loop. Violating this ratio causes the loops to fight each other.
69.10 Summary
This chapter covered the fundamentals of feedback in control systems:
- Feedback Definition: Output information routed back to influence input, creating self-regulating systems
- Everyday Examples: Thermostats, cruise control, and refrigerators all use feedback
- IoT Applications: Environmental control, safety systems, energy management, and distributed feedback across networks
- Feedback Types: Negative feedback stabilizes systems (most common), positive feedback amplifies changes (specialized uses)
- Foundation for PID: Understanding feedback is essential for implementing proportional-integral-derivative control
69.11 What’s Next
The next chapter explores Open-Loop and Closed-Loop Systems, comparing systems that operate with and without feedback, including decision frameworks for choosing the appropriate control architecture.
| Previous | Current | Next |
|---|---|---|
| Process Control and PID | Feedback Fundamentals | Open & Closed Loop Systems |
Related Chapters
- Open-Loop and Closed-Loop Systems - Comparing feedback architectures
- PID Control Theory - P, I, D term mathematics
- PID Tuning and Applications - Real-world implementation
- Processes & Systems Fundamentals - Systems thinking foundation