Fix S7-1200 PID_Compact V1.2 Not Restarting After Power Failure

David Krause12 min read
S7-1200SiemensTroubleshooting
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

Problem Summary

An S7-1200 CPU running three PID_Compact V1.2 loops (configured in TIA Portal V13) for temperature regulation fails to return to closed-loop control after a power loss or a controlled power-down for maintenance. After the CPU completes restart, the loop sits in Inactive and the commissioning dialog shows a status such as Setpoint outside limits, even though the configured setpoint (e.g. 3 °C) is well inside the configured ProcessValueHighLimit (15) and ProcessValueLowLimit (0). Pressing Start in the commissioning panel returns the block to automatic operation, but the next power cycle reproduces the same fault.

The behavior is consistent with PID_Compact losing its internal operating mode and falling back to i_mode = 0 at cold restart, which triggers the early input-validation bit on the very first call. Because PID_Compact V1.2 stores its working point and last mode differently than V2, the V1.2 block requires explicit configuration of the Restart behavior properties to remain in automatic after STOP→RUN and power-up transitions.

Symptom fingerprint: commissioning panel reports Setpoint outside limits or Invalid input parameter right after power-up; manual Start works; issue reproduces 100% on power cycle; multiple PID_Compact instances on the same CPU may behave identically or only some of them may fault depending on the retain attributes of the instance DB.

Root Cause Analysis

PID_Compact V1.2 in TIA Portal V13 exposes its operating state through the static tag <PID_DB>.sRet.i_mode on the instance DB of each loop. The accepted values, inherited from the PID_Compact application design, are:

i_mode Meaning Typical use
0 Inactive Block loaded but no control active; outputs held in substitute.
1 Sensor commissioning Phase 1 of pretuning for input scaling / valve curve.
2 Controller tuning Phase 2 of pretuning; identification of process parameters.
3 Automatic mode Closed-loop control with PID algorithm.
4 Manual mode Operator-driven fixed output (ManualValue).
5 Substitute output Output forced to configured substitute value.

After a power loss the CPU reinitializes: the OB100 (warm restart) or OB101 (hot restart) executes, instance DB tags marked Retain are restored from the buffered area, and PID_Compact evaluates its restart properties. On PID_Compact V1.2 the relevant block property is:

  • Basic settings > Restart behavior > Enable last mode after CPU restart (default: disabled)

When this property is left at its default, PID_Compact resets to i_mode = 0 on every CPU restart regardless of the previous state. The block then evaluates its inputs on the first cycle: because Setpoint, Input (ProcessValue) and the limit configuration have not yet been committed through a successful iMode = 3 transition, the early-cycle check can latch Setpoint outside limits based on stale configuration. Pressing Start in the commissioning panel writes i_mode = 3, the block re-evaluates limits against the live setpoint/configuration, the alarm clears, and automatic control resumes. That is why the issue appears to be a configuration paradox — the values look valid in the inspector, but the block reports them as invalid until it is initialized through the operator panel.

The reference for this property is the SIMATIC S7-1200/1500 PID control function manual, section 4.2.1.1 Basic settings V1 (page 100 in the released edition), which documents the V1.x block families (PID_Compact V1.x, PID_3Step V1.x). The same property also exists on PID_Compact V2, where it appears as CPU restart behavior with options Run last mode / Go to inactive mode.

Affected Versions and Compatibility

Block Firmware range where behavior observed TIA Portal Notes
PID_Compact V1.0 CPU 1200 FW ≤ 4.0 V11 SP2 / V12 Same Restart behavior property; default = off.
PID_Compact V1.1 CPU 1200 FW 4.0–4.2 V12 SP1 Same property; bug fixes on limit latching.
PID_Compact V1.2 CPU 1200 FW 4.2–4.6 V13 / V13 SP1 / V14 Property name unchanged; manual page 100.
PID_Compact V2.x CPU 1200 FW ≥ 4.4 (and S7-1500) V14 SP1 / V15 Property renamed to CPU restart behavior; set to Run last mode.
PID_Compact V3.x CPU 1200 FW ≥ 4.5; S7-1500 V15.1 / V16 / V17 Sub-option Substitute output value available on restart.
If you migrate PID_Compact V1.2 to V2 or V3 in TIA V14 or later, the Enable last mode after CPU restart property is automatically mapped to CPU restart behavior = Run last mode. Verify the mapping in the project after upgrade — the migration tool only carries the property if the block instance is regenerated.

Solution 1 — Enable "Last Mode After CPU Restart"

This is the documented, intended fix and is the first thing to change on every PID_Compact instance in the project.

Prerequisites

  • TIA Portal V13 SP1 or higher (V13 SP2 recommended for V1.2 firmware compatibility).
  • Project offline; user has Edit rights on the controller and the PID instance DBs.
  • The PID instance DB must be configured as Retain on the operator-relevant tags (Setpoint, ManualValue, ProcessValue scaling). This is the default for instance DBs generated by PID_Compact.

Step-by-step

  1. Open the TIA Portal project and navigate to the CPU folder of the S7-1200 station.
  2. Open each PID_Compact instance (three instances in the reference case) by double-clicking the block in the program.
  3. Switch to the Configuration editor (gear icon at the lower-left of the block editor).
  4. Select Basic settings → page Restart behavior (formerly labeled "Mode after CPU restart").
  5. Tick the checkbox Enable last mode after CPU restart.
  6. For V2/V3 blocks: change CPU restart behavior from Go to inactive mode to Run last mode.
  7. Compile (Hardware + Software) and download to the CPU. If only the software is changed, perform an Online & Diagnostics → Download to device; the instance DB retain values are preserved.
  8. Test the cold-restart path: drive the CPU to STOP, remove the 24 V supply for at least 5 seconds, re-apply power. The CPU executes OB100; PID_Compact reverts to i_mode = 3; the loop resumes automatic control without operator intervention.

Verification

  • Open an Watch table on the instance DB and confirm that sRet.i_mode reads 3 within two OB1 cycles of CPU restart.
  • In the commissioning panel of each PID, confirm Operating mode = Automatic and no active error bits in ErrorBits.
  • Confirm that the last setpoint (e.g. 3 °C) is still present in Setpoint after the power cycle — this proves the retain setting of the instance DB is intact.

Solution 2 — Hardened Watchdog on sRet.i_mode

If the instance DB retain setting cannot be guaranteed (for example because a third-party HMI writes to the DB and unsets the retain attribute on some tags), or if you want to add belt-and-braces protection against the operator commissioning panel being used incorrectly, add a watchdog that re-enters automatic mode whenever the block drops to i_mode = 0.

Reference logic (SCL)

// FB_PID_AutoRestart — drops onto each PID_DB instance
// Inputs: i_PID_DB (VARIANT pointing at the PID_DB), i_AllowRestart (BOOL)
// Outputs: q_State (INT), q_Error (BOOL)

#q_State := "PID_DB".sRet.i_mode;

IF #i_AllowRestart AND "PID_DB".sRet.i_mode = 0 THEN
    // First, force a Reset to clear any latched ErrorBits
    "PID_DB".sRet.i_Mode := 4;          // switch to manual briefly
    "PID_DB".ManualEnable := TRUE;
    "PID_DB".ManualValue  := "PID_DB".Output;   // bumpless transfer

    // Wait one OB1 cycle
    // (in practice use a TON or a rising-edge trigger)

    "PID_DB".sRet.i_Mode := 3;          // request automatic
    "PID_DB".ManualEnable := FALSE;
END_IF;

// Latch an operator-visible error if the block refuses to enter auto
#q_Error := ("PID_DB".sRet.i_mode = 0) AND #i_AllowRestart;

A robust field-proven pattern is to gate the watchdog with a 10 s on-delay timer so that normal mode transitions during pretuning are not masked. Wire the timer output to sRet.i_mode := 3 only when the block has been continuously inactive for >10 s.

Watchdog in LAD

  1. Create a TON (IEC timer) with PT = 10 s, IN = ("PID_DB".sRet.i_mode = 0).
  2. On the rising edge of the timer Q output, set a coil that writes 3 to "PID_DB".sRet.i_mode using a move box and a coil that pulses "PID_DB".Reset = TRUE for one cycle.
  3. Reset the timer the moment sRet.i_mode = 3 is observed, so the watchdog only acts when the block has been stuck.
Treat sRet.i_mode as the source of truth for the operating state. Do not write to i_Mode (input) and sRet.i_mode (output) at the same time. The block evaluates i_Mode on the rising edge and reports back through sRet.i_mode; if the two disagree you will introduce a startup race that occasionally traps the block in i_mode = 4 (manual) forever.

Solution 3 — Force a Clean Pretuning Pass

If the commissioning panel still reports Setpoint outside limits after Solution 1 and Solution 2, the limit configuration is genuinely inconsistent with the live process value. This is rare but happens when the analog input scaling is changed after the block has already executed. The clean fix is to walk the block through pretuning once:

  1. In TIA Portal, open each PID_Compact instance and run Commissioning → Pretuning. If Sensor commissioning is enabled (PID_Compact V1.2 + analog input scaling), run that first.
  2. Observe the Status field; it should progress through Sensor commissioning (1) → Pretuning (2) → Automatic (3) without errors.
  3. If Pretuning reports Setpoint outside limits, check Config.InputScaling.UpperPointIn / LowerPointIn and the analog input wiring at the SM module. On S7-1200 the SB or SM input type must match the sensor type (e.g. Pt100 RTD on a 4-wire input).
  4. Once pretuning completes successfully, the working point is committed and the next cold restart will report the correct limits.

Diagnostics: Reading ErrorBits

PID_Compact V1.2 surfaces a 16-bit ErrorBits structure on the instance DB. Knowing the bit pattern removes the guesswork from "Setpoint outside limits" alarms:

Bit Symbolic name Meaning
0 Input_PER_INV Periphery input value invalid (broken wire, overflow, configuration mismatch).
1 Setpoint_LIM Setpoint outside configured limits (the alarm seen in the case).
2 Input_INV Process value (scaled) invalid: NaN or out-of-range.
3 Output_LIM Output saturated at OutputHighLimit/OutputLowLimit for > OutputWarningLimit cycles.
4 Input_LIM Process value outside ProcessValueHigh/Low limits (typically bad sensor wiring).
5 No_Param Block configuration incomplete — parameters not committed through commissioning panel.
6 Version FW/TIA mismatch — block generated for a different CPU firmware family.
7 CycleTime OB1 cycle time exceeded sampling-time guard; PID switches off if Monitor sampling time is on.
Bits 8–15
8 Init Block in startup; Initialize input active or first cycle after download.
9 TuningInProgress Pretuning or fine-tuning is running.
10 TuningDone Pretuning completed successfully (one-shot, cleared on next mode change).
11 ManualActive Manual mode active (i_mode = 4).
12 SubstituteActive Substitute output value being driven (i_mode = 5).

In a watch table, observe <PID_DB>.ErrorBits as W#16#0002 for the case described — bit 1 (Setpoint outside limits) confirms the alarm.

Hardening Checklist for the S7-1200 PID Project

  1. Tick Enable last mode after CPU restart on every PID_Compact instance.
  2. Confirm each instance DB has its Retain attribute set so that Setpoint, ManualValue, Output, and the PID gains survive power loss.
  3. In TIA Portal V13, under CPU properties → Retain memory, ensure enough retain bytes are reserved. Each PID_Compact V1.2 instance DB consumes roughly 300–400 bytes of retain depending on configuration.
  4. Wire a TON watchdog (10 s) on sRet.i_mode = 0 for every loop, with a Reset pulse to clear stale ErrorBits.
  5. In HMI tags (WinCC Comfort/TIA), use Cyclical acquisition of sRet.i_mode and ErrorBits; raise a message in the HMI log if i_mode < 3 for > 30 s.
  6. Add a UPS or use the S7-1200 capacitor-backed retain time: an S7-1214C with the Maintain power-down setting on the analog SM can hold retain values for up to 100 h after power loss. Use this to avoid the cold-restart code path entirely when the power-loss duration is short.
  7. Document the alarm in the operating manual: "After power-up the controller returns to automatic control within 5 s; if it does not, press Start in the controller faceplate."

Troubleshooting Matrix

Observed symptom Likely cause Fix
PID in i_mode = 0 after power-up; "Setpoint outside limits" Restart behavior property disabled Solution 1 — enable "Last mode after CPU restart".
PID in i_mode = 0 despite restart property enabled Instance DB Retain attribute not set on the Setpoint/ManualValue tags Open instance DB properties, set Retain = true; recompile; cold download.
PID in i_mode = 0 after firmware update FW upgrade reset retain area; instance DB not re-initialized Re-download the software including the instance DB; cold restart.
PID stuck in i_mode = 4 (manual) after restart HMI forced manual mode before power loss; retain preserved manual state Add watchdog that reasserts i_mode = 3 after power-up; document in operator manual.
PID in i_mode = 3 but output is 0%; no control Output saturated at OutputLowLimit; check OutputHighLimit/LowLimit Inspect Output_PWM and Output; raise limits if appropriate; reduce integral action.
"Invalid input parameter" on every restart Analog input not configured (type mismatch on SM1231 RTD/TC) Reconfigure the analog input module type to match sensor (Pt100 / TC / 4–20 mA).
Pretuning fails with "Sampling time error" OB1 cycle time > configured Sampling time Raise Sampling time to 1.0 s or disable Monitor sampling time if OB1 jitter is expected.
Only some of three PIDs fail on the same CPU Each PID DB has independent retain/initialization; check per-instance settings Apply Solution 1 to every instance individually — there is no project-wide setting.

FAQ

Why does PID_Compact V1.2 show "Setpoint outside limits" right after a power cycle even though the setpoint (e.g. 3) is inside the configured limits (0 to 15)?

On a cold restart PID_Compact resets to sRet.i_mode = 0 when the Enable last mode after CPU restart property is disabled. In i_mode = 0 the block re-evaluates its limits before the working point is committed, which can latch Setpoint outside limits based on stale configuration. Tick the restart-behavior property in the block's Basic settings, or add a watchdog that writes i_mode = 3 after a 10 s delay.

What is the difference between i_Mode and sRet.i_mode on PID_Compact V1.2?

i_Mode is the input that requests a mode change (3 = automatic, 4 = manual, etc.). sRet.i_mode is the actual current operating state reported back by the block. They can differ for one or two OB1 cycles during a mode transition; write only to i_Mode and read only from sRet.i_mode to avoid races.

Does "Enable last mode after CPU restart" survive a TIA Portal software update?

Yes, the property is stored in the offline project and in the block instance. When you upgrade TIA Portal (for example V13 SP1 → V14) and migrate the project, the property is mapped to the equivalent V2/V3 setting CPU restart behavior = Run last mode. Verify the mapping in the inspector after migration; if the block instance is regenerated without the migration tool, the property defaults back to off.

Will retain on the PID_Compact instance DB eat my retain budget on the S7-1200?

Each PID_Compact V1.2 instance DB consumes roughly 300 to 400 bytes of retain memory. An S7-1212C has 10 kB of retain, an S7-1214C has 14 kB, and an S7-1215C has 18 kB by default; three PID loops plus typical process retain (setpoints, totals) fit comfortably. Increase the retain area under CPU properties → Retain memory if you add more loops or large recipe structures.

Can I keep the PID in automatic during a planned power-down for maintenance?

Use the S7-1200 capacitor-backed retain or an external UPS sized for at least the hold-up time of the retain area (typically a few seconds to 100 h depending on CPU model). With retain intact and the restart property enabled, PID_Compact returns to i_mode = 3 on power-up automatically. For longer maintenance windows, switch the HMI to Manual first, set the actuator to a safe position via the manual output, then power down — the controller will restart in manual and your watchdog can later bump it back to automatic.

Back to blog