Resolving PID_Compact Output_PWM Not Activating on S7-1200

David Krause11 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

Resolving PID_Compact Output_PWM Not Activating on S7-1200 in Cyclic Interrupt OB30

When a temperature loop using PID_Compact is placed inside a cyclic interrupt OB (for example OB30) on a SIMATIC S7-1200 CPU, the most common symptom is that Output_PWM never goes high even though Input_PER is below setpoint. The controller appears to do nothing after a download, but begins regulating as soon as the user clicks Start in the online commissioning editor. This article documents the root causes, the exact parameter set that drives PWM behavior, and a verified commissioning sequence that eliminates the failure mode.

Pre-read: Siemens documents cyclic interrupt behavior for the S7-1200 in the SIMATIC S7-1200 G2 Manual Collection – Cyclic Interrupt OB. The OB cycle time determines how often PID_Compact is called and directly affects the achievable PWM resolution.

1. Problem Description

Typical reported failure on a CPU 1214C / 1215C / 1217C running firmware V4.2 through V4.6 with TIA Portal V16/V17/V18:

  • PID_Compact instance DB is called from OB30 with a configured interrupt period (for example 100 ms).
  • Process value is wired through an analog input word (e.g., IW64) into Input_PER.
  • Setpoint is loaded above the measured temperature.
  • After project download and CPU RUN, Output_PWM stays FALSE continuously.
  • As soon as the operator opens the PID commissioning editor and clicks Start, the controller begins modulating Output_PWM immediately.

The discrepancy between offline simulation, downloaded behavior, and online commissioning behavior is the diagnostic signature of a mode-retention or scaling misconfiguration, not a wiring or hardware fault.

2. Root Cause Analysis

Four distinct causes can produce the symptom. They are listed in the order Siemens technical support and the TIA Portal online help recommend checking them.

2.1 Operating Mode Drops to Manual After Download

PID_Compact initializes to a default Mode = 4 (Manual mode with manual value 0.0) when the instance DB is freshly generated. The operator clicking Start in the commissioning editor sets the mode to 3 (Automatic) and writes it to the retain area. After every download of a new program or a STOP-to-RUN transition that is not preceded by a re-initialize, the controller reads back the retained Mode value. The watchdog tag to monitor is State:

State value Effective operating state
0 Undefined / initialization
1 Inactive (controller not enabled)
2 Manual mode active
3 Automatic mode active
4 Pre-tuning active
5 Fine tuning active
6 Manual mode reached from fine tuning

If State reads 2 after download and the manual value is 0.0, Output stays at 0 % and Output_PWM never goes high. This is the single most frequent cause.

2.2 PLCSIM 1200 Does Not Execute PID_Compact

PLCSIM for the S7-1200 line is a stripped-down simulator and does not execute the PID instruction. Attempts to test a closed loop against PLCSIM 1200 always show Output_PWM = FALSE. Only PLCSIM V15 and later for the S7-1500 family supports PID_Compact and PID_3Step. If the development environment is PLCSIM 1200, move the project to a real S7-1200 CPU or to PLCSIM 1500 (with an S7-1500 program image) for verification.

2.3 Interrupt OB Cycle Time vs. PWM Period Mismatch

Retain.CtrlParams.Cycle defines the period of the PWM signal that the instruction generates internally. The interrupt OB cycle time is the resolution at which PID_Compact is called. If the OB cycle is, for example, 100 ms and Retain.CtrlParams.Cycle is 1.0 s, the instruction rounds on/off times to multiples of 100 ms. For a calculated Output of 89 % the instruction tries to emit 890 ms ON / 110 ms OFF, rounds to 900 ms / 100 ms, and records the rounding error to compensate on the next cycle. A too-coarse OB time can create dead bands on small outputs and is a frequent source of confusion when the user monitors the output in a watch table whose refresh is itself several hundred milliseconds.

2.4 Minimum On/Off Time Larger Than Period

Config.MinimumOnTime and Config.MinimumOffTime are safety limits, in seconds, applied to the PWM output. If either value is set equal to or greater than Retain.CtrlParams.Cycle, the instruction cannot produce a valid duty cycle and will suppress the output transition. Siemens' recommendation is to keep both minimum times strictly less than the configured PWM period; typical values are 0.05 s to 0.2 s for thermal loops.

3. Operating Mode Parameters and How to Set Them

Mode is declared as InOut, so it cannot accept a constant at the block call. Three working methods exist:

  1. Static initialization (recommended): Open the PID instance DB, set Mode = 3, save, and download. Because Mode is retain, the value survives a STOP-RUN. If the value does not appear online, use the toolbar Online & diagnostics → Download to device → Reset to factory settings / Initialize option to force the retain area to take the new value.
  2. Programmatic change: Use a MOVE instruction to write 3 into iDB.Mode before the PID_Compact call, then assign TRUE to ModeActivate for exactly one scan of the calling OB. A rising edge on ModeActivate is the trigger that causes the instruction to commit the new Mode value.
  3. Watch table (engineering use only): Force Mode = 3 and toggle ModeActivate = TRUE once, then back to FALSE. This is the fastest method for diagnosing the cause and confirming the parameter path is correct.
Caution: Force tables and watch-table writes to a retain tag persist across power cycles only if the value committed is the new retained value. Always verify by power-cycling the CPU once after commissioning.

4. PWM Output Behavior, Timing, and Calculations

For any Output strictly between 0 % and 100 % exclusive, Output_PWM switches every cycle with a duty cycle equal to the manipulated value. The general formula is:

T_on = Retain.CtrlParams.Cycle × Output / 100
T_off = Retain.CtrlParams.Cycle × (100 − Output) / 100

Retain.CtrlParams.Cycle [s] Output [%] T_on [ms] T_off [ms] Visible to 250 ms watch table?
1.0 89 890 110 Yes (slow)
0.5 89 445 55 Marginal
0.2 89 178 22 Often missed
0.1 10 10 90 No - use Trace

The S7-1200 has an integrated Trace function (TIA Portal > CPU > Traces) that records tag values at the OB cycle resolution. Recording Output_PWM, Output, and Setpoint for 30 s is the only reliable method to verify PWM timing when the watch-table refresh hides the transitions.

5. Process Value Input: Input vs. Input_PER

Two input paths are available; both feed the same internal process variable, but they require different configuration flags.

Process value source Input parameter to use Configuration flag Output to monitor
Already scaled REAL in user program Input Config.InputPerOn = FALSE ScaledInput equals Input
Raw analog input word from SM/SB (e.g. IW64) Input_PER Config.InputPerOn = TRUE ScaledInput shows the scaled engineering value

The scaling for Input_PER is defined in the PID configuration editor under Process value scaling with lower and upper limits in engineering units and a raw range matching the analog module (0–27648 for 0–10 V or 0–20 mA, ±27648 for ±10 V or ±20 mA). If the limits are not configured, ScaledInput remains at 0 and the controller cannot generate a non-zero error signal.

6. Step-by-Step Recovery Procedure

The following sequence restores Output_PWM on a freshly downloaded S7-1200 program.

  1. Confirm target hardware. Make sure you are testing against a real S7-1200 CPU (or PLCSIM 1500) – not PLCSIM 1200.
  2. Check the calling OB. Verify OB30 has a cycle time attribute set in the OB properties (e.g., 100 ms). The instruction must be called at a fixed cadence. Use the Cyclic Interrupt OB documentation as the reference for the allowed range (1 ms to 60 000 ms on S7-1200, with a minimum equal to the CPU cycle time).
  3. Inspect the instance DB online. Open the PID_Compact instance DB with monitoring active. Record the values of Mode, State, Input_PER, ScaledInput, Setpoint, and Output.
  4. Set Mode = 3 via watch table. Force the value and pulse ModeActivate. Confirm State transitions to 3.
  5. Verify input scaling. Confirm ScaledInput tracks the live process value in engineering units. If it remains 0, re-enter the scaling limits in the configuration editor and re-download.
  6. Confirm Retain.CtrlParams.Cycle. Typical thermal-loop value: 1.0 s to 10.0 s. The cycle must be at least 10 × the OB period to give the PWM enough resolution; a 1.0 s PWM with a 100 ms OB gives 10 quanta, which is acceptable. A 0.2 s PWM with a 100 ms OB is acceptable but borderline; prefer shorter OB periods for higher resolution.
  7. Trim MinimumOnTime / MinimumOffTime. Set both to 0.05 s or to a value strictly smaller than Retain.CtrlParams.Cycle.
  8. Download and reset the retain area. Right-click the CPU in the project tree > Download to device > check Initialize retain data. This writes the offline Mode = 3 into the retain area permanently.
  9. Confirm with Trace. Record Output_PWM, Output, and Setpoint for 30 s. Duty cycle must match Output / 100 within ± one OB period.

7. Tuning Methods Built into PID_Compact

If the output is present but the loop response is sluggish, run the integrated tuning. Both methods can be triggered from the commissioning editor or by writing to the Mode parameter with ModeActivate.

Method Mode value Precondition Controller action Resulting State
Pre-tuning 1 Setpoint well above current process value, process in "cold" state Steps Output to a configurable amplitude, evaluates process reaction 3 (Automatic) on success, 6 (Manual fallback) on failure
Fine tuning 2 Process value near setpoint Oscillates Output around the operating point with small amplitude 3 (Automatic) on success, 6 (Manual fallback) on failure
Automatic mode 3 Tuning complete or known gains entered manually Normal closed-loop control 3
Manual mode 4 Operator override Output tracks ManualValue 2

Manual gain tuning follows the classic Chien-Hrones-Reswick rules. For a thermal loop, start with Gain (Kp) ≈ 1.0 and Ti (Tn) ≈ 60 s, then reduce Tn in 20 % steps until small overshoots appear, then increase it back by 30 %. If derivative action is needed, add Td (Tv) ≈ 0.1 × Tn with a low-pass filter factor of 0.5.

8. Verification Checklist

  • State = 3 on the instance DB (automatic mode active).
  • ScaledInput matches live temperature in engineering units.
  • Output is non-zero when ScaledInput ≠ Setpoint.
  • Trace shows Output_PWM toggling at the configured period with the correct duty cycle.
  • Setpoint step from 25 °C to 60 °C on a 1 kW heater brings ScaledInput to 60 ± 1 °C within the expected settling time.
  • After CPU power cycle (OFF for 5 s, ON), State = 3 is retained and Output_PWM resumes without operator action.

9. Common Pitfalls and Field Notes

  • Offline Mode does not equal online Mode. The instance DB column in offline view shows the value from the project file. The value in the CPU is the retained one. Use Reset to factory settings / Initialize retain data to align them.
  • Watch-table refresh hides fast transitions. Watch tables poll the CPU with a cycle of typically 200–500 ms. A 50 ms pulse on Output_PWM will be invisible. Use Trace.
  • PWM period set shorter than OB period. If the OB period is 100 ms and Retain.CtrlParams.Cycle is 50 ms, the instruction will not be able to subdivide the period and will clamp the output. The instruction enforces Retain.CtrlParams.Cycle ≥ OB period in the configuration editor with a warning, but the warning is easy to miss.
  • Input_PER wired to the wrong IW address. On a CPU 1214C the onboard analog inputs start at IW64. On a CPU 1217C they start at IW0. Mixing them up feeds a fixed value into the controller and the response looks dead.
  • Sensor break detection trips the controller to State = 1 (inactive). If Input_PER underflows or overflows the raw range (e.g., a 4–20 mA sensor with broken wire returns 0), PID_Compact enters a safe state and Output_PWM is forced FALSE regardless of Mode. The diagnostic buffer of the CPU will contain the entry "PID_Compact sensor break" with the instance DB number.
Safety reminder: Output_PWM drives an SSR or contactor that switches mains voltage to a heater. Always confirm the PWM output is wired through a fused, interlocked contactor rated for the load, and add an independent over-temperature cutoff (Klixon or PTC) on the heater element. PID_Compact alone is not a safety system.

10. FAQ

Why does Output_PWM work in the online commissioning editor but not after a download?

Clicking Start in the commissioning editor sets Mode = 3 (Automatic) and writes it to the retain area. A download with a new program or a STOP-to-RUN transition can leave Mode at the default 4 (Manual with manual value 0). Set Mode = 3 in the offline instance DB and download with Initialize retain data to make the change permanent.

Can I test PID_Compact in PLCSIM 1200?

No. PLCSIM 1200 does not execute the PID instruction. The output remains 0 regardless of inputs. Use a real S7-1200 CPU or PLCSIM 1500 (with an S7-1500 program) for closed-loop simulation.

What is the relationship between OB30 cycle time and Retain.CtrlParams.Cycle?

OB30 cycle time is the rate at which PID_Compact is called. Retain.CtrlParams.Cycle is the period of the PWM signal that the instruction generates. Keep Retain.CtrlParams.Cycle at least 10 × the OB period to get reasonable PWM resolution; typical values are 1.0–10.0 s for thermal loops.

How do I switch from Manual to Automatic mode during runtime?

Write the desired value to the InOut parameter Mode using a MOVE block, then generate a single rising edge on ModeActivate. The State parameter transitions to 3 to confirm Automatic mode is active. Monitor State continuously to detect mode changes initiated by the instruction itself (for example, the fallback to Manual after failed tuning).

Why does my watch table show Output_PWM stuck on or off even though Trace shows correct toggling?

The S7-1200 watch table refreshes every 200–500 ms and can miss narrow pulses. Use the integrated Trace function (CPU > Traces in TIA Portal) to record Output_PWM at the OB cycle resolution and verify the true duty cycle. This is especially important when Retain.CtrlParams.Cycle is below 1 s.

Back to blog