67  Process Control and PID

In 60 Seconds

PID control is the foundation of IoT actuator management, used in 95% of industrial control loops. The three terms (Proportional, Integral, Derivative) address current error, accumulated past error, and predicted future error respectively – together they enable precise temperature, motor speed, and position control with settling times under 5 seconds.

67.1 Learning Objectives

By the end of this chapter series, you will be able to:

  • Explain Feedback Concepts: Describe how feedback loops measure, compare, and correct system output
  • Design PID Controllers: Architect Proportional-Integral-Derivative controllers for IoT actuator systems
  • Contrast Control Types: Compare open-loop and closed-loop strategies with quantitative trade-off analysis
  • Evaluate System Response: Assess system behavior metrics including overshoot, settling time, and steady-state error
  • Implement Control Systems: Build temperature, motor, and position control using microcontrollers
  • Apply Tuning Methods: Execute Ziegler-Nichols and manual tuning to optimize controller performance
MVU: Minimum Viable Understanding

Core concept: PID control uses three strategies working together - Proportional responds to current error, Integral eliminates persistent offset, and Derivative prevents overshoot - to smoothly maintain a setpoint instead of oscillating on/off. Why it matters: Simple on/off control causes temperature swings, wastes energy, and wears out actuators; PID enables the precise, stable control required for greenhouses, manufacturing, and smart homes. Key takeaway: Start tuning with P only (increase until oscillation), add I to eliminate steady-state error, then add D to reduce overshoot - not every application needs full PID; PI often suffices.

Process control in IoT is about automatically adjusting systems to maintain desired conditions. Think of cruise control in a car: it continuously measures your speed, compares it to your target, and adjusts the throttle to keep you on track. IoT systems use similar feedback loops to control everything from room temperature to industrial manufacturing processes.

67.2 Chapter Overview

This topic has been split into four focused chapters for better learning progression:

67.2.1 1. Feedback Fundamentals

Difficulty: Foundational | Time: ~15 minutes

Learn the basic concepts of feedback control that form the foundation for all control systems:

  • What feedback is and why it matters
  • Everyday feedback examples (thermostats, cruise control)
  • Positive vs negative feedback
  • Feedback in IoT applications
  • Distributed feedback across network boundaries

67.2.2 2. Open-Loop and Closed-Loop Systems

Difficulty: Intermediate | Time: ~20 minutes

Compare and contrast control architectures:

  • Closed-loop systems with continuous feedback
  • Open-loop systems without feedback
  • Advantages and disadvantages of each approach
  • Decision framework for selecting control architecture
  • Edge vs cloud control placement

67.2.3 3. PID Control Theory

Difficulty: Advanced | Time: ~25 minutes

Deep dive into PID controller mathematics and behavior:

  • The PID equation and its components
  • Proportional (P) control and steady-state error
  • Integral (I) control and error accumulation
  • Derivative (D) control and overshoot prevention
  • Integral windup and anti-windup techniques
  • Comparing P, PI, PD, and full PID configurations

67.2.4 4. PID Tuning and Applications

Difficulty: Advanced | Time: ~20 minutes

Practical implementation and real-world examples:

  • Systematic tuning approaches
  • Real-world industrial brewery case study
  • Domain-specific tuning (HVAC, motors, irrigation, vehicles)
  • Performance metrics and ROI analysis
  • Design considerations for IoT systems

67.3 Prerequisites

Before starting this chapter series, you should be familiar with:

This chapter connects to multiple learning resources:

Interactive Tools:

  • Simulations Hub - Try the PID tuning simulator to experiment with Kp, Ki, and Kd values
  • Power Budget Calculator in Energy Management - Calculate control system power consumption

Visual Learning:

Assessment:

  • Quizzes Hub - Test your understanding of feedback loops and PID tuning

Common Challenges:

  • Knowledge Gaps Hub - Address misconceptions about steady-state error and integral windup

Knowledge Structure:

  • Knowledge Map - See how PID control connects to sensors, actuators, and IoT architectures

67.4 Quick Reference: PID Term Summary

Term Reacts To Purpose Issue to Watch
P Current error magnitude Provide proportional response Steady-state error, overshoot
I Accumulated error over time Eliminate steady-state error Integral windup, slow response
D Rate of error change Dampen overshoot, predict future Noise amplification, hard to tune

Simplified Summary:

  • P corrects present error
  • I corrects past accumulated error
  • D corrects future predicted error

67.4.1 Interactive: PID Term Contribution Calculator

Adjust the gains and error values to instantly see how each PID term contributes to the total controller output.

PID control is the secret superpower that makes smart devices actually SMART!

67.4.2 The Sensor Squad Adventure: The Magic Temperature Wand

Lila the LED was SO frustrated. Her pet fish tank kept getting too hot and then too cold. The old heater just went ON or OFF – nothing in between!

“When it’s ON, the water gets too hot. When it’s OFF, it gets too cold. My fish are NOT happy!” said Lila.

Max the Microcontroller had an idea. “We need PID control – it’s like a magic wand with THREE powers!”

  • Power P (Present): “How far are we from the right temperature RIGHT NOW?”
  • Power I (Past): “Have we been a little bit off for a LONG time?”
  • Power D (Danger): “Are we heading toward the target too FAST?”

Sammy the Sensor checked the water: “25.5 degrees! Target is 26!”

Max’s PID brain calculated: “Just 0.5 degrees off, so we need a tiny bit of heat. And we’ve been slightly low for 5 minutes, so add a little extra. And the temperature is rising slowly, so we’re on track!”

Instead of slamming the heater to 100%, the PID controller gently warmed the water to exactly 26.0 degrees. No overshooting. No wild swings. Just perfect, steady temperature.

“My fish are SO happy now!” cheered Lila. “PID is the BEST!”

67.4.3 Key Words for Kids

Word What It Means
PID Three helpers: Present-error, Integrated-past, Derivative-future
Setpoint The perfect target value (like 26 degrees for fish!)
Oscillation When something bounces back and forth (bad for fish!)
Smooth control Gently adjusting instead of slamming on/off

67.4.4 Try This at Home!

Try balancing a ball on a flat tray. When the ball rolls right, tilt left (that is P!). If it keeps drifting right no matter what, tilt more (that is I!). If the ball is rolling fast, make a bigger correction quickly (that is D!). You just used PID to balance a ball!

67.5 Worked Example: On/Off vs PID for a Commercial Greenhouse – Energy and Crop Impact

A commercial greenhouse (2,000 m2) grows tomatoes requiring 22 +/- 1 C. The grower currently uses on/off heater control and is considering upgrading to PID. The heater is a 50 kW gas-fired unit ($0.08/kWh natural gas equivalent).

On/Off Control Performance (Current)

Setpoint: 22°C, Hysteresis: ±2°C (heater ON at 20°C, OFF at 24°C)
Observed temperature swing: 19.5°C to 24.5°C (5°C range)
Cycle frequency: ~12 cycles/hour (heater runs 50% duty)
Daily gas cost: 50 kW × 0.50 duty × 16 hr/day × $0.08/kWh = $32/day
Annual heating cost: $32 × 200 heating days = $6,400/year
Crop impact: Temperature excursions below 20°C reduce tomato yield by 8-12%

PID Control Performance (Proposed)

Setpoint: 22°C, Steady-state accuracy: ±0.3°C
Observed temperature range: 21.7°C to 22.3°C (0.6°C range)
Heater modulation: Proportional valve, 0-100% output
Average duty: 35% (heater runs at lower intensity, fewer thermal losses)
Daily gas cost: 50 kW × 0.35 duty × 16 hr/day × $0.08/kWh = $22.40/day
Annual heating cost: $22.40 × 200 days = $4,480/year
Crop impact: Stable temperature eliminates cold-stress yield loss

Cost-Benefit Analysis

Category On/Off (Current) PID (Proposed) Difference
Annual gas cost $6,400 $4,480 -$1,920 (30% savings)
Yield loss from temperature swings ~10% of $80,000 crop = $8,000 ~0% -$8,000
Heater maintenance (cycling wear) $800/year (valve replacement) $200/year -$600
Total annual benefit $10,520
PID hardware cost (controller + valve + install) $2,800 one-time
Payback period 3.2 months

Why the 30% Energy Savings? On/off control overshoots the setpoint, then lets temperature drop below it, wasting energy in both directions. PID modulates heater output to match the actual heat loss rate. When outside temperature is 10 C, the greenhouse only needs ~35% heater power to maintain 22 C. On/off runs at 100% power half the time (50% average), wasting 15% of energy as overshoot heat that must then be vented.

Tuning Parameters Used: Kp = 8.0, Ki = 0.3, Kd = 2.0. The integral term (Ki) eliminates the 0.5 C steady-state error that proportional-only control would leave. The derivative term (Kd) prevents overshoot when doors open and cold air enters (a sudden disturbance that pure PI would overcorrect).

Hands-on Exercise: Use the PID simulator in the Simulations Hub to explore how each term affects temperature control.

Setup:

  • Setpoint: 25°C
  • Initial temperature: 18°C
  • Plant: First-order thermal system (room heating)

Tasks:

  1. P-only control: Set Kp=5.0, Ki=0, Kd=0
    • Observe: Does it reach exactly 25°C? How long to settle?
    • Expected: Fast response, ~1°C steady-state error
  2. PI control: Set Kp=5.0, Ki=0.3, Kd=0
    • Observe: Does it eliminate the offset? Any overshoot?
    • Expected: Reaches 25°C exactly, possible 1-2°C overshoot
  3. PID control: Set Kp=5.0, Ki=0.3, Kd=1.5
    • Observe: How does overshoot compare to PI?
    • Expected: Minimal overshoot, faster settling

What to observe:

  • Rise time (speed to reach target)
  • Overshoot (how far past target)
  • Settling time (time to stabilize)
  • Steady-state error (final offset)

Documentation: Screenshot your best-tuned response curve and note the optimal gains you found.

How It Works: PID Control in Action

The Three-Term Controller Explained:

1. Proportional (P) - React to Current Error Think of P as your immediate reaction. If you’re driving at 50 km/h but want 100 km/h, the 50 km/h error tells you to press the accelerator hard. As you approach 100 km/h and the error shrinks to 10 km/h, you ease off proportionally.

Formula: P_output = Kp × error

2. Integral (I) - Remember Accumulated Error The I term is your memory. If you’ve been 5 km/h too slow for 30 seconds, the I term accumulates that history and adds extra correction. This eliminates the steady-state offset that P-only cannot fix.

Formula: I_output = Ki × ∫error dt

3. Derivative (D) - Predict Future Error The D term is your anticipation. If your speed is rising rapidly at 10 km/h per second, the D term sees this rate of change and starts reducing the accelerator before you overshoot 100 km/h.

Formula: D_output = Kd × (de/dt)

Combined Output: u(t) = P + I + D

Real Example - Smart Thermostat:

  • Current temp: 18°C, Target: 22°C, Error: +4°C
  • P-term: Kp=10, Output = 10×4 = 40% heater power
  • I-term: Error has persisted for 60 seconds, ∫error = 240°C·s, Ki=0.2, Output = 0.2×240 = 48% additional power
  • D-term: Temperature rising at 0.5°C/min, Kd=5, Output = 5×(-0.5/60) = -0.042% (tiny braking)
  • Total output: 40 + 48 - 0.042 = 88% heater power → smooth, precise control

67.6 Concept Relationships

Concept Relationship to PID Control Why It Matters
Feedback Loop PID is a specific algorithm within a closed-loop feedback system Without feedback (measuring output), PID has no error signal to process
Setpoint The target value that PID maintains All three terms (P, I, D) calculate their contribution based on deviation from setpoint
Steady-State Error P-only control cannot eliminate it; I-term is required Explains why PI control is more common than P-only in IoT applications
Overshoot D-term specifically reduces overshoot by detecting rapid approach Critical for systems where exceeding setpoint is dangerous (ovens, medical devices)
Actuator Saturation Limits maximum control output, can cause integral windup Anti-windup clamping prevents I-term from accumulating to extreme values
Sensor Noise D-term amplifies high-frequency noise Explains why derivative gain must be tuned carefully or omitted in noisy environments

67.7 See Also

Related chapters that expand on PID control concepts:

Key Takeaway

PID control replaces crude on/off switching with smooth, precise actuator management by combining three complementary strategies: Proportional (reacts to current error), Integral (eliminates persistent offset), and Derivative (prevents overshoot). Used in 95% of industrial control loops, PID is the single most important control algorithm for IoT systems. Start learning with feedback fundamentals, then progress through open/closed-loop comparison, PID math, and finally hands-on tuning.

67.8 What’s Next

Start with Feedback Fundamentals to build a solid foundation, then progress through the chapters in order. Each chapter builds on concepts from the previous ones.

For hands-on practice, visit the Simulations Hub to experiment with the interactive PID tuning simulator.

Previous Current Next
Processes & Systems Process Control and PID Feedback Fundamentals

Key Concepts

  • Process Control: The engineering discipline of automatically maintaining a process variable (temperature, pressure, flow, pH) at a desired setpoint by manipulating actuators based on sensor feedback
  • PID Controller: The most widely used feedback control algorithm combining proportional, integral, and derivative terms to drive a measured process variable toward a setpoint with minimal steady-state error and overshoot
  • Control Loop: The complete feedback cycle from sensor measurement through controller computation to actuator output and back to the process, operating continuously at a fixed sample rate
  • Setpoint: The target value the control system drives the process variable toward — expressed in the same engineering units as the sensor measurement
  • Actuator: The physical device (valve, heater, motor, pump) manipulated by the controller output to influence the process variable
  • Disturbance Rejection: The ability of a closed-loop control system to automatically return to setpoint when external disturbances (load changes, supply variations, environmental conditions) push the process variable away

Common Pitfalls

Tuning PID gains on a process whose dynamics have not been characterized. Without knowing the process gain, time constant, and dead time, gain selection is guesswork. Always run a step response or frequency sweep to identify process parameters before tuning.

Routing sensor data through an MQTT broker to a cloud-hosted PID controller and back to the actuator, adding 50–200 ms of round-trip latency to a control loop that needs <10 ms. Control loops requiring sub-100 ms response must run at the edge or on the device, not in the cloud.

Implementing PID with floating-point arithmetic on microcontrollers without hardware FPU (Arduino Uno, ATmega). Float operations consume 50–100 cycle, making 1 kHz control loops infeasible. Use scaled integer arithmetic with known fixed-point precision.

Adding integral action to a control loop without implementing anti-windup. During startup when the actuator is saturated, the integral accumulates unboundedly. When the actuator unsaturates, massive overshoot results. Always implement anti-windup before enabling integral action.