Skip to content

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:

ControllerApplicationSetpoint UnitManipulated Variable
DODissolved Oxygenmg/LAirflow (m³/h)
SRTSolids Retention TimedaysWAS Flow (m³/d)
RASReturn SludgeratioRAS Ratio
WASWaste Sludgem³/dWAS Flow
FlowFlow Controlm³/dPump Flow
pHpH ControlpH unitsChemical Dose (L/h)

Extended Controllers (Task 186) ​

Advanced control strategies for complex processes:

ControllerStrategyKey Application
Cascade-ControllerMaster-slave PIDNested control loops
Deadband-ControllerOn/off with hysteresisEquipment protection
Switch-ControllerSmooth S-curve transitionState changes
TimeOnOff-ControllerProgrammable cyclingIntermittent aeration
Ratio-ControllerFlow ratio with PID trimRAS/WAS ratio
ContinuousP-ControllerIntegrating proportionalValve positioning
Feedforward-ControllerDisturbance-basedLoad 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:

  1. Integral Clamping: Limits integral term magnitude
  2. 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 --> Nodes

Configuration ​

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 ​

  1. Start Conservative: Begin with low gains and increase gradually
  2. Tune Sequential: For cascade, tune slave first, then master
  3. Monitor Oscillations: Reduce Kp if oscillations occur
  4. Integral Action: Ki should be 5-10× slower than Kp response

Typical Tuning Values ​

ApplicationKp RangeKi RangeKd RangeNotes
DO Control20-1005-200-10Fast response needed
SRT Control50-2000.5-50Slow integration
RAS Ratio0.2-1.00.02-0.10Gentle control
pH Control20-1002-100.5-3Nonlinear near 7.0
Flow Control0.5-2.00.05-0.20-0.1Quick 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 ​

IssueLikely CauseSolution
OscillationKp too highReduce Kp by 50%
Slow responseKp too lowIncrease Kp gradually
OffsetKi too lowIncrease Ki
OvershootKi too high or Kd too lowReduce Ki or add Kd
Noise amplificationKd too highReduce Kd or increase filter
SaturationLimits too tightCheck output limits

References ​

  1. Seborg, D.E., et al. "Process Dynamics and Control" (4th Edition)
  2. Rieger, L., et al. "Guidelines for Using Activated Sludge Models" (IWA)
  3. Olsson, G. "ICA and Me - A Subjective Review" (Water Research, 2012)