Overview
The PID Controller module provides precise process control for temperature, position, speed, and other continuous variables. It includes auto-tuning algorithms and advanced features for production systems.Basic PID Control
This example demonstrates a simple temperature control system using PID.Complete Example
Advanced Features
The PID controller supports several advanced features for production systems.Derivative Filter
Reduces noise sensitivity in the derivative term:Deadband
Prevents control action for small errors near the setpoint:Setpoint Ramping
Creates gradual transitions to new setpoints:Output Rate Limiting
Prevents abrupt changes in control output:Performance Monitoring
Track system performance metrics:Motor Control Example
Bi-directional motor control with position feedback:Auto-Tuning
The module includes auto-tuning algorithms to determine optimal PID gains.Available Methods
- Ziegler-Nichols Method 1: Classic oscillation method
- Ziegler-Nichols Method 2: Step response method
- Cohen-Coon: For processes with delay
Usage
Refer to the auto-tuning examples:pid_controller_zn1-tuning-example.inopid_controller_zn2-tuning-example.inopid_controller_cohen-coon-example.ino
Parameter Persistence
Save and load PID parameters to/from EEPROM:pid_controller_esp32-eeprom-example.ino for complete implementation.
Key Methods
| Method | Description |
|---|---|
setSetPoint(float) | Set target value |
compute(float) | Calculate control output |
reset() | Reset controller state |
getKp(), getKi(), getKd() | Get current gains |
setKp(), setKi(), setKd() | Update gains |
getProportionalComponent() | Get P term |
getIntegralComponent() | Get I term |
getDerivativeComponent() | Get D term |
Hardware Requirements
- Temperature/position sensor with analog output
- PWM-capable output pin
- Actuator (heater, motor, etc.)
Source Files
Example files located at:- Basic:
example/modules/control/EXAMPLE-PIDController/pid_controller_basic-pid-example/ - Advanced:
example/modules/control/EXAMPLE-PIDController/pid_controller_advanced-features-example/