Field fix / guideDesign DocumentVendor-agnostic (IEC 61131-3)Water / Wastewaterindustrial-automation
Activated Sludge Aeration Basin Control — Control Design
Shared by TSIMEREZIVO Team · 4 Oct 2026 · 45 views
# Water/Wastewater Template: Activated Sludge Aeration Basin Control
## 1. Overview
**Purpose:**
Maintain dissolved oxygen (DO) setpoint in activated sludge reactor tank through automatic aeration control. The aeration basin is the **heart of wastewater treatment**, where microorganisms consume organic pollutants (BOD) under aerobic conditions. Precise DO control maximizes treatment efficiency while minimizing energy cost.
**Industry Standards:**
- EPA Wastewater Treatment Standards (40 CFR Part 133)
- WPCF (Water Pollution Control Federation) Manual of Practice
- ISO 2941 (Dissolved oxygen measurement in water)
- ASME B29.1 (Blower & compressor piping)
- NFPA 70 (WET location electrical installation)
**Critical Constraints:**
- **DO setpoint:** 1.5 – 3.5 mg/L (typical range depends on BOD loading and sludge age)
- **Temperature effect:** DO solubility ↓ ~2% per °C increase → same air flow = lower DO at 25°C vs. 10°C
- **PID loop:** Proportional aeration intensity to demand; **avoid hunting** (on/off chatter)
- **Sludge washout:** Excessive DO can **strip** CO₂, raising pH → nitrification inhibition
- **Turndown ratio:** Aeration can be modulated 5:1 (VFD) or 10:1 (multi-blower switcher)
- **Response lag:** DO sensor reads ; PLC adjusts aeration; bulk tanks (500 m³+) have **30–90 second lag**
- **Biota compliance:** Sudden aeration loss kills nitrifiers; gradual ramp-down required for shutdown
**Relevant Physics:**
- **Aeration:** Henry's Law: $C = k_H \cdot P_{O_2}$ (gas-liquid equilibrium)
- **Deficiency rate:** $\frac{dO_2}{dt} = k_L a (C^* - C) - O_2\_uptake$
- $k_L a$ = oxygen transfer coefficient (depends on aerator design, tank geometry)
- $C^*$ = saturation concentration (function of T, salinity)
- $C$ = current dissolved oxygen
- $O_2\_uptake$ = biological oxygen demand from microbes
- **Aeration response:** VFD-driven blower (0–100% speed) reaches new DO setpoint in **2–8 minutes** (depends on basin volume)
---
## 2. Control Philosophy
**Challenge:**
A wastewater plant must treat 1,000–10,000 m³/day of influent (incoming sewage). DO too low → treatment fails, effluent quality ↓. DO too high → energy cost ↑ by 40–60%, aeration is largest operating expense. Must adapt aeration to:
- Time of day (more BOD mid-morning, less at night)
- Influent flow rate (rainy day = more sewage dilution = less oxygen demand)
- Temperature (cold water holds more oxygen → lower air flow needed)
- Plant loading (seasonal variation: summer = higher temperature + more BOD)
**Solution: Cascaded PID with Feedforward**
```
LAYER 1 — Master DO Controller
Input: DO sensor (mg/L) in aeration basin
SP: DO_setpoint (1.5–3.5 mg/L, typically 2.5 mg/L)
Output: Demand signal (0–100%)
LAYER 2A — Aeration Intensity Modulator (VFD Blower)
Input: Demand from Layer 1
Output: VFD frequency command (30–60 Hz)
Hysteresis: ±0.2 mg/L deadband (reduce hunting)
LAYER 2B — Feedforward Predictor
Inputs: Current flow, BOD estimate (proxy: UV absorbance)
Output: Bias offset to Layer 1 (pre-emptively ramp aeration up/down)
LAYER 3 — Return Sludge Pump (RAS) Feedback
Role: Return microbe biomass from clarifier back to aeration basin
Setpoint: MLSS (Mixed Liquor Suspended Solids) 3,500–5,500 mg/L
Adjust: RAS flow to maintain target MLSS concentration
LAYER 4 — Waste Sludge Pump (WAS) Flow
Role: Remove excess biomass to prevent sludge age drift
Setpoint: Sludge Age = 5–15 days (depends on treatment objective)
```
**Why This Approach:**
- PID alone lags 2–8 minutes; feedforward anticipates BOD swings within 30 seconds
- Hysteresis reduces aeration on/off cycling (saves compressor life, reduces noise)
- RAS + WAS loops decouple biomass control from DO control
- Cascade avoids over-aeration during low-load periods
---
## 3. Control Logic
**Pseudocode: Multi-Layer Aeration Basin Control**
```pascal
{ === ACTIVATED SLUDGE AERATION BASIN CONTROL === }
{ Maintain DO setpoint 1.5–3.5 mg/L via VFD blower + return sludge (RAS) + waste (WAS) }
PROCEDURE Aeration_Basin_Master_Controller
CONSTANTS
DO_SP_BASE = 2.5 { mg/L, default setpoint }
DO_HYSTERESIS = 0.2 { ±0.2 mg/L deadband to prevent hunting }
MLSS_SP = 4500 { mg/L, target mixed liquor suspended solids }
SLUDGE_AGE_SP = 10 { days, target sludge retention time }
VFD_MIN_HZ = 30 { minimum VFD frequency (avoid stall) }
VFD_MAX_HZ = 60 { maximum VFD frequency }
BASIN_VOLUME_M3 = 750 { aeration tank volume }
PID_KP = 8.0 { proportional gain for DO controller }
PID_KI = 0.15 { integral gain }
PID_KD = 2.0 { derivative gain }
TEMP_CORRECTION_FACTOR = 0.02 { DO solubility ↓ 2% per °C }
VARIABLES
{ Measured inputs }
do_sensor_raw : REAL { mg/L, raw sensor reading }
do_filtered : REAL { mg/L, low-pass filtered }
temp_reactor : REAL { °C, temperature probe }
influent_flow : REAL { m³/h, wastewater inflow }
influent_bod : REAL { mg/L, estimated BOD (via UV sensor proxy) }
pH_reactor : REAL { pH, for nitrification monitoring }
mlss_measured : REAL { mg/L, suspended solids in basin }
{ Sensor quality checks }
do_sensor_drift : REAL { mg/L, drift over 24 hours }
sensor_fault_detected : BOOLEAN { 0/1, drop >2 mg/L in <30 sec }
{ PID state }
do_error : REAL { SP - measured }
do_error_integral : REAL { sum of errors over time }
do_error_derivative : REAL { rate of error change }
pid_output : REAL { 0–100% aeration demand }
{ Aeration control }
aeration_demand : REAL { 0–100%, primary output to VFD }
aeration_demand_prev : REAL { previous cycle value }
vfd_frequency_command : REAL { 30–60 Hz }
blower_fault : BOOLEAN { 0/1, compressor alarm }
{ Feedforward adjustment }
feedforward_bias : REAL { additive offset to aeration (anticipatory) }
flow_rate_change_rate : REAL { derivative of influent flow }
bod_estimate : REAL { estimated BOD from UV sensor }
{ RAS (Return Activated Sludge) pump control }
ras_pump_demand : REAL { 0–100%, flow modulation }
ras_flow_setpoint : REAL { m³/h, calculated from MLSS balance }
ras_flow_measured : REAL { m³/h }
{ WAS (Waste Activated Sludge) pump control }
was_pump_demand : REAL { 0–100%, intermittent or continuous }
sludge_age_estimated : REAL { days, calculated from inventory }
waste_batch_timer : INTEGER { sec, for batch waste operation }
{ Diagnostics }
aeration_cost_kwh : REAL { energy consumed today }
treatment_efficiency_percent : REAL { BOD removal % }
alarms_active : ARRAY[*] OF STRING { active fault messages }
BEGIN
{ === SENSOR ACQUISITION & VALIDATION === }
do_sensor_raw = Read_DO_Sensor() { 0–20 mA input }
temp_reactor = Read_Temperature() { Pt100 RTD }
influent_flow = Read_Flow_Meter() { magnetic flowmeter }
influent_bod = Estimate_BOD_From_UV_Sensor() { proxy }
mlss_measured = Read_MLSS_Sensor() { scattered light turbidity }
pH_reactor = Read_pH_Probe()
{ Low-pass filter DO sensor (tau = 30 sec) to smooth noise }
alpha_lp = 0.15 { time constant adjustment }
do_filtered = do_filtered × (1 - alpha_lp) + do_sensor_raw × alpha_lp
{ Detect sensor faults }
IF ABS(do_sensor_raw - do_filtered) > 2.0 THEN
sensor_fault_detected = TRUE
Log_Alarm("DO_SENSOR_FAULT_SPIKE")
END IF
IF Elapsed_Time_Since_Sensor_Zero_Calibration() > 7 DAYS THEN
Log_Warning("DO_SENSOR_NEEDS_RECALIBRATION")
END IF
{ === FEEDFORWARD COMPENSATION === }
{ Adjust DO setpoint based on temperature (cold water holds more O₂) }
temp_correction = (temp_reactor - 20) × TEMP_CORRECTION_FACTOR
do_sp_adjusted = DO_SP_BASE + temp_correction
{ Example: at 25°C, setpoint raised by +0.1 mg/L }
{ Early feedforward: if BOD spike predicted, pre-ramp aeration }
flow_rate_change = influent_flow - influent_flow_prev
IF flow_rate_change > 50 THEN { >50 m³/h jump (rainy day) }
feedforward_bias = 10.0 { add 10% aeration demand immediately }
ELSIF ABS(influent_bod - influent_bod_prev) > 100 THEN { >100 mg/L jump }
feedforward_bias = 15.0
ELSE
feedforward_bias = LIMIT(feedforward_bias - 1, 0, 20) { decay feedforward }
END IF
{ === MASTER DO FEEDBACK CONTROLLER (PID) === }
do_error = do_sp_adjusted - do_filtered
{ Dead-band: if within ±deadband, treat error as zero (reduce hunting) }
IF ABS(do_error) < DO_HYSTERESIS THEN
do_error := 0.0
END IF
{ Integral term (I) — sum of past errors }
do_error_integral := do_error_integral + do_error
do_error_integral = LIMIT(do_error_integral, -50, 50) { anti-windup }
{ Derivative term (D) — rate of error change }
do_error_derivative = do_error - do_error_prev
{ PID output }
pid_output = (PID_KP × do_error) + (PID_KI × do_error_integral) + (PID_KD × do_error_derivative)
{ Combine with feedforward }
aeration_demand = LIMIT(pid_output + feedforward_bias, 0, 100)
{ Rate limiter: prevent wild swings (max 25% change per 30 sec) }
demand_rate_limit = 25
IF ABS(aeration_demand - aeration_demand_prev) > demand_rate_limit THEN
aeration_demand = aeration_demand_prev + SIGN(aeration_demand - aeration_demand_prev) × demand_rate_limit
END IF
{ === VFD BLOWER OUTPUT === }
IF blower_fault THEN
vfd_frequency_command := VFD_MIN_HZ { safe idle }
Log_Alarm("BLOWER_FAULT_CHECK_COMPRESSOR")
ELSE
vfd_frequency_command = VFD_MIN_HZ + (aeration_demand × (VFD_MAX_HZ - VFD_MIN_HZ) / 100)
vfd_frequency_command = LIMIT(vfd_frequency_command, VFD_MIN_HZ, VFD_MAX_HZ)
END IF
{ Send to VFD drive }
Write_VFD_Frequency_Command(vfd_frequency_command)
{ Monitor blower power (optional soft-start protection) }
blower_power_kw = Read_Blower_Power_Draw()
IF blower_power_kw > 150 THEN { threshold example }
Activate_Compressor_Unload_Valve() { bypass compressor to reduce load }
END IF
{ === RETURN ACTIVATED SLUDGE (RAS) PUMP CONTROL === }
{ RAS maintains mixed liquor concentration }
mlss_error = MLSS_SP - mlss_measured
{ Simple P-only: higher MLSS error → higher RAS flow }
ras_pump_demand = LIMIT(50 + (mlss_error × 0.2), 20, 100) { 20–100% min/max }
Write_RAS_Pump_Speed(ras_pump_demand)
{ === WASTE ACTIVATED SLUDGE (WAS) PUMP CONTROL === }
{ WAS removes excess biomass to maintain sludge age }
sludge_age_estimated = (mlss_measured × BASIN_VOLUME_M3) / (was_pump_flow × 24)
{ simplified; assumes steady state }
sludge_age_error = SLUDGE_AGE_SP - sludge_age_estimated
IF sludge_age_error > 2 THEN { too old; remove more sludge }
was_pump_demand = LIMIT(was_pump_demand + 2, 0, 80)
ELSIF sludge_age_error < -2 THEN { too young; stop wasting }
was_pump_demand = LIMIT(was_pump_demand - 1, 0, 20)
END IF
Write_WAS_Pump_Speed(was_pump_demand)
{ === PROCESS DIAGNOSTICS & ALARMS === }
CLEAR alarms_active
{ DO too low → treatment failure risk }
IF do_filtered < 0.5 THEN
APPEND alarms_active "CRITICAL_DO_TOO_LOW"
Activate_Backup_Blower()
END IF
{ DO too high → energy waste }
IF do_filtered > 4.5 AND vfd_frequency_command > 50 THEN
Log_Warning("DO_EXCESSIVE_CONSIDER_AERATION_REDUCTION")
END IF
{ MLSS drift → sludge balance failure }
IF mlss_measured < 2500 THEN
Log_Warning("MLSS_TOO_LOW_CHECK_CLARIFIER_SETTLING")
ELSIF mlss_measured > 6500 THEN
Log_Warning("MLSS_TOO_HIGH_INCREASE_WAS")
END IF
{ pH drift → nitrification interference }
IF pH_reactor > 8.2 THEN
Log_Warning("pH_HIGH_POSSIBLE_OVER_AERATION_STRIPPING_CO2")
ELSIF pH_reactor < 6.5 THEN
Log_Warning("pH_LOW_NITRIFICATION_INHIBITED")
aeration_demand = LIMIT(aeration_demand + 5, 0, 100) { slight boost }
END IF
{ Energy cost tracking }
blower_power_kw = Read_Blower_Power_Draw()
aeration_cost_kwh := aeration_cost_kwh + (blower_power_kw / 3600) { accumulate }
{ Treatment efficiency }
effluent_bod = Read_Effluent_BOD_Analyzer()
treatment_efficiency_percent = (influent_bod - effluent_bod) / influent_bod × 100
IF treatment_efficiency_percent < 85 THEN
Log_Warning("POOR_TREATMENT_EFFICIENCY_CHECK_SRT_LOAD")
END IF
{ === LOG & TREND === }
IF MOD(scan_count, 600) = 0 THEN { every 10 minutes }
Log_Process_Data({
timestamp: Get_Timestamp(),
do_level: do_filtered,
aeration_demand: aeration_demand,
vfd_freq: vfd_frequency_command,
mlss: mlss_measured,
ras_flow: ras_flow_measured,
was_flow: was_pump_demand,
temp: temp_reactor,
ph: pH_reactor,
blower_kw: blower_power_kw,
treatment_eff_pct: treatment_efficiency_percent
})
END IF
do_error_prev = do_error
influent_flow_prev = influent_flow
influent_bod_prev = influent_bod
aeration_demand_prev = aeration_demand
END PROCEDURE
```
---
## 4. Tag List (Selected)
```
AERATION_BASIN_DO_SENSOR { mg/L, dissolved oxygen (0–20 mA input) }
AERATION_BASIN_DO_SETPOINT { mg/L, target: 2.5 (range 1.5–3.5) }
AERATION_BASIN_TEMPERATURE { °C, reactor temperature }
AERATION_BASIN_PH { pH units, nitrification monitor }
AERATION_BASIN_MLSS { mg/L, mixed liquor suspended solids }
INFLUENT_FLOW_RATE { m³/h, wastewater flow }
INFLUENT_BOD_ESTIMATE { mg/L, estimated from UV }
BLOWER_VFD_FREQUENCY { Hz, 30–60 Hz command }
BLOWER_VFD_DEMAND { %, 0–100 aeration intensity }
BLOWER_POWER_KW { kW, compressor power draw }
RAS_PUMP_DEMAND { %, return sludge pump }
RAS_PUMP_FLOW_MEASURED { m³/h }
WAS_PUMP_DEMAND { %, waste sludge pump }
SLUDGE_AGE_ESTIMATED { days, retention time }
EFFLUENT_BOD_ANALYZER { mg/L, treated water quality }
TREATMENT_EFFICIENCY_PCT { %, (influent – effluent) / influent }
AERATION_ENERGY_COST_KWH { cumulative kWh }
```
---
## 5. Alarm & Trip Matrix
| **Condition** | **Severity** | **Action** |
|---|---|---|
| **DO < 0.5 mg/L** | 🔴 CRIT | Activate backup blower; page operator |
| **DO > 5.0 mg/L** | ⚠ WARN | Reduce VFD; check for flow surge |
| **MLSS < 2,500 mg/L** | ⚠ WARN | Reduce WAS; check clarifier |
| **MLSS > 6,500 mg/L** | 🟡 WARN | Increase WAS pump |
| **pH > 8.2** | ⚠ WARN | Reduce aeration (CO₂ stripping) |
| **pH < 6.5** | ⚠ WARN | Slight aeration boost; check acid input |
| **Temp > 35°C** | ⚠ WARN | Monitor for nitrifier stress |
| **Blower Fault** | 🔴 CRIT | Activate manual compressor; alert maint. |
| **Treatment Eff. < 85%** | ⚠ WARN | Review SRT, influent load, MLSS balance |
| **Sensor Drift >1 mg/L / day** | ⚠ WARN | Schedule DO sensor calibration |
---
## 6. HMI Layout
```
╔════════════════════════════════════════════════════════════════════╗
║ ACTIVATED SLUDGE AERATION BASIN — PLANT A ║
╚════════════════════════════════════════════════════════════════════╝
STATUS: [ RUNNING ] ✓ ALL SYSTEMS NORMAL
┌─────────────────────────────────────────────────────────────────┐
│ DISSOLVED OXYGEN CONTROL │
│ │
│ DO Setpoint: 2.5 mg/L │
│ DO Measured: 2.43 mg/L ✓ (97% SP) │
│ Error: -0.07 mg/L (within deadband) │
│ │
│ [█████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] ← PID Error Trend │
│ -1.0 0.0 +1.0 mg/L │
│ │
│ Aeration Demand: 42% VFD Frequency: 44.5 Hz │
│ [████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0–100%│
│ │
│ Temperature Correction: +0.08 mg/L (T = 24°C) │
│ Feedforward Bias: +3% (slight BOD elevation detected) │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ MIXED LIQUOR & SLUDGE MANAGEMENT │
│ │
│ MLSS Measured: 4,320 mg/L ✓ (target: 4,500) │
│ RAS Pump: 58% Flow: 145 m³/h │
│ WAS Pump: 34% Flow: 22 m³/h │
│ [████████░░░░░░░░░░░░░░░░░░░░░░░░] 3.5–5.5 k mg/L target │
│ │
│ Estimated Sludge Age: 9.8 days ✓ (target: 10 days) │
│ Sludge Age Trend: [════════════════] 5 15 days │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ PROCESS QUALITY │
│ │
│ Influent Flow: 875 m³/h (normal for 10 AM Tue) │
│ Influent BOD Est.: 420 mg/L (mid-morning peak) │
│ Effluent BOD (Ana.): 32 mg/L ✓ (target <50) │
│ Treatment Efficiency: 92.4% ✓ GOOD │
│ │
│ pH: 7.2 ✓ | Temp: 24°C ✓ │
│ │
│ Blower Power: 62 kW (today's cumulative: 445 kWh) │
│ Est. Daily Cost: $42/day @ $0.12/kWh │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ 4-HOUR TREND GRAPH │
│ │
│ DO (mg/L) Aeration Demand (%) MLSS (mg/L) │
│ 4.0 ┤ ╱╲╱╲╱╲ 100 ┤ ╱╲ 6000 ┤ │
│ 3.0 ┤────┼───────── 50 ┤────────── 4000 ┤───┐ │
│ 2.5 ┼────╋───────── 40 ┤ ╱╲╱╲ 4500 ┼───┼───┼──── │
│ 1.5 ┤────┼───────── 0 ┤ ╲ ┤ │ │ │
│ 0.0 ┤____└ └──── └──────────── 3000 ┤───┘ │ │
│ └──────────────────── └────────────── └──────────── │
│ 12:00 14:00 16:00 12:00 14:00 12:00 14:00 │
│ DO steady ~2.5 Demand ramped 0–50% MLSS stable │
└─────────────────────────────────────────────────────────────────┘
CONTROL BUTTONS:
[ Manual VFD Override... ] [ Reduce / Maintain / Boost Aeration ]
[ Emergency Blower Backup ] [ Dump WAS Now (one cycle) ]
```
---
## 7. Configuration
**JSON (aeration_basin_config.json)**
```json
{
"plant": {
"name": "Plant A",
"aeration_basins": 1,
"total_volume_m3": 750,
"design_capacity_mglpd": 10000,
"sludge_age_target_days": 10
},
"do_control": {
"setpoint_base_mgl": 2.5,
"setpoint_range_min": 1.5,
"setpoint_range_max": 3.5,
"hysteresis_mgl": 0.2,
"sensor_type": "polarographic_DO",
"calibration_interval_days": 7
},
"pid_tuning": {
"kp": 8.0,
"ki": 0.15,
"kd": 2.0,
"integral_anti_windup_limit": 50,
"rate_limiter_pct_per_30sec": 25
},
"vfd_blower": {
"type": "variable_frequency_drive",
"frequency_min_hz": 30,
"frequency_max_hz": 60,
"power_rating_kw": 90,
"fault_response": "activate_backup_blower"
},
"mlss_control": {
"setpoint_mgl": 4500,
"range_min_mgl": 3500,
"range_max_mgl": 5500,
"ras_pump_p_gain": 0.2
},
"sludge_waste": {
"target_sludge_age_days": 10,
"was_pump_max_demand_pct": 80,
"was_pump_min_demand_pct": 0
},
"feedforward": {
"enable": true,
"temp_correction_pct_per_c": 2.0,
"flow_jump_threshold_m3h": 50,
"bod_jump_threshold_mgl": 100
},
"alarms": {
"do_critical_low_mgl": 0.5,
"do_warn_high_mgl": 4.5,
"mlss_low_mgl": 2500,
"mlss_high_mgl": 6500,
"ph_low": 6.5,
"ph_high": 8.2
}
}
```
---
## 8. Implementation Checklist
### Design Phase
- [ ] Conduct basin hydraulic study (residence time = volume / flow)
- [ ] Calibrate DO sensor (zero, span; compare to lab method)
- [ ] Establish MLSS baseline samples (manual analysis x 7 days minimum)
- [ ] Select aeration equipment (fine bubble, coarse bubble, surface aerators)
- [ ] Verify blower capacity (SCFM or m³/min) for peak demand
### Soft Commissioning (Simulated Wastewater)
- [ ] Simulate BOD spike: manually increase aeration demand; verify DO rises in 3–5 min
- [ ] Verify PID hysteresis works: DO should not chatter ±0.5 mg/L
- [ ] Test RAS pump: increase setpoint; confirm MLSS rises (flow + settling ratio)
- [ ] Test WAS pump: run x5 minutes; confirm MLSS drops
- [ ] Feedforward test: step increase influent flow; verify aeration pre-ramps
### Production Commissioning (Real Wastewater)
- [ ] Run plant at 25% design flow; monitor stability for 48 hours
- [ ] Adjust PID gains (Ziegler–Nichols or Tyreus–Luyben method) if hunting observed
- [ ] Daily MLSS & SVI (Sludge Volume Index) samples x7 days
- [ ] Baseline effluent BOD, TSS, TN, TP analysis
- [ ] Measure aeration energy cost (kWh / m³ treated); typical = 1–2 kWh/m³
- [ ] Confirm no nitrification inhibition (TN removal >70% → nitrifiers active)
---
**Document Version:** 1.0
**Last Updated:** 2026-04-13
**Status:** Ready for Production
**Approval:** Water/Wastewater Engineering (pending)