Overview: S7-1500 PID Control for Pressure and Mass Flow
The SIMATIC S7-1500 controller family executes closed-loop control loops natively in the PLC, with no dedicated controller module required. A typical process plant cell uses a PLC to read a 4-20 mA pressure or mass-flow transmitter, compute a setpoint error against a target, and drive a control valve, variable-speed pump, or PID-controlled heating element. On the S7-1500, three PID instruction families are available inside TIA Portal: CONT_C, PID_Compact, and PID_3Step. The selection depends entirely on the actuator type (continuous valve vs. motorized valve with two direction signals vs. process with no final-control element) and on whether the engineering team wants an automatic tuning wizard.
This reference walks through implementing continuous-input, continuous-output PID control on a S7-1500 with the CONT_C technology object, the block that maps most cleanly to the legacy FB41 "CONT_C" used on S7-300/S7-400. The same engineering pattern applies whether the controlled variable is pressure (bar/psi), mass flow (kg/h, kg/s), temperature, level, or analytical measurement (pH, conductivity).
Prerequisites
Before adding any PID block, confirm the engineering environment, PLC firmware, and I/O hardware are aligned with the project requirements.
| Item | Requirement | Notes |
|---|---|---|
| TIA Portal | V13 SP1 Update 9 or later (V15, V16, V17, V18, V19, or V20 recommended) | The CONT_C instruction is available in every TIA Portal version that supports S7-1500; later versions add commissioning dialogs. |
| S7-1500 CPU firmware | V2.0 or later for full CONT_C features; V2.5+ recommended | Firmware is updated via TIA Portal > Online > Accessible devices. |
| Analog input module | SM 531 (e.g., 6ES7531-7KF00-0AB0) or analog input on CPU | 4-20 mA or 0-10 V input channels; configure channel type in device configuration. |
| Analog output module | SM 532 (e.g., 6ES7532-5HF00-0AB0) or analog output on CPU | 4-20 mA or 0-10 V output to valve positioner or drive reference. |
| Sensor | Pressure transmitter 4-20 mA (e.g., SITRANS P, Rosemount 3051) or mass-flow meter (e.g., SITRANS FC MASS 2100) | Loop-powered or 4-wire depending on PLC I/O type. |
| Actuator | Continuous-control valve with 4-20 mA positioner, or VFD with analog speed reference | Requires analog output. |
| Project structure | Configured S7-1500 station, PROFINET topology compiled without errors | Compile hardware must be error-free before cyclic OB scheduling. |
PID Block Selection: CONT_C vs. PID_Compact vs. PID_3Step
Each Siemens PID instruction targets a specific actuator class. Choose the block that matches the field device, not the one with the most features.
| Criterion | CONT_C | PID_Compact | PID_3Step |
|---|---|---|---|
| Input signal | Continuous (analog) | Continuous (analog) | Continuous (analog) |
| Output signal | Continuous (analog, e.g., 0-100 %) | Continuous (analog, 0-100 %) | Two binary signals (open / close pulses) |
| Typical actuator | Modulating control valve, VFD speed reference | Modulating control valve, VFD speed reference | Motorized valve, damper actuator with position feedback |
| Auto-tuning | Not built-in (manual tuning required) | Built-in tuning wizard (pretuning + fine tuning) | Built-in tuning for motor travel time |
| Anti-windup | Integrator holding via INT_HOLD
|
Automatic in standard mode | Travel-time-based pulse limiting |
| Best for | Engineers familiar with classic FB41 migration | New projects, fast commissioning | Integrating actuators with end-position feedback |
| When to avoid | If a built-in autotuner is required | If you need full manual control of every static bit | If actuator requires true analog signal |
CONT_C and PID_Compact are valid. CONT_C maps 1:1 to the legacy FB41 used on S7-300/S7-400 and is the easier starting point if you are migrating an existing project or carrying over logic from classic STEP 7. PID_Compact is recommended for greenfield projects because its integrated tuning wizard shortens commissioning time. PID_3Step is wrong for this application; it is reserved for motorized valves with discrete open/close commands.Adding CONT_C to the S7-1500 Project
The CONT_C instruction is added from the "Instructions" task card under Technology > PID Control > Compact PID in TIA Portal V15 and later, or under Optional Packages > PID Control in V13/V14. The block is dragged into a code block (OB, FB, or FC) and an instance data block (DB) is created automatically when the block is dropped.
- Open the project in TIA Portal and expand the S7-1500 station in the project tree.
- Open the Program blocks folder and double-click the cyclic OB that should host the PID (typically OB1 or OB35 for a 100 ms cycle).
- Drag
CONT_Cfrom the Instructions task card into a network inside the OB. - When prompted, accept the default instance DB name (e.g.,
CONT_C_DB) or assign a project-specific name. The DB holds the static parameters of the PID. - Compile the program. The instruction appears with the inputs/outputs listed below.
Per Siemens documentation, CONT_C on S7-1500 has the same signal-processing flow as on S7-300/S7-400 but executes on the optimized S7-1500 runtime with shorter cycle jitter. The TIA Portal V21 cloud documentation describes the technology object structure in Technology object CONT_C (S7-300, S7-400, S7-1500) - PID.
Static vs. Dynamic Parameters
Splitting the parameter set into static and dynamic categories is the cleanest mental model for commissioning. Static parameters are set once during design and rarely changed; dynamic parameters are adjusted online during tuning, mode switching, or restart.
Static Parameters (configure once)
| Input | Type | Purpose | Typical Value |
|---|---|---|---|
COM_RST |
BOOL | Complete restart of the PID algorithm (resets integrators, status) |
FALSE; pulse to TRUE from startup OB to reset on cold start |
MAN_ON |
BOOL | Manual mode enable |
FALSE for automatic; toggle from HMI to enter manual |
PVPER_ON |
BOOL | Process variable sourced from peripheral (analog input word) instead of PV_IN
|
TRUE when using PV_PER; FALSE when using scaled engineering value |
P_SEL |
BOOL | Enable proportional action | TRUE |
I_SEL |
BOOL | Enable integral action |
TRUE for self-regulating processes; FALSE for pure P-control during initial dry-run |
INT_HOLD |
BOOL | Freeze integrator output |
FALSE in normal operation; TRUE during setpoint changes to avoid integral kick |
I_ITL_ON |
BOOL | Initialize integrator with I_ITVAL
|
TRUE on restart; FALSE in run |
D_SEL |
BOOL | Enable derivative action |
FALSE for slow pressure/flow loops; TRUE only for fast temperature or flow loops with high noise immunity |
CYCLE |
TIME | Sampling time of the PID algorithm | 100 ms for pressure; 1 s for slow mass flow; must match the OB cycle that calls CONT_C
|
Dynamic Parameters (set online or via HMI)
| Input | Type | Purpose | Range / Units |
|---|---|---|---|
SP_INT |
REAL | Internal setpoint (engineering units) | 0.0 to 100.0 % of process-variable range, or scaled units (bar, kg/h) |
PV_IN |
REAL | Process variable (engineering units) when PVPER_ON=FALSE
|
Scaled to match transmitter range |
PV_PER |
WORD | Process variable from peripheral (raw ADC word) when PVPER_ON=TRUE
|
0-27648 for Siemens 4-20 mA (6ES7 standard) |
MAN |
REAL | Manual manipulated variable used when MAN_ON=TRUE
|
0.0 to 100.0 % |
GAIN |
REAL | Proportional gain (unitless) | 0.1 to 10.0 typical; tune to step response |
TI |
TIME | Integral time (reset time) | 0 ms disables I-action; 1 s to 600 s typical |
TD |
TIME | Derivative time | 0 ms disables D-action; rarely used for pressure |
DEADB_W |
REAL | Deadband width on the error | 0.0 to disable; 0.5 % typical for noisy pressure |
LMN_HLM / LMN_LLM
|
REAL | Manipulated variable high/low limits | 0.0 / 100.0 default; tighten to protect actuator |
PV_FAC / PV_OFF
|
REAL | Linear scaling: PV = PV_PER × FAC + OFF |
FAC = (range_max - range_min) / 27648; OFF = range_min
|
CYCLE time must equal the OB cycle time that calls CONT_C. Mismatching these two values introduces aliasing in the derivative action and can produce unstable behavior. If you place the call in OB35 (100 ms cyclic interrupt), set CYCLE := T#100ms.Wiring CONT_C in Structured Text (SCL) or Ladder
The example below shows a typical SCL call with a 4-20 mA pressure transmitter on channel 0 of an SM 531 (IW address) and a 4-20 mA proportional valve on channel 0 of an SM 532 (QW address). The process variable is scaled to engineering units (bar) inside the program so the operator can see the pressure in bar on the HMI.
// Pressure transmitter: 0-10 bar mapped to 4-20 mA
// SM 531 input word IW 0 -> raw 0-27648
// SM 532 output word QW 0 -> raw 0-27648 for 0-100% valve position
"i_PV_Raw" := "DB_AI".IW0; // PIW 0 from SM 531
"PV_PER" := "i_PV_Raw"; // pass raw to CONT_C
"PVPER_ON" := TRUE; // use peripheral PV
"SP_INT" := "i_Setpoint_Bar"; // operator setpoint in bar
"GAIN" := 1.2; // tuned value
"TI" := T#5s; // tuned value
"TD" := T#0ms; // D off for pressure
"MAN_ON" := "b_ManualMode"; // HMI toggle
"MAN" := "r_ManualMV"; // operator manual MV %
"LMN_HLM" := 100.0; // MV high limit (%)
"LMN_LLM" := 0.0; // MV low limit (%)
CONT_C( // instance DB = CONT_C_DB
PV_PER := "PV_PER",
PVPER_ON := "PVPER_ON",
SP_INT := "SP_INT",
MAN := "MAN",
MAN_ON := "MAN_ON",
COM_RST := "b_FirstRun",
CYCLE := T#100ms,
GAIN := "GAIN",
TI := "TI",
TD := "TD",
DEADB_W := 0.0,
LMN_HLM := "LMN_HLM",
LMN_LLM := "LMN_LLM",
PV_FAC := 0.000361, // 10 bar / 27648
PV_OFF := 0.0,
LMN => "r_Output_Percent",
LMN_PER => "qw_OutputRaw"
);
// Optional: output the analog signal to the valve
"DB_AO".QW0 := "LMN_PER"; // scaled raw word to SM 532
The LMN_PER output is a peripheral-compatible WORD (0-27648) that maps directly to the analog output module. Use LMN when you want a REAL percentage for HMI display or for further scaling inside the PLC.
Cyclic OB and Call Frequency
The CONT_C algorithm assumes it is called at a fixed interval. The two practical options are:
-
OB1 (cyclic, ~10 ms typical scan time): Acceptable for fast pressure loops with proportional valve. The
CYCLEparameter must match the actual average OB1 cycle, but a small mismatch is tolerable if the loop is slow. - OB35 (100 ms cyclic interrupt, configurable 1 ms-1 min): Recommended for repeatable loop timing. The OB priority is higher than OB1, so the PID executes on a fixed schedule regardless of the main program scan.
For a typical industrial pressure regulator (loop time constant 2-10 s) or mass-flow regulator (loop time constant 1-5 s), a 100 ms cycle is the right choice. Set OB35 phase offset to distribute the load across the 100 ms window when the project has multiple PID loops.
Step-by-Step: Commissioning the Pressure Regulator
- Wire the field devices. Connect the 4-20 mA pressure transmitter to the SM 531 channel; connect the 4-20 mA valve positioner to the SM 532 channel. Verify polarity; a reversed loop will give a saturated negative reading on first power-up.
- Configure analog channels. In the device view of the SM 531 and SM 532, set the channel measurement type (4-wire current, 0-20 mA or 4-20 mA) and the diagnostics behavior. Compile hardware.
-
Go online and read the raw input. Open a watch table on
PIW 0and verify the count moves from ~5534 (4 mA = 0 bar) to 27648 (20 mA = full scale) as you stroke the transmitter. -
Add CONT_C and call it from OB35. Configure the instance DB with the static parameters from the table above. Set
GAIN = 1.0,TI = T#0ms(I-action disabled for initial dry-run),TD = T#0ms(D disabled). SetLMN_HLM = 100,LMN_LLM = 0. -
Place the loop in manual mode (
MAN_ON = TRUE). Use the HMI or watch table to setMAN = 50.0(50 % valve). Verify the valve actually moves and the process variable responds. If the PV does not change, the valve is wired backward or the scaling is inverted. -
Switch to automatic (
MAN_ON = FALSE) withSP_INTequal to the current PV. The MV should hold steady. This confirms the bumpless-transfer logic is functioning. -
Step the setpoint by 5-10 % of range. Observe the PV response. Tune
GAINupward until you see 2-3 small oscillations, then back off by 30 %. -
Enable integral action (
I_SEL = TRUE). Start with a longTI(e.g., 30 s) and reduce it until the loop eliminates the steady-state error in 3-5 loop time constants. -
Add derivative action only if required. Pressure loops rarely need D-action. Mass-flow loops with fast noise sometimes benefit from
TD= 0.5-2 s with a low-pass filter.
Tuning Methods
| Method | Procedure | When to Use | Resulting Parameters |
|---|---|---|---|
| Ziegler-Nichols (closed-loop, ultimate gain) | Set TI = T#0ms, TD = T#0ms. Increase GAIN until loop oscillates at constant amplitude. Note Ku (ultimate gain) and Tu (oscillation period). |
Allowed offline; safe processes | GAIN = 0.6 × Ku, TI = 0.5 × Tu, TD = 0.125 × Tu (PID form) |
| Step-response (open-loop) | Place loop in manual, step MAN by 5-10 %, record the PV curve. Measure process gain Kp, dead time Td, time constant τ. |
Open-loop stable processes with low noise | GAIN = τ / (Kp × Td), TI = 2 × Td (Lambda tuning variant) |
| Lambda tuning | Same data as step-response, but with a damping factor λ > Td. | Conservative tuning for noisy industrial loops | GAIN = τ / (Kp × (λ + Td)), TI = τ |
| Built-in autotuner (PID_Compact only) | Start the pretuning wizard from the commissioning editor. | Use PID_Compact for this; not available in CONT_C
|
Calculated by the wizard |
The transfer-function basis for the P, I, and D branches inside CONT_C is:
y(t) = GAIN * ( e(t) + (1/TI) * integral(0..t, e(tau) dtau) + TD * de(t)/dt )
where e(t) = SP - PV (with sign convention per MAN_ON / SP_INT)
Anti-windup is handled by clamping the integrator at the LMN_HLM / LMN_LLM output limits. The INT_HOLD input freezes the integrator when the manipulated variable is saturated, preventing overshoot on the first recovery after a long saturation event.
Mass-Flow Specific Configuration
For a mass-flow regulator (e.g., SITRANS FC MASS 2100 on a pump discharge line) the engineering approach is identical to pressure, but the time constants and noise profile differ:
-
Sensor noise: Coriolis flowmeters produce high-frequency density/temperature noise. Enable a deadband (
DEADB_W = 0.5% of range) or apply a first-order low-pass filter on the input before scaling. - Loop time constant: Typically 0.5-3 s for liquid mass flow; sample at 50-100 ms.
-
Square-root compensation: For differential-pressure flowmeters, take the square root of the DP value before presenting it as PV. Do this in the scaling FB, not in
CONT_C. - Derivative action: Avoid for noisy mass-flow signals; the derivative amplifies noise. Use a low-pass filter on the PV or stick to PI control.
Safety, Limits, and Restart Behavior
-
Output limits: Always set
LMN_HLMandLMN_LLMto protect the actuator. A typical 4-20 mA control valve is happy between 0 % and 100 %; a VFD speed reference is usually limited to 10-90 % to avoid motor stall and overspeed. -
Restart behavior: Pulse
COM_RSTfrom the startup OB (OB100) to reset integrators and the mode state. Without this, a warm restart may leave the PID in an undefined mode. -
Fault response: If the analog input reports wire-break or overflow, the PV goes to a saturated value. The PID will drive the MV to a limit and stay there. Add a watchdog in the user program: if the input quality code is bad, force
MAN_ON = TRUEand hold the MV at the last good value. -
Bumpless transfer: When toggling
MAN_ON, the integrator is preloaded with the current manual value, so the automatic output starts from the same point. This prevents a process bump on every mode change.
Verification Checklist
After commissioning, run through this checklist before handing the loop to operations:
- Confirm
CYCLEin the instance DB equals the OB cycle time that callsCONT_C. - Confirm
PV_PERtracksPIWof the analog input with the correct sign and range. - Verify that stroking the manual MV produces a monotonic PV response. If the PV moves the wrong direction, invert the sign in scaling (
PV_FAC = -PV_FAC) or check field wiring. - Verify bumpless transfer by switching from manual to automatic at several setpoints; the MV should not jump.
- Step the setpoint by 10 % of range; record overshoot, settling time, and steady-state error. Compare against the design basis (typical pressure loop target: < 5 % overshoot, < 3 loop time constants to settle).
- Confirm anti-windup: drive the MV to 100 % by setting an out-of-range setpoint, then return the setpoint to the operating point. The PV should approach the setpoint smoothly, not overshoot by more than 10 %.
- Cycle power to the PLC and confirm the loop restarts in a safe state (typically manual mode with MV = 0 or last good value).
Troubleshooting Matrix
| Symptom | Likely Cause | Action |
|---|---|---|
| MV stays at 0 % | PV_PER = 0, transmitter not wired | Check analog-input channel in online diagnostics; verify mA loop with multimeter |
| MV sits at 100 % | PV saturated or SP > PV with inverted scaling | Inspect PIW value; if 27648, check transmitter; check PV_FAC sign |
| Loop oscillates continuously | GAIN too high, CYCLE too short, or derivative enabled | Halve GAIN, double CYCLE, disable D_SEL |
| Slow drift from setpoint | Integral action disabled or TI too long | Set I_SEL = TRUE, reduce TI by half until slight oscillation, then increase by 30 % |
| Large overshoot on setpoint step | Integrator windup during saturation | Set INT_HOLD = TRUE during large setpoint changes, or use PID_Compact with built-in anti-windup |
| MV jumps when toggling MAN_ON | Bumpless-transfer preload not active; integrator not initialized | Verify the integrator is initialized from MAN on the rising edge of MAN_ON; consult the FB block diagram in the S7-1500 PID manual |
| Noisy valve motion | PV noise amplified by D-action or insufficient deadband | Disable D_SEL, increase DEADB_W, add input low-pass filter |
Migrating CONT_C from S7-300/S7-400 to S7-1500
Existing STEP 7 V5.x projects that use FB41 CONT_C migrate to the S7-1500 platform by re-instantiating the same instruction in TIA Portal. The parameter list is functionally identical; the only mechanical changes are:
- The instance DB is automatically optimized for S7-1500 symbolic access; legacy absolute addressing patterns must be replaced with symbolic tag names.
- The cycle-time input
CYCLEmust be set in IEC time format (e.g.,T#100ms) and must match the OB that calls the block. - The
PV_PERinput is a peripheral WORD. With the S7-1500 analog I/O, this maps directly to the process-image input word (PIW). - Compile the migrated program with "Software (all)" to surface any symbolic-access issues before going online.
When to Switch from CONT_C to PID_Compact
Stay on CONT_C for the duration of any project where the team is more comfortable with the legacy interface, where the tuning is done manually from the HMI/watch table, or where the application must remain source-compatible with an existing S7-300/S7-400 fleet. Switch to PID_Compact when the project is greenfield, when the operator population is unfamiliar with manual PID tuning, or when the loop dynamics are difficult to characterize offline and the autotuner will shorten commissioning. The two blocks coexist in the same CPU; you can run one pressure loop on CONT_C and one flow loop on PID_Compact in the same project without conflict.
Frequently Asked Questions
Should I use CONT_C or PID_Compact for an S7-1500 pressure regulator?
For a new project, PID_Compact is recommended because it includes a built-in pretuning and fine-tuning wizard that reduces commissioning time. Use CONT_C if you are migrating from S7-300/S7-400 code that used FB41, or if you need explicit, manual control of every static parameter (P_SEL, I_SEL, PVPER_ON, etc.) without the autotuner interference.
What cycle time (CYCLE) should I set for a pressure loop?
Use 100 ms for typical industrial pressure regulators (loop time constant 2-10 s). Place the call in OB35 (100 ms cyclic interrupt) and set CYCLE := T#100ms in the instance DB. Mismatching the cycle parameter with the actual OB cycle produces unstable derivative action and erratic control.
How do I switch between manual and automatic mode without bumping the process?
Toggle MAN_ON from the HMI. The CONT_C block performs bumpless transfer: when MAN_ON rises, the integrator is preloaded with the current manual value (MAN), so the automatic output starts from the same operating point. Verify the transition by stepping the setpoint in automatic immediately after switching from manual.
Why does my loop oscillate continuously after the first tuning attempt?
Three common causes: (1) GAIN is too high, halve it and retry; (2) CYCLE is shorter than the OB cycle, so the integrator accumulates too aggressively, set both to the same value; (3) derivative action is enabled (D_SEL = TRUE) on a noisy process, set it to FALSE and apply a low-pass filter to the input instead.
Can I test the PID without real field devices connected?
Yes. Use the TIA Portal PLCSIM (S7-PLCSIM or S7-PLCSIM Advanced) to simulate the S7-1500 CPU. For the analog input, write a known scaled value to PV_IN with PVPER_ON = FALSE from a watch table. For the analog output, monitor LMN_PER or LMN online. The PID math executes identically in simulation; only the physical I/O is absent. Always validate the closed-loop response with a process model or surrogate load before connecting real plant.