Field fix / guideDesign DocumentVendor-agnostic (IEC 61131-3)Generic Modulesindustrial-automation

Pressure Control Loop (PID-Based) — Control Design

Shared by TSIMEREZIVO Team · 4 Oct 2026 · 43 views

# Generic Module: Pressure Control Loop (PID-Based) **Version**: 1.0 **Complexity**: Medium-High **Industries**: Chemical, Pneumatics, Hydraulics, Oil & Gas, Compressor Systems **PLC Languages**: ST, FBD **Sensor**: Pressure transmitter (0-4000 kPa typical) --- ## 📋 Overview Maintain system pressure at setpoint via proportional valve modulation. Prevents overpressure conditions and minimizes pressure oscillations. **Use When:** - ✅ Need constant pressure regulation (gas, liquid, compressed air lines) - ✅ Proportional/solenoid valve available for modulation - ✅ Pressure transducer with 4-20mA output available - ✅ Precision ±5% required (better than relief valve alone) **Do NOT Use When:** - ❌ Simple relief valve adequate (cost-prohibitive) - ❌ Fast response needed (<1 second, use proportional relief) - ❌ No modulating valve available (only on/off solenoid) --- ## 🎯 Control Philosophy ``` Error = Pressure_Setpoint - Pressure_Actual Output = (Kp × Error) + (Ki × ∫Error) + (Kd × dError/dt) When Error = 0 (at setpoint): → Output holds steady (integral eliminates drift) When Pressure rises (error negative): → Proportional term increases valve opening → Relieves pressure to setpoint When Pressure falls (error positive): → Proportional term closes valve → Pump/compressor builds pressure back up Integral term prevents hunting (valve oscillating) Derivative term dampens overshoot ``` **Why PID for Pressure?** - ✅ Smooth regulation without overshooting - ✅ Eliminates steady-state offset - ✅ Responds quickly to load changes - ✅ Adapts to gradual seal leakage --- ## 🏗️ Control Logic (Pseudocode) ```pascal PROGRAM Pressure_PID_Control VAR (* ─── SENSOR INPUT ─── *) Pressure_Raw : INT; (* 0-4095 from transducer *) Pressure_Actual : REAL; (* bar or psi *) (* ─── SETPOINT & LIMITS ─── *) Pressure_Setpoint : REAL := 50.0; (* bar, operator adjustable *) Pressure_Max_Trip : REAL := 70.0; (* Safety overpressure limit *) Pressure_Min_Alarm : REAL := 5.0; (* Low pressure alarm *) (* ─── PID PARAMETERS (tuned during commissioning) ─── *) Kp : REAL := 0.8; (* Proportional gain *) Ki : REAL := 0.05; (* Integral gain *) Kd : REAL := 0.1; (* Derivative gain *) Integral_Limit : REAL := 30.0; (* Anti-windup clamp *) Deadband : REAL := 0.5; (* Ignore errors < ±0.5 bar *) (* ─── PID STATE VARIABLES ─── *) Error : REAL := 0.0; Error_Previous : REAL := 0.0; Error_Integral : REAL := 0.0; Error_Derivative : REAL := 0.0; (* ─── OUTPUT COMMAND ─── *) PID_Output : REAL := 0.0; (* 0-100% valve modulation *) Output_Limited : REAL := 0.0; (* Clamped to 0-100% *) (* ─── STATUS & ALARMS ─── *) System_Mode : INT := 0; (* 0=Off, 1=Manual, 2=Auto *) Pressure_High_Alarm : BOOL := FALSE; Pressure_Low_Alarm : BOOL := FALSE; Pressure_Trip : BOOL := FALSE; Valve_Fault : BOOL := FALSE; PID_Integral_Saturated : BOOL := FALSE; (* ─── DIAGNOSTICS ─── *) Pressure_Error_Max : REAL := 0.0; (* Peak deviation from SP *) Response_Time_Sec : REAL := 0.0; END_VAR (* ═════════════════════════════════════════════════════════════ *) (* 1. SENSOR CONVERSION (mA to pressure) *) (* ═════════════════════════════════════════════════════════════ *) (* Convert 0-4095 (4-20mA) to 0-100 bar *) (* Typical relation: 4mA = 0 bar, 20mA = 100 bar *) Pressure_Actual := (Pressure_Raw / 4095.0) * 100.0; (* ═════════════════════════════════════════════════════════════ *) (* 2. SAFETY INTERLOCKS *) (* ═════════════════════════════════════════════════════════════ *) (* Overpressure trip (immediate valve full open) *) IF Pressure_Actual > Pressure_Max_Trip THEN Output_Limited := 100.0; (* Dump all pressure *) Pressure_Trip := TRUE; System_Mode := 0; (* Disable auto mode *) ALARM_OVERPRESSURE_TRIP := TRUE; ELSIF Pressure_Actual > Pressure_Setpoint + 10.0 THEN Pressure_High_Alarm := TRUE; END_IF; (* Low pressure alarm *) IF Pressure_Actual < Pressure_Min_Alarm THEN Pressure_Low_Alarm := TRUE; END_IF; (* ═════════════════════════════════════════════════════════════ *) (* 3. PID CALCULATION (when in auto mode) *) (* ═════════════════════════════════════════════════════════════ *) IF System_Mode = 2 THEN (* AUTO mode *) (* Calculate error *) Error := Pressure_Setpoint - Pressure_Actual; (* Apply deadband *) IF ABS(Error) < Deadband THEN Error := 0.0; END_IF; (* ─── PROPORTIONAL TERM ─── *) Proportional_Term := Kp * Error; (* ─── INTEGRAL TERM ─── *) Error_Integral := Error_Integral + (Error * SCAN_TIME_SEC); (* Anti-windup: clamp integral *) IF ABS(Error_Integral) > Integral_Limit THEN Error_Integral := MAX(-Integral_Limit, MIN(Integral_Limit, Error_Integral)); PID_Integral_Saturated := TRUE; ELSE PID_Integral_Saturated := FALSE; END_IF; Integral_Term := Ki * Error_Integral; (* ─── DERIVATIVE TERM ─── *) Error_Derivative := (Error - Error_Previous) / SCAN_TIME_SEC; Derivative_Term := Kd * Error_Derivative; Store: Error_Previous := Error; (* ─── COMBINE PID ─── *) PID_Output := Proportional_Term + Integral_Term + Derivative_Term; (* Track maximum error for commissioning analysis *) Pressure_Error_Max := MAX(Pressure_Error_Max, ABS(Error)); ELSIF System_Mode = 1 THEN (* MANUAL mode *) (* Operator directly adjusts valve via slider input *) (* PID_Output not used *) ELSE (* OFF mode *) PID_Output := 0.0; END_IF; (* ═════════════════════════════════════════════════════════════ *) (* 4. OUTPUT LIMITING & VALVE COMMAND *) (* ═════════════════════════════════════════════════════════════ *) (* Clamp output to 0-100% *) Output_Limited := MAX(0.0, MIN(100.0, PID_Output)); (* Write to proportional relief valve (0-100% = 0-4095 mV) *) WRITE_ANALOG_OUTPUT(AO_RELIEF_VALVE, Output_Limited); (* ═════════════════════════════════════════════════════════════ *) (* 5. DIAGNOSTICS & TRENDING *) (* ═════════════════════════════════════════════════════════════ *) (* Measure response time to setpoint *) IF (ABS(Error) <= 1.0) AND NOT Response_Time_Ready THEN Response_Time_Sec := Response_Time_Sec + SCAN_TIME_SEC; END_IF; (* Log every 10 seconds *) IF (SCAN_COUNT MOD 10) = 0 THEN LOG_PRESSURE_TREND := [ Timestamp: NOW(), Pressure_SP: Pressure_Setpoint, Pressure_PV: Pressure_Actual, Error: Error, Output%: Output_Limited, Kp_Term: Proportional_Term, Ki_Sum: Error_Integral, Kd_Term: Derivative_Term ]; END_IF; END_PROGRAM ``` --- ## 🏷️ Tag List | Tag | Type | I/O | Range | Description | |-----|------|-----|-------|-------------| | `PRESSURE_01_ACTUAL` | REAL | Feedback | 0-100 bar | System pressure reading | | `PRESSURE_01_SETPOINT` | REAL | Param | 0-100 bar | Desired pressure | | `PRESSURE_01_ERROR` | REAL | Status | -100…100 bar | Setpoint - Actual | | `PRESSURE_01_SP_LOW` | REAL | Alarm | 0-100 bar | Low limit alarm threshold | | `PRESSURE_01_SP_HIGH` | REAL | Alarm | 0-100 bar | High limit alarm threshold | | `PRESSURE_01_TRIP` | REAL | Safety | 0-100 bar | Overpressure (full vent) | | `PRESSURE_01_VALVE_CMD` | REAL | Output | 0-100 % | Relief valve modulation | | `PRESSURE_01_KP` | REAL | Param | 0-5 | Proportional gain | | `PRESSURE_01_KI` | REAL | Param | 0-0.5 | Integral gain | | `PRESSURE_01_KD` | REAL | Param | 0-1 | Derivative gain | | `PRESSURE_01_MODE` | INT | Cmd | 0/1/2 | 0=Off, 1=Manual, 2=Auto | | `PRESSURE_01_INTEGRAL_SAT` | BOOL | Alarm | - | Integral term clamped | | `PRESSURE_01_ALRM_HIGH` | BOOL | Alarm | - | Pressure > high limit | | `PRESSURE_01_ALRM_LOW` | BOOL | Alarm | - | Pressure < low limit | | `PRESSURE_01_TRIP_HIGH` | BOOL | Alarm | - | Overpressure trip | | `PRESSURE_01_RESPONSE_TIME` | REAL | Metrics | 0-300 sec | Time to reach ±1 bar | --- ## 🚨 Alarm & Trip Matrix | Alarm | Condition | Severity | Auto-Reset | |-------|-----------|----------|-----------| | **Overpressure Trip** | Pressure > Max Trip | Critical | Manual (acknowledge) | | **High Pressure Alarm** | Pressure > Max Alarm | Warning | Auto | | **Low Pressure Alarm** | Pressure < Min Alarm | Warning | Auto | | **Valve Fault** | Output 100% but pressure static | Critical | Manual | | **Integral Saturated** | Error accumulated > limit | Info | Auto | | **No Load Change** | Pressure steady 10+ min | Info | Informational | | **Pump Cavitation** | Rapid pressure chatter | Warning | Check inlet | --- ## 📺 HMI Layout ``` ┌──────────────────────────────────────────┐ │ PRESSURE CONTROL LOOP #1 │ ├──────────────────────────────────────────┤ │ │ │ Setpoint: 50.0 bar ⚙️ [Editable] │ │ │ │ ┌──────────────────────────────────┐ │ │ │ Actual: 50.3 bar │ │ │ │ [██████████████ 50.3 bar] │ │ │ │ Target ↑ 50.0 bar │ │ │ │ Error: +0.3 bar (stable) │ │ │ └──────────────────────────────────┘ │ │ │ │ Status: REGULATING [●●●] │ │ Relief Valve: 25% [██████░░░░░░░░░░│ │ │ Response: Settled (45 seconds) │ │ │ │ ┌─────────────────────────────────┐ │ │ │ PID Gains (Advanced) │ │ │ │ Kp: 0.80 Ki: 0.05 │ │ │ │ Kd: 0.10 Deadband: 0.5 bar │ │ │ │ [AutoTune] [Load Preset] │ │ │ └─────────────────────────────────┘ │ │ │ │ Limits: │ │ Alarm High: 55.0 bar │ │ Alarm Low: 5.0 bar │ │ Trip High: 70.0 bar (→ vent) │ │ │ │ Mode: [Off] [Manual ⊙] [Auto ◉] │ │ │ └──────────────────────────────────────────┘ ``` --- ## 🔧 Configuration Parameters ```json { "sensor_range_bar": [0, 100], "control_mode": "auto", "pressure_setpoint": 50.0, "alarm_low_bar": 5.0, "alarm_high_bar": 55.0, "trip_high_bar": 70.0, "deadband_bar": 0.5, "kp_proportional": 0.8, "ki_integral": 0.05, "kd_derivative": 0.1, "integral_anti_windup_limit": 30.0, "valve_type": "proportional_relief", "valve_response_ms": 200, "pump_max_pressure": 80.0, "system_max_safe_pressure": 100.0, "tuning_method": "ziegler_nichols", "scan_time_ms": 100 } ``` --- ## 📝 Implementation Checklist ### Before Deployment - [ ] **Pressure transmitter calibrated** (0 bar = 4mA, 100 bar = 20mA) - [ ] **Relief valve proportional coil tested** (0-100% energization produces 0-100 bar relief) - [ ] **System pressure gauge verified** (compare to transmitter at 5 points spanning 0-100 bar) - [ ] **Deadman button installed** (manual relief if system fails) - [ ] **System flushed** (no contamination that would clog valve) ### During Commissioning 1. **Manual mode test**: - Switch to Manual mode - Valve command 0% → 25% → 50% → 100% - Verify pressure decreases smoothly as valve opens - Record valve response time (should be <500ms) 2. **Auto mode startup**: - Target pressure: 30 bar (half of max) - Observe ramp up (should be smooth) - Monitor error: should converge to ±2% - Settling time typical: 30-60 seconds 3. **Load step test**: - Demand sudden 10% more flow - Pressure should dip <5%, recover within 30 sec - No overshoot >10% 4. **Overpressure test**: - Valve command 0% (fully closed) - Let pressure rise to trip point - Verify trip cuts fuel/pump immediately - Pressure should vent to safe level --- ## 📊 Expected Performance | Metric | Target | Achievable | |--------|--------|-----------| | **Steady-state error** | ±1% | ±0.5-2% | | **Settling time** | 60 sec | 30-90 sec | | **Overshoot** | <5% | 2-8% | | **Oscillation** | Damped | <±1 bar peak | | **Response to load step** | <30 sec | 15-45 sec | | **Valve response time** | <200 ms | 150-300 ms | --- ## 🔄 Advanced Variations ### Load-Compensated Control Measure system flow (via flow meter), feed-forward to adjust valve ahead of pressure change. ### Cascade Control Inner loop: Proportional valve pressure feedback Outer loop: System pressure setpoint → Faster response, independent of pump dynamics ### Pressure Limiting (vs Relief) Instead of full modulation, use 2-port proportional relief: - 0-50% output: pump bypass (low relief) - 50-100% output: pump discharge (high relief or dump) --- **Production-ready pressure control for pneumatic, hydraulic, and gas systems.**

More like this

Rate, comment, and get full access

Members can download files, rate contributions, and discuss fixes with the engineers who posted them — free.

Join the library