Overview: PID_Compact Architecture and the Dual-Process-Variable Question
The SIMATIC S7-1200 PID_Compact technology object is, by design, a Single-Input Single-Output (SISO) controller: one feedback variable (Input_PER / Input) is compared against one setpoint (Setpoint) to produce one manipulated variable (Output, Output_PER, or Output_PWM). It is not possible to bind two physical process variables (PV1, PV2) to the same PID_Compact instance and have the controller resolve both errors simultaneously against a shared output. This is a hard architectural boundary of the instruction, not a configuration limitation.
Engineers who need to regulate two interacting variables (temperature + pressure, level + flow, position + velocity) must choose between three Siemens-supported paths:
- Multi-instance approach — call PID_Compact twice (or more), one loop per PV. This is the canonical solution and is fully supported in TIA Portal V16 through V21 on S7-1200, S7-1200 G2, and S7-1500 CPUs.
- True MIMO control — requires the Model Predictive Control (MPC) library blocks from the PCS 7 / Advanced Process Control environment, which are not distributed on S7-1200 firmware.
- PD-mode switching workaround — disable the integral action (I << Ti) and re-bind the process variable / setpoint pair at runtime. The controller behaves as a fast PD when one variable dominates and as a slow PD with negligible I when the secondary variable takes over. This is a field-proven pattern for slow, large-inertia processes (tank farms, climate chambers, multi-zone furnaces) and is described in detail below.
This reference documents each path, the underlying technology object parameters exposed in TIA Portal, the Ladder/Structured Text glue logic required for the PD-swap pattern, and the verification procedure that confirms a stable dual-PV control loop. The scope covers PID_Compact V2.x as documented in the SIMATIC S7-1200 / S7-1500 PID Control Function Manual and the TIA Portal V21 online help.
Prerequisites
| Item | Requirement | Notes |
|---|---|---|
| CPU firmware | S7-1200 V4.2 or later (recommended V4.5+) | PID_Compact V2.1 requires firmware ≥ 4.2 |
| CPU firmware | S7-1200 G2 V1.0 or later | G2 inherits PID_Compact technology object |
| TIA Portal | V16 SP1 minimum (V17/V18/V19/V20/V21 supported) | Technology object schema differs across versions |
| Required support package | "PID_Compact V2" or "PID Control V2" | Installed via TIA Portal Options > Support Packages |
| I/O | Two analog inputs (4–20 mA / 0–10 V / RTD / TC) or one AI + one scaled peripheral value | Resolution ≥ 12 bit recommended |
| Output hardware | One analog output (continuous) or one digital output (PWM) | PWM period 0.1–100 s configurable |
| Cycle time | OB1 ≤ 100 ms, ideally 10–50 ms | Faster than PV dynamics |
| Documentation | SIMATIC S7-1200, S7-1500 PID Control Function Manual | Authoritative reference |
| Online help | Technology object PID_Compact (TIA V21) | Cloud-based manual |
PID_Compact Technology Object: Parameter Map
The PID_Compact block is a self-contained technology object. Every input/output that the user binds is in fact a configuration parameter of a DB that the wizard generates under Technology objects > PID_Compact_x > Configuration > Basic settings / Process value settings / Output settings / Advanced settings. The list below covers the parameters that matter when adapting the controller to a dual-PV or PD-swap architecture.
| Parameter | Direction | Data type | Default | Engineering meaning |
|---|---|---|---|---|
| Setpoint | IN | REAL | 0.0 | Reference value in physical units (after scaling) |
| Input | IN | REAL | 0.0 | Scaled process value in physical units |
| Input_PER | IN | INT | 0 | Raw peripheral value from AI; auto-scaled by configuration |
| ManualEnable | IN | BOOL | FALSE | Force manual mode; Output tracks ManualValue |
| ManualValue | IN | REAL | 0.0 | Manual output value [%] |
| Retain.CtrlParams.Gain | Retain | REAL | 1.0 | Proportional gain Kp |
| Retain.CtrlParams.Ti | Retain | REAL | 20 000 ms | Integral (reset) time; Ti = 0 disables I-term |
| Retain.CtrlParams.Td | Retain | REAL | 0.0 ms | Derivative time; Td = 0 disables D-term |
| Config.InputScaling.UpperPointIn / UpperPointOut | Config | REAL | 27 600 / 100.0 | PV scaling end-point (raw → engineering units) |
| Config.InputScaling.LowerPointIn / LowerPointOut | Config | REAL | 0 / 0.0 | PV scaling start-point |
| Config.OutputScaling.UpperPointIn / UpperPointOut | Config | REAL | 100.0 / 27 600 | Output scaling (engineering % → raw AO) |
| Config.SetpointLimit.UpperLimit / LowerLimit | Config | REAL | +∞ / −∞ | SP clamp (anti-surge) |
| Config.OutputLimits.UpperLimit / LowerLimit | Config | REAL | 100.0 / 0.0 | MV clamp [%] |
| ActivateRecoverMode | Config | BOOL | TRUE | Restart tuning after CPU RUN→STOP→RUN |
| Warning.HeatWarning / Warning.CoolingWarning | OUT | REAL | — | Internal warnings, not user-set |
| Output | OUT | REAL | — | Scaled MV in % (continuous) |
| Output_PER | OUT | INT | — | Raw MV for analog output |
| Output_PWM | OUT | BOOL | — | Bit-pattern MV for DO / PWM actuator |
| SetpointLimit_H / SetpointLimit_L | OUT | BOOL | — | SP-out-of-range flags |
| InputWarning_H / InputWarning_L | OUT | BOOL | — | PV out of configured range flags |
Per the TIA Portal V21 help, the scaling pairs (LowerPointIn, LowerPointOut) and (UpperPointIn, UpperPointOut) are stored as the four corners of a linear interpolation. The peripheral value range LowerPointIn = 0, UpperPointIn = 27 600 matches the default Siemens AI scaling for 0–10 V or 4–20 mA on SM 1231 modules. For RTD/TC modules (SM 1231 RTD, SM 1231 TC) the upper-point is often 27 647 and the scaling must be re-entered manually.
Why Two Process Variables Cannot Share One PID_Compact Instance
The PID_Compact V2 algorithm computes the error as e = Setpoint − Input at every cycle. The technology object owns exactly one Input (REAL) and one Input_PER (INT) input pin. Attempting to feed a multiplexed value to Input from a user program is technically possible, but it changes the definition of the controlled variable every scan and corrupts the integrator (the I-term sums the previous error and would oscillate with the multiplexing). Three failure modes appear in practice:
- Integrator wind-up on swap — the moment the active PV swaps from PV1 to PV2, the previous error accumulator remains stored, and a step change in setpoint or PV drives the I-term to saturation.
- Derivative kick — every PV swap produces a discontinuity; the D-term amplifies it into an output spike that can damage actuators.
-
Loss of bumpless transfer — the anti-windup and "bumpless" features inside PID_Compact (activated through
ManualEnable↔ automatic transitions) only support one error stream.
For these reasons, the only fully supported Siemens path is to instantiate PID_Compact once per loop. The remaining sections explain how to wire two (or more) instances and how to implement the PD-mode swap trick that suppresses the I-term pathologies when the two PVs are mutually exclusive in time.
Workaround Path A — Multiple PID_Compact Instances (Canonical MIMO)
Block diagram
PV1 (AI0) ──► [SCALE] ──► Input_PER ──► [PID_Compact_1] ──► Output_PER ──► [AO0] (Valve 1) SP1 (HMI) ────────────────────────────────────► Setpoint PV2 (AI1) ──► [SCALE] ──► Input_PER ──► [PID_Compact_2] ──► Output_PER ──► [AO1] (Valve 2) SP2 (HMI) ────────────────────────────────────► Setpoint [Decoupling block — optional] ──► feed-forward between the two MVs
Implementation steps (TIA Portal V16+)
- Open the project tree, right-click Technology objects > Add new object > PID > PID_Compact V2.x. Create one DB per loop, e.g.
PID_Compact_FlowandPID_Compact_Pressure. - For each instance, open Configuration > Basic settings and choose Input_PER as the process value source, then bind the AI address (e.g.
%IW64for the first SM 1231 channel). - Configure the process value scaling. For a 4–20 mA pressure transmitter with range 0–10 bar, set:
LowerPointIn = 0,LowerPointOut = 0.0,
UpperPointIn = 27648,UpperPointOut = 10.0. - Configure the output scaling. For a 4–20 mA proportional valve driven by a 0–10 V SM 1232 AO, set:
OutputScaling.UpperPointIn = 100.0,UpperPointOut = 27648. - Bind the instance DB in OB1 (or a cyclic OB, e.g. OB35 with 100 ms):
CALL "PID_Compact_Flow" , "PID_Compact_Flow_DB"in a CFC-like network. - Wire the second instance the same way with its own AI and AO. The cycle time should be identical for both; mismatched cycle times cause a 0.5× to 2× tuning error because PID_Compact normalises Kp, Ti, Td to
CycleTime. - Run a pre-tune (
Mode = 3) and fine-tune (Mode = 4) on each loop separately. The function manual recommends running the loops sequentially to avoid cross-coupling influence on the identification. - If the loops interact (e.g. flow affects pressure), add a feed-forward term: multiply PV1 by a gain and add it to
Inputof PID_Compact_2 through a NORM_X / SCALE_X chain. This is the practical Siemens substitute for full MPC on an S7-1200.
Structured-text skeleton (SCL) for OB35
// OB35 — 100 ms cyclic, both PID loops executed in one cycle
IF "i_StartUpDone" THEN
// === Loop 1: Flow control ===
"PID_Compact_Flow".Setpoint := "dbHMI".SP_Flow;
"PID_Compact_Flow".Input_PER := "iFlow_Raw"; // %IW64 from SM 1231
"PID_Compact_Flow".ManualEnable := "bFlow_Manual";
"PID_Compact_Flow".ManualValue := "rFlow_ManVal";
"PID_Compact_Flow"();
"qFlow_AO_Raw" := "PID_Compact_Flow".Output_PER; // %QW64 to SM 1232
// === Loop 2: Pressure control with feed-forward ===
"dbPressure".rPV_Compensated :=
NORM_X(MIN := 0.0, MAX := 10.0, VALUE := "iPress_Raw")
- "dbPressure".rFF_Gain * ("dbFlow".rPV_Eng - "dbHMI".SP_Flow);
"PID_Compact_Pressure".Setpoint := "dbHMI".SP_Pressure;
"PID_Compact_Pressure".Input := "dbPressure".rPV_Compensated;
"PID_Compact_Pressure"();
"qPress_AO_Raw" := "PID_Compact_Pressure".Output_PER;
END_IF;
Workaround Path B — PD-Mode Swap Pattern (Single-Output Dual-PV)
This pattern is used when a process has two slow, mutually dominant variables that share a single actuator — for example, a large climate chamber where supply-air temperature governs the warm-up phase and return-air humidity governs the dwell phase. The engineer implements a single PID_Compact instance in PD mode (Ti set to a very large value) and a multiplexer that swaps the active PV/SP pair on a state-machine transition.
Why PD, not full PID
When the active PV/SP pair is swapped, the integrator's previous value is no longer meaningful. Setting Retain.CtrlParams.Ti = 4000 000.0 ms (effectively disabling I during the swap window) keeps the integrator contribution at the previous level. The controller behaves as a PD with a very small, bounded I. In a well-tuned PD controller with negligible Ti the contribution of the integral term is < 1 % of the total MV for any realistic error trajectory, so the swap artefact is hidden.
PD tuning rule (numerical)
Starting values for a thermal/mass process:
| Term | Initial value | Tuning direction |
|---|---|---|
| Kp (Gain) | 1 / (process gain × 2) | Increase until small overshoot (5–10 %) |
| Ti (Integral time) | 10 000 ms – 40 000 ms (negligible) | Keep large; never < 5 000 ms in swap mode |
| Td (Derivative time) | 0.2 × dead time | Reduce if MV is noisy |
| Cycle time | 100 ms | Match to OB35 period |
The example values reported in the field report — Kp = 100, Ti = 5 ms, Td = 500 ms — must be interpreted in the engineering-unit context. With a 0–100 °C process, Kp = 100 means that a 1 °C error demands a 100 % MV step. Such a gain is plausible only for very small dead-time processes (laboratory-scale heaters) and will saturate instantly on a 50 °C step. The rule of thumb above gives a more defensible start.
Ladder logic for PV/SP multiplexer
// Network 1 — select active PV
A "bState_Warmup" // 1 during warm-up, 0 during dwell
JCN NW2
L "iTemp_Raw" // %IW64 — supply-air temperature
T "PID_Compact".Input_PER
L "rSP_Temp" // °C
T "PID_Compact".Setpoint
JU NW3
NW2: L "iHumid_Raw" // %IW66 — return-air humidity
T "PID_Compact".Input_PER
L "rSP_Humid" // %RH
T "PID_Compact".Setpoint
NW3: NOP 0
Bumpless swap sequence
- Detect transition edge (e.g.
rPV_Warmup >= rSP_Temp - 1.0ANDoldState == Warmup). - Force
ManualEnable := TRUEandManualValue := current_Outputfor one cycle. - Switch the multiplexer (NW2) to the new PV/SP pair.
- On the next cycle, set
ManualEnable := FALSEto resume automatic mode. PID_Compact V2 will start fromManualValuewith a zeroed error integral — bumpless transfer.
Alternative: PID_Temp and PID_3Step for Heat/Cool Architectures
When the dual-variable system is actually a heat + cool split, the SIMATIC library provides PID_Temp (V2, S7-1200 / S7-1500) which natively supports two output structures: a heating output (analog or PWM) and a cooling output (analog or PWM) with anti-windup and split-range logic. PID_Temp is documented in the same function manual and is the correct technology object for two-position thermal loops with separate heating and cooling actuators.
| Technology object | Inputs | Outputs | Typical application | Note |
|---|---|---|---|---|
| PID_Compact | 1 PV (PER or REAL) | 1 MV (analog, PWM, or %) | Generic SISO | Default choice for S7-1200 |
| PID_3Step | 1 PV | 1 actuator with up/down commands | Motorised valves, dampers | Includes backlash compensation |
| PID_Temp | 1 PV (REAL) | 2 MVs (heat + cool) | Temperature chambers, extruders | Split-range and dead-band |
PID_Temp can also be reconfigured at runtime for two setpoint profiles — a useful feature when the second variable (e.g. cooling demand) is treated as a second setpoint. The TIA Portal V21 online help section "Using PID_Temp" walks through the configuration in the same project context as PID_Compact.
Tuning the Dual-PV Loop
- Pre-tune (Mode = 3) — PID_Compact applies a step perturbation to MV and observes the PV step response. The block computes Kp, Ti, Td using a relay-feedback method and writes the result to the retain parameters. Run this for each PID_Compact instance individually, with the other loop in manual.
- Fine-tune (Mode = 4) — apply a small setpoint step (5–10 % of full scale) and let the controller converge. Fine-tune writes refined Kp/Ti/Td to the retain area; the values persist across CPU restarts.
- Setpoint ramp — to protect the process, enable the setpoint ramp (Config.SetpointLimit + SetpointRiseTime). For the PD-swap pattern, set the rise time equal to the PV dead time so that the I-term is naturally small.
- Disturbance rejection test — apply a 10 % load step on the actuator and record the integrated absolute error (IAE) of both PVs. A well-tuned dual-loop system has IAE < 5 %·s for each PV over 60 s.
- Bumpless transfer verification — toggle ManualEnable ten times, log the MV. The peak-to-peak MV deviation during a manual↔auto transition must be < 2 %.
Verification Procedure
- Open the technology object in TIA Portal, switch to Commissioning > Online and confirm
Retain.CtrlParams.Gain,Ti,Tdhave non-zero, non-default values. - In the watch table, force
Input_PER = 0and confirmOutput = Config.OutputLimits.LowerLimitafter 2 s. - Force
Input_PER = 27648(full scale) and confirmOutput = Config.OutputLimits.UpperLimitafter 2 s. - For the swap pattern, log PV1, PV2, MV, and
ManualEnablewith the trace recorder (TIA Portal V18+). Confirm the MV remains inside ±3 % during the swap. - Read the diagnostic buffer of the PID_Compact DB. The
ErrorWordbits must all be 0. The most common error is0x0001(configuration incomplete) and0x0080(process value out of range). - Power-cycle the CPU and confirm
ActivateRecoverMode = TRUErestores the loop to the last automatic state without a manual reset.
Troubleshooting Matrix
| Symptom | Likely cause | Diagnostic | Remediation |
|---|---|---|---|
| MV saturates at 0 or 100 % immediately | PV scaling reversed (UpperPointIn < LowerPointIn) | Watch table: Input vs Input_PER | Swap scaling points; check transmitter wiring polarity |
| Large MV spike on PV swap | D-term reacts to discontinuity | Trace Input and Output; D-term gain too high | Reduce Td, increase D-filter constant; add a low-pass on Input |
| Slow drift after CPU restart | ActivateRecoverMode = FALSE | Inspect technology object configuration | Set ActivateRecoverMode = TRUE and download |
| Output jumps 100 % on ManualEnable ↔ Auto | ManualValue not loaded from current Output | Watch ManualValue vs Output | Capture Output into ManualValue on the rising edge of ManualEnable |
| Pre-tune does not converge | PV too noisy, or dead time > 5 × CycleTime | Trace Input over 60 s | Increase CycleTime to 250 ms, apply Input filter (Config.InputFiltering.TimeConstant ≥ 0.5 s) |
| ErrorWord = 16#8001 | Invalid Gain (e.g. negative) | Read Retain.CtrlParams | Re-run fine-tune; Kp must be > 0 |
| ErrorWord = 16#0004 | Setpoint outside configured range | Read SetpointLimit_H/L | Expand Config.SetpointLimit.* or clamp SP in user code |
| Output_PER clipped to AO module range | AO configured for ±10 V but OutputScaling set for 4–20 mA | Compare AO configuration vs OutputScaling | Adjust OutputScaling.UpperPointIn/Out to match AO type |
Memory and Cycle Budget
Each PID_Compact V2 instance consumes approximately 1.2 KB of DB (load memory) and 600 bytes of work memory. A CPU 1214C with 100 KB of work memory supports ~150 instances theoretically; the practical ceiling is set by OB1 cycle time, not memory. Each instance adds 80–150 µs of execution time on a 1214C measured at 100 ms cycle. For the dual-PV swap pattern, the multiplexer is < 5 µs, so the bottleneck remains the PID math.
On the S7-1200 G2 (firmware V1.0) the technology object is the same instruction; execution time is roughly halved because of the faster backplane. No code change is required to migrate a 1200 → 1200 G2 PID_Compact project; the wizard will refactor the schema automatically when the project is upgraded.
Frequently Asked Questions
Can a single PID_Compact block accept two process variables on an S7-1200?
No. PID_Compact V2.x is a SISO technology object with one Input / Input_PER and one Setpoint. To regulate two PVs against a shared actuator you must either instantiate PID_Compact twice (one per loop) or use the PD-swap multiplexer pattern with Ti set to a very large value. True MIMO is not available outside the PCS 7 MPC library.
What is the correct way to bind two analog inputs to one PID loop?
It is not supported by the technology object. The canonical Siemens solution is to create a second PID_Compact instance, wire it to the second AI, and let the two loops coordinate through a feed-forward path or a higher-level selector block in your user program.
Which PID technology object should I use for heat + cool control?
Use PID_Temp (S7-1200 / S7-1500). It provides a heating output and a cooling output with anti-windup, split-range, and a configurable dead-band. The configuration is documented in the same function manual as PID_Compact.
How do I stop the integrator from accumulating during a PV swap?
Set Retain.CtrlParams.Ti to a very large value (for example 4 000 000 ms) so the I-term contribution is < 1 % of MV. For a fully bumpless transition, force ManualEnable := TRUE for one cycle, set ManualValue to the current Output, switch the multiplexer, and release manual mode on the next cycle. PID_Compact V2 then restarts the integrator with zero error.
Does PID_Compact work on the S7-1200 G2?
Yes. The technology object is supported on the S7-1200 G2 (firmware V1.0+) and projects can be upgraded from S7-1200 V4.x with no source change. The TIA Portal V21 online help covers the migration path. Execution time roughly halves due to the faster backplane.