Hardware Engineer's Guide
PID CONTROL
By Shimi Cohen
PID Control Guide
1. PID FUNDAMENTALS
TRANSFER FUNCTION
𝐺(𝑠) = 𝐾𝑝 + 𝐾𝑖/𝑠 + 𝐾𝑑 · 𝑠
COMPONENT TIME DOMAIN FREQ. DOMAIN PHYSICAL EFFECT
Proportional 𝐾𝑝 · 𝑒(𝑡) 𝐾p Immediate response strength
Integral 𝐾𝑖 · ∫ 𝑒(𝑡)𝑑𝑡 𝐾𝑖 / 𝑠 Historical error elimination
Derivative 𝐾𝑑 · 𝑑𝑒(𝑡)/𝑑𝑡 Kd · s Predictive overshoot prevention
Term Analogy Too Low Too High
P Immediate reaction to difference. Slow Unstable.
I Corrects for past errors, accumulated drift Slow Settle Overshoots
D Anticipates changes, smooths approach Overshoots unstable
2
PID Control Guide
CORE FUNCTION
Direct multiplication of current error by gain factor.
• Immediate Response: Output changes instantly
• Linear Relationship: Doubling error doubles control output
• Steady-State Error: Always present in pure proportional
• Stability Margin: Higher Kp lower stability but faster response
• Response time: Instantaneous
• Steady accuracy: Limited by proportional band
• Typical Kp range: 0.1 to 100 (application dependent)
CORE FUNCTION
Accumulates historical error to eliminate steady-state offsets.
• Error Accumulation: Continuously sums past errors over time
• Offset Elimination: Forces steady-state error to zero
• Wind-up Susceptibility: Can saturate during large transients
• Stability Impact: Reduces phase margin, can cause oscillation
• Continuous: True integration for analog systems
• Discrete: Trapezoidal rule for digital implementation
• Wind-up protection: Essential for practical systems
CORE FUNCTION
Provides predictive action based on error rate of change.
• Predictive Nature: Responds to error rather than magnitude
• Overshoot Reduction: Opposes rapid changes in error signal
• Noise Amplification: High-frequency noise becomes dominant
• Damping Enhancement: Improves transient response characteristic
• Pure derivative: unusable due to noise amplification
• Low-pass filtering: Typically 10:1 to 100:1 ratio
• Kick suppression: required for setpoint changes
3
PID Control Guide
2. THE PLANT
The object being manipulated (Heater, Valve, Motor etc.)
TIME CONSTANT
• Thermal Systems: Heat capacity / thermal conductance
• Mechanical Systems: Inertia / damping coefficient
• Electrical Systems: L/R or RC time constants
• Process Systems: Volume / flow rate relationships
DEAD TIME EFFECTS
• Transport delays: Physical distance between control and measurement
• Processing delays: Computational and signal processing time
• Sensor delays: Measurement device response time
4
PID Control Guide
COMMON NON-LINEAR ELEMENTS
NON-LINEARITY EFFECT ON CONTROL COMPENSATION METHOD
Saturation Output limiting Anti-windup, gain scheduling
Dead zone Poor small-signal response Bias injection, dither
Backlash Oscillation tendency Pre-loading, feed-forward
Rate limiting Slow large-signal response Acceleration limiting
CONSTRAINT HANDLING
• Actuator saturation: 0-100% valve, ±10V amplifier limits
• Rate constraints: Maximum slew rate limitations
• Physical limits: Temperature, pressure, position boundaries
STEP RESPONSE ANALYSIS
• Rise time: 10% to 90% of final value
• Settling time: Within 2% of final value
• Overshoot: Peak value above final value
• Time constant: 63% of final value time
FREQUENCY RESPONSE METHODS
• Bode plot analysis
• Nyquist criteria
5
PID Control Guide
3. FEEDBACK PATH
POSITION/DISPLACEMENT SENSORS
SENSOR TYPE RESOLUTION ACCURACY BANDWIDTH TYPICAL APPLICATIONS
Encoder 0.1° - 0.001° ±0.05° 10kHz Servo positioning, robotics
Resolver 0.1° ±0.02° 1kHz Harsh environment motors
LVDT 0.1μm ±0.1% 1kHz Precision linear positioning
Hall Effect 1° ±1° 100kHz Low-cost positioning
TEMPERATURE SENSORS
SENSOR TYPE RANGE ACCURACY RESPONSE INTERFACE
Thermocouple -200°C : 1800°C ±0.5°C 100ms Differential voltage
RTD -200°C : 850°C ±0.1°C 1s Resistance measurement
Thermistor -50°C to 300°C ±0.05°C 10ms Resistance measurement
IC Sensor -40°C to 125°C ±0.25°C 1ms Voltage/digital output
AMPLIFICATION AND SCALING
• Sensor output range: mV to V
• ADC input range: Typically, 0-3.3V
• Gain calculation: (ADC_range) / (Sensor_range)
• Offset compensation for bipolar signals
NOISE REJECTION TECHNIQUES
• Differential signaling for long cable runs
• Shielding and grounding for electromagnetic immunity
• Low-pass filtering at sensor interface
• Digital filtering for software-based noise reduction
6
PID Control Guide
CRITICAL PLACEMENT CONSIDERATIONS
• Thermal coupling: Sensor proximity to controlled element
• Mechanical coupling: Rigid mounting for position feedback
• Electrical isolation: Avoiding ground loops and interference
• Environmental protection: Temperature, vibration, moisture
CALIBRATION PROCEDURES:
• Zero-point calibration at known reference
• Span calibration using full-scale reference
• Linearity verification across operating range
• Temperature compensation coefficient determination
ERROR SIGNAL GENERATION
𝐸𝑟𝑟𝑜𝑟 = 𝑆𝑒𝑡𝑝𝑜𝑖𝑛𝑡 − 𝑃𝑟𝑜𝑐𝑒𝑠𝑠_𝑉𝑎𝑟
ERROR SIGNAL CONDITIONING:
• Scaling: Engineering units to controller units
• Limiting: Prevent excessive error signals
• Rate limiting: Prevent derivative kick
• Filtering: Remove high-frequency noise
MULTIPLE INPUT HANDLING:
• Sensor redundancy for critical applications
• Fault detection through signal comparison
• Automatic sensor switching for failures
• Signal validation and range checking
7
PID Control Guide
4. FORWARD ARCHITECTURE
POWER STAGE CLASSIFICATIONS
ACTUATOR TYPE POWER STAGE CONTROL SIGNAL PROTECTION REQUIRED
DC Motor H-Bridge PWM PWM + Direction Current limiting, thermal
AC Motor 3-Phase Inverter 3-Phase PWM Over-current, over-voltage
Servo Valve Linear Amplifier ±10V Analog Short-circuit, thermal
Heater SSR/Contactor On/Off or PWM Over-temperature, earth fault
CURRENT SENSING METHODS
• Shunt resistors: High accuracy, low cost
• Hall effect sensors: Isolated, wide bandwidth
• Current transformers: AC systems, isolation
• Integrated current sensing: Motor drivers
PROTECTION IMPLEMENTATION
• Hardware current limiting: Independent of software
• Thermal monitoring: Junction and case temperature
• Over-voltage protection: Surge suppressors, TVS diodes
• Under-voltage lockout: Prevent malfunction at low supply
8
PID Control Guide
5. SIGNAL PROCESSING
ANTI-ALIASING FILTER DESIGN
Sampling Rate Selection:
• Nyquist criterion: 𝑓𝑠 > 2 × 𝑓𝑚𝑎𝑥
• Practical rule: fs = 10 × 𝑐𝑜𝑛𝑡𝑟𝑜𝑙 𝑏𝑎𝑛𝑑𝑤𝑖𝑑𝑡ℎ
• Oversampling benefits: Reduced filter requirements
FILTER TOPOLOGIES
FILTER TYPE ORDER ROLL-OFF GROUP DELAY APPLICATION
Butterworth 2nd-8th -40dB/decade Moderate General purpose
Bessel 2nd-6th -40dB/decade Linear Pulse response
Chebyshev 2nd-8th -60dB/decade Non-linear Steep cutoff
Elliptic 4th-8th -80dB/decade Non-linear Minimum order
Butterworth
9
PID Control Guide
DIGITAL BI-QUAD IMPLEMENTATION
𝐻(𝑧) = (𝑏0 + 𝑏1 × 𝑧⁻¹ + 𝑏2 × 𝑧⁻²) / (1 + 𝑎1 × 𝑧⁻¹ + 𝑎2 × 𝑧⁻²)
Coefficient Calculation Methods:
• Bilinear transform: Frequency warping compensation
• Matched Z-transform: Impulse response matching
• Zero-order hold: Step response matching
ANALOG FILTER ADVANTAGES
• No sampling limitations
• Inherent anti-aliasing
• Lower group delay
• Simpler implementation
DIGITAL FILTER ADVANTAGES
• Programmable coefficients
• Perfect repeatability • Complex transfer functions
• No component drift
10
PID Control Guide
6. PID IMPLEMENTATION
CLASSIC ANALOG PID CONFIGURATION
• OPAMP: High slew rate, low offset drift
• Resistors: 1% tolerance, low temperature coefficient
• Capacitors: Low leakage, stable dielectric
• Power supplies: Low noise, good regulation
FIXED-POINT VS FLOATING -POINT
Fixed-Point Advantages:
• Faster execution on most microcontrollers
• Deterministic execution time
• Lower power consumption
• Suitable for real-time applications
Floating-Point Advantages:
• Wider dynamic range
• Simpler coefficient calculation
• Reduced scaling concerns
• Better for complex algorithms
NUMERICAL PRECISION REQUIREMENTS
• Control output: 12-16 bits typical
• Internal calculations: 24-32 bits recommended
• Overflow protection: Essential for integral term
11
PID Control Guide
TIMER CONFIGURATION:
• Control loop timing: Hardware timer interrupt
• PWM generation: Dedicated PWM peripherals
• ADC sampling: Synchronized with control loop
• Communication: Non-blocking for real-time operation
REAL-TIME PERFORMANCE
• Fixed execution time: Avoid conditional branches in ISR
• Memory allocation: Static allocation only in ISR
• Stack usage: Monitor stack depth for nested interrupts
• Priority levels: Control loop highest priority
CODE OPTIMIZATION TECHNIQUES:
• Table lookups: Replace calculations with lookup tables
• Bit manipulation: Use shifts instead of multiply/divide
• Compiler optimization: Enable appropriate optimization levels
• Assembly critical sections: Hand-optimize time-critical code
12
PID Control Guide
7. TUNING & TROUBLESHOOTING
ZIEGLER-NICHOLS METHOD
Critical Gain Determination
• Set Ki = 0, Kd = 0
• Increase Kp until sustained oscillation occurs
• Record critical gain (Kc) and oscillation period (Tc)
TYPE KP KI KD
P-only 0.5 × Kc 0 0
PI 0.45 × Kc 1.2×Kp/Tc 0
PID 0.6 × Kc 2×Kp/Tc Kp × Tc/8
COHEN-COON METHOD
Based on open-loop step response characteristics:
• Process gain (K): Steady-state output change / input change
• Time constant (τ): Time to reach 63% of final value
• Dead time (θ): Time before response begins
13
PID Control Guide
OSCILLATION PROBLEMS
TYPE CHARACTERISTICS ROOT CAUSE SOLUTION
High Freq Small Amp, fast D gain too high Reduce Kd or add filter
Mid Freq Growing Amp P gain too high Reduce Kp
Low Freq Large Amp, slow I gain too high Reduce Ki
Limit Square wave Actuator saturation Reduce gains, add anti-windup
INTEGRAL WINDUP PREVENTION
• Conditional integration: Stop integration when output saturated
• Back-calculation: Reduce integral term when output limited
• Clamping: Limit integral term to prevent excessive accumulation
14
PID Control Guide
GAIN SCHEDULING
• Multiple PID parameter sets for different operating regions
• Smooth transitions between parameter sets
• Based on setpoint, process variable, or external conditions
FEED-FORWARD CONTROL
• Anticipate disturbances before they affect process variable
• Reduce dependency on feedback for known disturbances
• Combine with PID for optimal performance
CASCADE CONTROL
• Inner loop: Fast variable (current, pressure)
• Outer loop: Slow variable (position, temperature)
• Improved disturbance rejection and stability
15
PID Control Guide
STEP RESPONSE TESTING
1. Apply step input to system
2. Record process variable response
3. Calculate process parameters
4. Use parameters for controller tuning
FREQUENCY RESPONSE TESTING
1. Apply sinusoidal input sweep
2. Measure amplitude ratio and phase shift
3. Create Bode plot
4. Design controller for desired margins
AUTO-TUNING ALGORITHMS
• Relay feedback method: Automated critical gain finding
• Pattern recognition: Identify system response patterns
• Adaptive tuning: Continuous parameter adjustment
• Model reference: Compare with ideal response
16
PID Control Guide
8. REAL-WORLD APPLICATIONS
Linear Actuator Position Control
SYSTEM COMPONENTS
• Plant: Linear Actuator with encoder feedback
• Sensor: Optical encoder (1000 PPR typical)
• Controller Implemented PID in MCU
TYPICAL SPECIFICATIONS
PARAMETER SPECIFICATION TYPICAL VALUES
Position accuracy ±0.1° Encoder resolution limited
Settling time <100ms For 90° step input
Following error <2° At maximum velocity
Velocity ripple <5% Of commanded velocity
CHALLENGES
• Commutation timing: Precise rotor position required
• Current control: Inner current loop for torque control
• Back-EMF compensation: Velocity-dependent voltage drop
• Cogging torque: Periodic disturbances from magnets
17
PID Control Guide
Temperature Control System Design: Heater Temperature Control
SYSTEM CHARACTERISTICS
• Plant: Thermal mass with heater
• Sensor: Precision thermistor (0.1°C accuracy)
• Actuator: Linear Peltier driver (±5A)
• Control range: -10°C to +80°C
DESIGN CONSIDERATIONS
ASPECT CHALLENGE SOLUTION
Thermal lag 10-100S time constants Long integration times
Heating/cooling asymmetry Different time constants Gain scheduling
Ambient variations External disturbances Feed-forward compensation
Power limitations Peltier current limits Anti-windup protection
TUNING PARAMETERS
• 𝑲𝒑: 5 − 20 (𝐴/°𝐶) − 𝐵𝑎𝑠𝑒𝑑 𝑜𝑛 𝑡ℎ𝑒𝑟𝑚𝑎𝑙 𝑟𝑒𝑠𝑖𝑠𝑡𝑎𝑛𝑐𝑒
• 𝑲𝒊: 0.1 − 1 (𝐴/°𝐶 − 𝑠) − 𝐿𝑜𝑛𝑔 𝑡𝑖𝑚𝑒 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡𝑠
• 𝑲𝒅: 0.05 − 0.5 (𝐴 − 𝑠/°𝐶) − 𝐹𝑖𝑙𝑡𝑒𝑟𝑒𝑑 ℎ𝑒𝑎𝑣𝑖𝑙𝑦 𝑓𝑜𝑟 𝑛𝑜𝑖𝑠𝑒
18
PID Control Guide
9. COMMON PID CIRCUITS
OP-AMP BASED PID CONTROLLER
Component Values for Typical Application:
• R0 = 10kΩ (proportional gain setting)
• R1 = 100kΩ (integral time constant)
• C1 = 0.1μF (integral capacitor)
• R2 = 10kΩ (derivative gain)
• C2 = 10nF (derivative filter)
• R3 = 10KΩ (Proportional Gain)
TRANSFER FUNCTION
DESIGN GUIDELINES
• Op-amp selection: Low offset, high slew rate
• Resistor tolerance: 1% for consistent performance
• Capacitor type: Low leakage for integral term
• Supply voltage: ±15V typical for wide output swing
19
PID Control Guide
DEDICATED PID CONTROLLER ICS
PART NUMBER FEATURES RESOLUTION INTERFACE
MAX1968 3-term PID, 12-bit 0.025% SPI
LTC1569 Analog PID filter Continuous Analog
AD5933 Impedance analyzer PID 12-bit I²C
MICROCONTROLLER-BASED SOLUTIONS:
• STM32F4: 32-bit ARM, floating-point unit
• TMS320F28x: Fixed-point DSP controllers
20
PID Control Guide
POWER SUPPLY DESIGN
• Analog circuits: ±15V or ±12V dual supplies
• Digital circuits: +3.3V or +5V single supply
• Isolation: Required for industrial applications
• Noise filtering: LC filters for switching supplies
ELECTROMAGNETIC COMPATIBILITY
• Cable shielding: Twisted pair for differential signals
• Grounding: Single-point ground for analog circuits
• PCB layout: Separate analog and digital ground planes
• Filtering: Ferrite beads and bypass capacitors
SAFETY AND RELIABILITY
• Watchdog circuits: Reset on software failures
• Redundancy: Backup systems for critical applications
• Fail-safe design: Known safe state on power loss
• Environmental protection: Temperature, vibration, moisture
TESTING AND VALIDATION
• Loop testing: Step response verification
• Stability margins: Gain and phase margin measurement
• Disturbance rejection: Load step testing
• Long-term stability: Extended operation testing
21