Appearance
Controllers Overview
Comprehensive process control system for wastewater treatment simulation
Introduction
ErgoPlanner provides a comprehensive controller framework for automatic process control in wastewater treatment simulations. Controllers adjust process parameters in real-time to maintain setpoints and optimize treatment performance.
Controller Categories
Base PID Controllers (Task 95)
Standard PID control for common wastewater parameters:
| Controller | Application | Setpoint Unit | Manipulated Variable |
|---|---|---|---|
| DO | Dissolved Oxygen | mg/L | Airflow (m³/h) |
| SRT | Solids Retention Time | days | WAS Flow (m³/d) |
| RAS | Return Sludge | ratio | RAS Ratio |
| WAS | Waste Sludge | m³/d | WAS Flow |
| Flow | Flow Control | m³/d | Pump Flow |
| pH | pH Control | pH units | Chemical Dose (L/h) |
Extended Controllers (Task 186)
Advanced control strategies for complex processes:
| Controller | Strategy | Key Application |
|---|---|---|
| Cascade-Controller | Master-slave PID | Nested control loops |
| Deadband-Controller | On/off with hysteresis | Equipment protection |
| Switch-Controller | Smooth S-curve transition | State changes |
| TimeOnOff-Controller | Programmable cycling | Intermittent aeration |
| Ratio-Controller | Flow ratio with PID trim | RAS/WAS ratio |
| ContinuousP-Controller | Integrating proportional | Valve positioning |
| Feedforward-Controller | Disturbance-based | Load compensation |
Control Theory Fundamentals
PID Control Equation
The standard PID algorithm implemented:
$$u(t) = K_p \cdot e(t) + K_i \int_0^t e(\tau) d\tau + K_d \frac{de(t)}{dt}$$
Where:
- $u(t)$ = Controller output
- $e(t)$ = Error (setpoint - process variable)
- $K_p$ = Proportional gain
- $K_i$ = Integral gain
- $K_d$ = Derivative gain
Discrete Implementation
The discrete form used in simulation:
$$u_k = K_p \cdot e_k + K_i \cdot \sum_{i=0}^{k} e_i \cdot \Delta t + K_d \cdot \frac{e_k - e_{k-1}}{\Delta t}$$
Features
Anti-Windup Protection
Prevents integral term accumulation during output saturation:
- Integral Clamping: Limits integral term magnitude
- Back-Calculation: Reduces integral when saturated
typescript
// Anti-windup implementation
const maxIntegral = ki > 0 ? (outputMax - outputMin) / ki : Infinity;
newIntegral = Math.max(-maxIntegral, Math.min(maxIntegral, newIntegral));Derivative Filtering
Low-pass filter on derivative term to reduce noise sensitivity:
$$D_{filtered} = \alpha \cdot D_{raw} + (1-\alpha) \cdot D_{previous}$$
Where $\alpha$ is the filter coefficient (default: 0.1).
Bumpless Transfer
Smooth transitions when:
- Switching between manual and auto mode
- Changing controller setpoints
- Re-initializing controllers
Controller Service Architecture
mermaid
graph TB
subgraph ControllerService
CI[Controller Initialization]
CE[Controller Execution]
CO[Output Application]
end
subgraph Controllers
PID[PID Controllers]
EXT[Extended Controllers]
end
subgraph Simulation
Graph[Calculation Graph]
Nodes[Process Units]
end
UI[User Configuration] --> CI
CI --> PID
CI --> EXT
Graph --> CE
PID --> CE
EXT --> CE
CE --> CO
CO --> NodesConfiguration
Base Controller Configuration
json
{
"id": "do-controller-1",
"type": "DO",
"enabled": true,
"setpoint": 2.0,
"kp": 50.0,
"ki": 10.0,
"kd": 5.0,
"targetNodeId": "aerobic-reactor-1",
"manipulatedVariable": "airflow"
}Extended Controller Configuration
json
{
"id": "cascade-do-1",
"type": "Cascade",
"enabled": true,
"master": {
"setpoint": 3000,
"kp": 1.0,
"ki": 0.1,
"kd": 0,
"pvNodeId": "reactor-1",
"pvVariable": "MLSS"
},
"slave": {
"kp": 2.0,
"ki": 0.5,
"kd": 0.1,
"pvNodeId": "reactor-1",
"pvVariable": "DO",
"targetNodeId": "reactor-1",
"manipulatedVariable": "airflow"
},
"mode": "auto",
"bumplessTransfer": true
}Tuning Guidelines
General Principles
- Start Conservative: Begin with low gains and increase gradually
- Tune Sequential: For cascade, tune slave first, then master
- Monitor Oscillations: Reduce Kp if oscillations occur
- Integral Action: Ki should be 5-10× slower than Kp response
Typical Tuning Values
| Application | Kp Range | Ki Range | Kd Range | Notes |
|---|---|---|---|---|
| DO Control | 20-100 | 5-20 | 0-10 | Fast response needed |
| SRT Control | 50-200 | 0.5-5 | 0 | Slow integration |
| RAS Ratio | 0.2-1.0 | 0.02-0.1 | 0 | Gentle control |
| pH Control | 20-100 | 2-10 | 0.5-3 | Nonlinear near 7.0 |
| Flow Control | 0.5-2.0 | 0.05-0.2 | 0-0.1 | Quick response |
Best Practices
1. Start with Manual Mode
- Verify process variable measurement
- Confirm output actuator response
- Check setpoint reasonableness
2. Monitor Controller Performance
- Track error magnitude over time
- Watch for oscillations
- Check for output saturation
3. Consider Process Dynamics
- Faster controllers for faster processes
- Longer integral times for sluggish processes
- Use derivative sparingly
4. Use Appropriate Controller Type
- Simple loops: Standard PID
- Nested loops: Cascade
- Equipment protection: Deadband
- Load changes: Feedforward
Troubleshooting
| Issue | Likely Cause | Solution |
|---|---|---|
| Oscillation | Kp too high | Reduce Kp by 50% |
| Slow response | Kp too low | Increase Kp gradually |
| Offset | Ki too low | Increase Ki |
| Overshoot | Ki too high or Kd too low | Reduce Ki or add Kd |
| Noise amplification | Kd too high | Reduce Kd or increase filter |
| Saturation | Limits too tight | Check output limits |
Related Topics
- Process-Units-Overview
- Simulation-Engine
- Calculation-Modes
References
- Seborg, D.E., et al. "Process Dynamics and Control" (4th Edition)
- Rieger, L., et al. "Guidelines for Using Activated Sludge Models" (IWA)
- Olsson, G. "ICA and Me - A Subjective Review" (Water Research, 2012)