Implementing Cascade PID Control in Siemens S7-1500/1200

David Krause10 min read
PID ControlSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Overview

Cascade control is a multi-loop strategy in which the output of an outer (master, primary) PID becomes the setpoint of an inner (slave, secondary) PID. The inner loop is sized to be 3–5x faster than the outer loop, so it can absorb disturbances before they propagate to the slower process variable. Typical applications include reactor temperature control, boiler superheat control, and pressure/flow cascades.

The reference application used throughout this document is a jacketed reactor with an exothermic reaction, where the product temperature is the master PV, jacket-outlet temperature is the slave PV, and the slave drives a split-range valve assembly (cold water at 0–50% controller output, steam at 50–100%). This document covers the full TIA Portal V17+ implementation on S7-1500 (PID_Compact V2, PID_Temp) and S7-1200 (PID_Compact V2), tuning methodology, split-range handling, and field-proven instability fixes.

2. Cascade Architecture

The control diagram for a jacketed reactor cascade:

[SP_material] -> [Master PID] -> [SP_jacket_scaled] -> [Slave PID] -> [0-100%]
                    ^                                ^                          |
                    |                                |                          v
              [PV_material]                  [PV_jacket]              [Split-range block]
                    |                                |                          |
                    +------- RTD/TC input ------------+                          v
                                                                       Valve_cold 0-100%
                                                                       Valve_steam 0-100%
  • Master (primary) loop: PV = material temperature inside the reactor; Setpoint = target product temperature; Output = slave setpoint, normally clamped to ±20% of the nominal operating point.
  • Slave (secondary) loop: PV = jacket-outlet temperature (or valve position); Setpoint = master output; Output = 0–100% valve command.
  • Loop-timing rule: Slave loop settling time should be 3–5x faster than the master loop. If the jacket dynamics settle in 30 s, the master should not be tuned faster than 150–300 s.

3. Prerequisites

  • S7-1500 CPU with firmware V2.5 or higher (PID_Compact V2 requires V2.0+; PID_Temp requires V2.1+).
  • S7-1200 CPU with firmware V4.2 or higher (PID_Compact V2).
  • TIA Portal V15.1 minimum; V17 or higher recommended for PID_Compact V2.3 and PID_Temp current revisions.
  • RTD or thermocouple input module with at least 0.1 K resolution for the slave PV.
  • HMI tag connection to the PID DB for online tuning.

Reference manuals:

4. FB Selection: PID_Compact vs PID_Temp

Feature PID_Compact V2 PID_Temp
CPU support S7-1200, S7-1500 S7-1500 only
Cascade wiring External SCL Internal multi-loop support
Anti-windup Yes, tied to output limits Yes, with configurable tracking
Derivative mode On error (default) or on PV (Mode 2) On PV, weighted α
Tuning in manual Pretuning only Pretuning + fine tuning + tuning in manual
Cooling/heating output Single output, split handled externally Configurable heating + cooling outputs
Typical use Flow, pressure, level, general temperature Slow temperature with long dead time

For jacketed reactor temperature control, prefer PID_Temp on S7-1500. On S7-1200, use PID_Compact V2 with the cascade wired in SCL as shown in Section 5.

5. Implementation: TIA Portal Configuration

5.1 Slave loop (jacket temperature)

  1. Insert PID_Compact V2 in a cyclic OB (recommended OB30 at 100 ms).
  2. Wire Input to the jacket RTD scaled value (REAL, °C).
  3. Leave Setpoint as a tag SP_jacket_real driven externally.
  4. Wire Output to the analog output tag Valve_cmd.
  5. Set initial tuning: Retain.CtrlParams.Gain = 0.5, Retain.CtrlParams.Ti = 60.0 s, Retain.CtrlParams.Td = 0.0 s.
  6. Set Config.InputScaling.UpperPointIn = 100.0, LowerPointIn = 0.0; same for OutputScaling.

5.2 Master loop (material temperature)

  1. Insert a second PID_Compact in a slower OB (OB35 at 1 s recommended).
  2. Wire Input to material thermocouple scaled value.
  3. Wire Setpoint to SP_material_real.
  4. Do not connect Output directly to a valve; scale it to the slave setpoint range as shown in 5.3.

5.3 Cascade wiring (SCL)

// OB30 - 100 ms cycle
// Master PID call
"iMaster_PID"(
    Setpoint       := "SP_material_real",
    Input          := "PV_material_real",
    Input_PER      := 0,
    ManualEnable   := FALSE,
    ManualValue    := 0.0,
    ErrorAck       := FALSE);

// Scale master output (0-100%) to slave jacket setpoint range
// 0% -> 20 deg C jacket, 100% -> 80 deg C jacket
"SP_jacket_scaled" := 20.0 + ("iMaster_PID".Output / 100.0) * 60.0;

// Apply master output limits (clamps slave SP to nominal +/- 20%)
IF "SP_jacket_scaled" > 80.0 THEN
    "SP_jacket_scaled" := 80.0;
ELSIF "SP_jacket_scaled" < 20.0 THEN
    "SP_jacket_scaled" := 20.0;
END_IF;

// Slave PID call
"iSlave_PID"(
    Setpoint       := "SP_jacket_scaled",
    Input          := "PV_jacket_real",
    Input_PER      := 0,
    ManualEnable   := FALSE,
    ManualValue    := 0.0,
    ErrorAck       := FALSE);

// Output to split-range block (see Section 6)
"Valve_cmd" := "iSlave_PID".Output;

5.4 Variable declarations

VAR
    SP_material_real   : REAL;   // operator entry, deg C
    SP_jacket_real     : REAL;   // slave setpoint, deg C
    SP_jacket_scaled   : REAL;   // scaled master output, deg C
    PV_material_real   : REAL;   // master PV, deg C
    PV_jacket_real     : REAL;   // slave PV, deg C
    Valve_cmd          : REAL;   // slave output 0-100%
    Valve_cold_water   : REAL;   // 0-100% cold water valve
    Valve_steam        : REAL;   // 0-100% steam valve
    iMaster_PID        : PID_Compact;   // multi-instance DB
    iSlave_PID         : PID_Compact;   // multi-instance DB
END_VAR

6. Split-Range Valve Handling

For a reactor with cold-water (0–50%) and steam (50–100%) valves, branch the slave output to two actuator signals:

// 0% controller output  -> 100% cold water
// 50% controller output -> both closed
// 100% controller output -> 100% steam
IF "Valve_cmd" <= 50.0 THEN
    "Valve_cold_water" := 100.0 - 2.0 * "Valve_cmd";
    "Valve_steam"      := 0.0;
ELSE
    "Valve_cold_water" := 0.0;
    "Valve_steam"      := 2.0 * ("Valve_cmd" - 50.0);
END_IF;

// Deadband around 50% to prevent valve overlap (steam-water hammering)
IF "Valve_cmd" > 49.5 AND "Valve_cmd" < 50.5 THEN
    "Valve_cold_water" := 0.0;
    "Valve_steam"      := 0.0;
END_IF;

For electrically actuated valves requiring pulse-width outputs, see 3-Point Stepper Control with SIMATIC S7-1500 and Valve Control with the ET 200S 2 PULSE module.

7. Tuning Methodology

Apply the standard cascade tuning sequence:

  1. Tune the slave first with the master in manual. Force master output to a fixed 50%, then run PID_Compact pretuning on the slave. Verify rise time, overshoot, and settling. A step response of < 60 s settling and < 5% overshoot is a workable slave.
  2. Switch slave to auto and freeze its setpoint at the 50% equivalent. Put the master in manual at the same fixed output. Perform a step test on the master PV by changing the manual output in 10% increments. Record dead time and dominant time constant.
  3. Run master pretuning with the slave in auto. PID_Compact will inject a step automatically.
  4. Start with low Kp and high Ti on the master. Per the reference discussion: "start with a very low proportional gain (Kp) and high reset time (Ti) then go slowly from there. That way your system won't become unstable."
  5. Verify with a closed-loop SP step on the master (e.g., 60 deg C -> 65 deg C). The material temperature should reach SP without overshoot exceeding 2 deg C.
Loop Start Kp Start Ti (s) Start Td (s) Sample time (s)
Slave (jacket) 0.5 60 0 0.1
Master (material) 0.1 300 0 1.0

Master Kp is typically 0.1–0.3× slave Kp. If the master is too aggressive, the slave setpoint will oscillate, the slave cannot keep up, and the material temperature will swing with growing amplitude.

8. Output Limits and Anti-Windup

Both PID_Compact V2 and PID_Temp implement anti-windup that freezes the integrator when the output is clamped. Configure the master output limits tightly:

// Master loop output limits: slave SP clamped to nominal +/- 20%
// Nominal jacket SP = 50 deg C, limits 40..60 deg C
"iMaster_PID".Retain.CtrlParams.LMN_LLM := 40.0;
"iMaster_PID".Retain.CtrlParams.LMN_HLM := 60.0;

// Slave loop output limits: full 0-100% valve range
"iSlave_PID".Retain.CtrlParams.LMN_LLM := 0.0;
"iSlave_PID".Retain.CtrlParams.LMN_HLM := 100.0;

When the master saturates, the integrator stops accumulating. This forces the master to slow down when the inner loop is at its limit, giving it time to catch up. This is the single most important stability lever in cascade control.

9. Common Failure Modes and Error Codes

Symptom Likely cause Fix
Material temperature oscillates with growing amplitude Master Kp too high, slave too slow Reduce master Kp by 50%, increase Ti
Slave setpoint swings wildly between min and max Master output limits not configured Apply LMN_LLM / LMN_HLM on master
Steam valve never closes when material reaches SP Ti too large, no derivative on master Reduce master Ti, switch to PID_Temp
Both valves open > 0% around 50% output Deadband missing Add 49.5–50.5% deadband
Output saturated long, then overshoots Integral windup Verify anti-windup, reduce Ti
Pretuning fails with error 0800H Process too slow or noisy Set sample time >= dead time, filter input
System stable in simulation, unstable in plant Valve hysteresis, dead zone, I/P drift Add positioner feedback to slave PV

PID_Compact error codes

Hex Meaning
0000 No error
0001 Input out of range
0800H Pretuning error: process variable not settling, no inflection point detected
0801H Pretuning aborted: setpoint changed during tuning
0802H Pretuning error: output limits reached before inflection
8001H Invalid setpoint scaling
8011H Invalid input configuration

See the full error-code list in the PID_Compact V2 manual.

10. Verification and Commissioning

  1. Slave auto, master manual: Step master manual value from 40% to 60%. Slave should track within 1–2 cycles. Jacket temperature should settle in < 60 s.
  2. Both auto: Step material SP from 50 deg C to 60 deg C. Material temperature should reach SP without overshoot > 2 deg C.
  3. Disturbance test: Inject a 5 deg C step on the cold-water inlet temperature. Slave should reject it; master PV should see only a small blip.
  4. Valve test: Verify both valves go to 0% inside the 49.5–50.5% deadband, and stroke linearly in both directions outside it.
  5. Fail-safe test: Open the safety circuit; both valves should fail to a defined position. For exothermic reactions, this is cold water = 100%, steam = 0%.

11. Jacketed Reactor Field Example

For the exothermic reactor described in the field report, the field-proven configuration is:

  • Master PV: material temperature (thermocouple in product).
  • Slave PV: jacket-outlet temperature (RTD in jacket).
  • Master SP: 60–80 deg C depending on reaction phase.
  • Master output: clamped to 30–70 deg C jacket setpoint (±20% around 50 deg C nominal).
  • Slave tuning: aggressive enough to reject the exotherm (10–30% of full scale per minute of heat generation).
  • Steam valve deadband at 50% prevents water hammer and steam condensation in the jacket.

If the symptom reported in the source occurs — "if the temperature is reached at that time it will not close my steam valve fast so graph of temperature continues to have an AC curve" — this indicates the master Ti is too high. Reduce master Ti from 300 s to 60–120 s, and verify the slave can keep up. If the slave cannot, increase slave sample rate or add derivative action (Mode 2 on PID_Compact V2).

12. HMI Integration

PID_Compact V2 includes a built-in commissioning faceplate for WinCC Comfort/Advanced. Add it from the HMI library and connect to the two PID DBs.

  • Path: Project tree -> HMI -> Add new device -> WinCC RT Advanced -> drag the PID faceplate onto a screen.
  • Connect Setpoint, Input, Output, and the ManualEnable / ManualValue tags from iMaster_PID and iSlave_PID.
  • Enable trend recording for Setpoint, Input, Output at 500 ms sample time.

For SCL-based HMI blocks, see Example Blocks for WinCC (TIA Portal) and STEP 7 (TIA Portal) and Example blocks for WinCC V7 and STEP 7 (TIA Portal).

Safety note: For exothermic reactions, always configure the safety PLC to force both valves to the safe position (cold water 100%, steam 0%) on any field-device fault, sensor break, or CPU stop. Cascade control is a regulatory loop, not a safety function.

FAQ

Why does my cascade become unstable on a real plant when it works in simulation?

Simulation uses ideal linear models, but real plants have valve hysteresis, dead zones, I/P drift, and sensor noise. Tune the slave first with the master in manual, apply ±20% output limits on the master, and keep master Kp at 0.1–0.3× slave Kp. Add a positioner feedback signal to the slave PV if valve hysteresis dominates.

Should I use PID_Compact V2 or PID_Temp for a jacketed reactor cascade?

On S7-1500, prefer PID_Temp — it has native multi-loop cascade support, built-in heating/cooling output, and tuning in manual mode. On S7-1200, use PID_Compact V2 with the cascade wired in SCL between the two instances as shown in Section 5.

What does PID_Compact error code 0800H mean during pretuning?

Error 0800H means the pretuning routine could not detect a process inflection point. Increase the output step magnitude, lengthen the cycle time to at least the process dead time, or filter the input signal. Also check that the process is not stuck against an output limit before the inflection occurs.

How do I handle split-range valves (cold water 0–50%, steam 50–100%) in the slave output?

Branch on the slave output: 0–50% maps to cold water (100%–0%), 50–100% maps to steam (0%–100%). Add a 0.5% deadband around 50% to prevent both valves being open simultaneously, which would cause steam-water hammering and jacket thermal shock.

How tight should the master output limits be in a cascade?

Industry practice is ±20% of the nominal operating point. Tighter limits (e.g., ±10%) make the loop more stable but slower to large disturbances; looser limits (±30%+) speed up response but risk master saturation and windup during large setpoint changes or cold-start conditions.

Back to blog