Siemens S5-135U CPU928B PID Control with OB250 OB251 Reference

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

CPU928B PID Architecture Overview

The Siemens SIMATIC S5-135U PLC equipped with the CPU928B processor provides two distinct organization blocks for closed-loop control: OB250 and OB251. These OBs implement fixed-cycle PID controllers directly in the operating system scan of the CPU, eliminating the need for a separate R64 regulator coprocessor and its COM 525 / COM REG parameterization software. When the CPU928B was deployed with native OB250/OB251 control, only the relevant data block (DB) needed to be defined; the OB itself performed the PID arithmetic on each scheduled invocation.

For the CPU928B, the architecture is conceptually different from later S7 platforms:

  • OB250 – a single-loop fixed-structure PID controller invoked by the operating system.
  • OB251 – an enhanced PID controller with selectable structure, manual setpoint, and manual/automatic mode, also invoked by the operating system.
  • DB – the data block holding controller parameters, setpoints, process values, manipulated variables, status flags, and mode bits.

The data block associated with OB250/OB251 is described in detail in the AG S5-135U Programming Guide, chapter 6.11 starting at page 6-65. This chapter is the canonical reference for the parameter word layout and must be available on-site for any commissioning engineer.

Documentation Requirement: When maintaining a CPU928B installation, the AG S5-135U Programming Guide (CPU 928B section, chapters 6.10 through 6.12) is mandatory. Without it, OB251 data block offsets cannot be reliably mapped and the controller may appear "dead" with output stuck at zero even though the OB is being called.

OB250 vs OB251 – Selection Criteria

Feature OB250 OB251
PID algorithm Fixed structure, position algorithm Selectable (P / PI / PID), position or velocity algorithm
Manual setpoint input Not supported Supported via DB word
Manual / Auto switch External only via bypass Internal mode bit in DB
Output limiting Hardware clamp only Software clamps in DB
Derivative on PV / on error Derivative on error only Configurable via DB flag
Sample time OB cycle time (set in DX0 / DX2) OB cycle time (set in DX0 / DX2)
Typical use Simple temperature/level loops Cascade, servo-pump, multi-mode loops

For a cascade where PID1 feeds PID2, with pump-velocity output and manual override capability, OB251 is the correct choice. OB250 lacks the native manual-mode bit required to switch the pump to a user-supplied speed.

PID Data Block Structure (OB251 DB Layout)

Each invocation of OB251 reads its parameters from a single data block. The CPU928B uses fixed offsets within this DB; the offsets documented in chapter 6.11 of the AG 135U Programming Guide are summarized below. Engineers porting code without comments must verify these against the installed firmware version of the CPU928B.

DB Word (DW) Symbol Function
DW 0 XP Proportional gain (KF, fixed-point), range 0.01 to 99.99
DW 2 TN Reset time (integral action), in seconds, KF format
DW 4 TV Derivative time, in seconds, KF format
DW 6 Y_MIN Lower output clamp, KF, typically -27648
DW 8 Y_MAX Upper output clamp, KF, typically +27648
DW 10 XW Process variable (actual value), KF, 0..27648 normalized
DW 12 W Setpoint, KF
DW 14 Y Manipulated variable output, KF, written back by OB
DW 16 Y_HAND Manual manipulated variable, KF, used in manual mode
DW 18 ERR Control deviation (W - XW), KF, diagnostic
DW 20 Y_SUM Integral component (I-share) for bumpless transfer
DW 22 CTRL_BITS Control word: bit 0 = manual, bit 1 = tracking, bit 2 = D-on-PV
DW 24 CYCLE Sampling time in 10 ms units, KF
Offset verification: The DW offsets above reflect the standard layout for OB251 as documented in the AG S5-135U Programming Guide, CPU928B firmware versions 6.x and 7.x. Some legacy installations used DW offsets shifted by 2; confirm against the actual AG 135U manual on site before modifying parameters.

COM REG vs Native OB251

The CPU928B also supports the R64 regulator card. When an R64 is fitted, parameterization is performed with the COM 525 / COM REG utility, which writes parameters to FB102 and stores runtime data in DB2. The COM REG software allows online tuning, trend display, and step-response recording.

When implementing PID purely via OB251, no FB102 and no COM REG are required. The PID is parameterized by writing the relevant KF (fixed-point) values directly into the DB. The trade-off is loss of online trend visualization: without COM REG the engineer must observe DW18 (control deviation) and DW14 (manipulated variable) via STEP5 variable table or via online PG status.

Approach Software required Data block Online trend
OB250 / OB251 only STEP5 Any user DB No (status only)
R64 + COM REG STEP5 + COM 525 DB2 (fixed) Yes (curve display)

Cascade Configuration (PID1 → PID2)

In the cascade described in the application, PID1 measures an analog process variable (flow, pressure, or temperature) and outputs an internal setpoint that is fed to PID2. PID2 then outputs a manipulated variable that drives the pump speed, typically a 4–20 mA or 0–10 V signal into a VFD reference input.

The cascade wiring is implemented entirely in software by copying DW14 of PID1 into DW12 of PID2 on every scan. There is no need for an external wiring change; only the DBs and the OB251 call order must be correct.

STEP5 Cascade Example

// PID1 DB layout (e.g., DB 50)
DB50
  DW 0   XP1     := KF+100    // Kp = 1.00
  DW 2   TN1     := KF+50     // Ti = 5.0 s
  DW 4   TV1     := KF+0      // No derivative for outer master
  DW 6   Y_MIN1  := KF-27648
  DW 8   Y_MAX1  := KF+27648
  DW10   XW1     := PEW 320   // Analog input word, channel 0
  DW12   W1      := KF+13824  // Setpoint 50% of full scale
  DW14   Y1      := 0         // Manipulated output, written by OB
  DW16   Y_HAND1 := KF+0
  DW18   ERR1    := 0
  DW20   Y_SUM1  := KF+0
  DW22   CTRL1   := KF+0
  DW24   CYCLE1  := KF+10     // 100 ms sample time

// PID2 DB layout (e.g., DB 51)
DB51
  DW 0   XP2     := KF+80
  DW 2   TN2     := KF+30
  DW 4   TV2     := KF+0
  DW 6   Y_MIN2  := KF+0      // Pump 0..100% only
  DW 8   Y_MAX2  := KF+27648
  DW10   XW2     := PEW 322   // Second analog input
  DW12   W2      := KF+0      // Filled from PID1.Y1 each scan
  DW14   Y2      := 0
  DW16   Y_HAND2 := KF+0
  DW18   ERR2    := 0
  DW20   Y_SUM2  := KF+0
  DW22   CTRL2   := KF+0
  DW24   CYCLE2  := KF+5      // 50 ms sample time

// OB1 cyclic scan
OB1
  JU   FB100                  // Cascade glue
  BE

// Cascade glue logic
FB100
  NAME   : CASCADE
  SET
        // Drive PID2 setpoint from PID1 output
  L     DB50.DW14              // Y1 from previous scan
  T     DB51.DW12              // Drive W2 of PID2
        // PID1 sample time update (10 ms tick from DX0)
  L     DB50.DW24
  L     KB1
  -I
  T     DB50.DW24
  L     KB0
  >I
  JC    M001
  L     KB10
  T     DB50.DW24
  SPA   OB251
  NAME  : OB251_IDB := DB50
M001: NOP 0
        // PID2 sample time
  L     DB51.DW24
  L     KB1
  -I
  T     DB51.DW24
  L     KB0
  >I
  JC    M002
  L     KB5
  T     DB51.DW24
  SPA   OB251
  NAME  : OB251_IDB := DB51
M002: NOP 0
  BE

Manual / Automatic Mode Switching

OB251 supports bumpless manual-to-auto transition through its control word (DW22). The recommended procedure:

  1. Set DW22 bit 0 (MANUAL) = 1 and write the desired manual value into DW16 (Y_HAND).
  2. The PID freezes its integral component (DW20) at the current value to prevent a step on the output.
  3. To transfer to automatic, set DW22 bit 0 = 0; the PID uses the current output value as the starting point for the I-share (bumpless transfer).
  4. Verify DW14 tracks DW16 in manual mode and tracks the controlled value in auto mode.
// Manual / Auto selection from operator panel
// I 32.0 = Auto request flag
// I 32.1 = Manual request flag
// IW 36  = Manual speed setpoint from panel (% of full scale, 0..27648)

A   I 32.0                  // Auto
S   M 100.0                 // M100.0 = AUTO_ACTIVE
A   I 32.1                  // Manual
S   M 100.1                 // M100.1 = MAN_ACTIVE

// Write manual value to PID2 if manual
A   M 100.1
JCN M003
L   IW 36
T   DB51.DW16               // Y_HAND2 = panel value
M003: NOP 0

// Build CTRL2 word (bit 0 = MANUAL)
L   KB0
T   DB51.DW22
A   M 100.1
JC  M004
L   KH0001                  // Set bit 0 = manual
T   DB51.DW22
M004: NOP 0

Pump Velocity Output Assignment

After OB251 updates DW14 of PID2, the value must be written to the analog output module that drives the pump VFD reference. Typical assignment:

Signal Source Destination
PID2.Y (manipulated variable) DB51.DW14 PAW 320 (analog output word 0)
Pump running feedback VFD digital output I 40.0 (digital input)
Pump fault VFD digital output I 40.1
Manual speed command Operator panel IW 36
// Write PID2 output to analog output
L   DB51.DW14
T   PAW 320

// Defensive final clamp in case DB is corrupted
L   DB51.DW14
L   KF+27648
>I
JC  M005
L   KF+27648
T   PAW 320
SPA M006
M005: NOP 0
L   DB51.DW14
L   KF+0
<I
JC  M006
L   KF+0
T   PAW 320
M006: NOP 0

Tuning Procedure (Without COM REG)

Without the COM REG online trend tool, tuning must be performed by:

  1. Starting with conservative gains (XP = KF+10, TN = KF+999, TV = KF+0).
  2. Applying a small step change to DW12 (setpoint) of ±5% of full scale.
  3. Reading the response at DW14 (output) and DW18 (error) on the PG using STEP5 Status Variable.
  4. Increasing XP until oscillation appears, then reducing XP by 30%.
  5. Decreasing TN until the steady-state error is eliminated without causing overshoot.
  6. Adding TV last, typically 1/4 of TN, only if the loop exhibits sluggishness.
Stage XP TN TV
Initial 10 999 0
P-tuned 80 999 0
PI-tuned 80 50 0
PID-tuned 80 50 12

Common Fault Modes and Diagnostics

Symptom Likely Root Cause Diagnostic Step
Output stuck at zero (DD46 = 0) OB251 not called, or wrong DB assigned Verify OB251 call in OB1 and that the instance DB matches
Output oscillates wildly Gain XP too high, or CYCLE time too short Halve XP, double CYCLE
Output clamps at Y_MAX immediately Sign error on XW (process variable) Verify PEW scaling and polarity
Bumpless transfer failed Y_SUM not preserved across mode change Verify DW20 is not overwritten by user logic
Manual mode does not respond CTRL_BITS bit 0 not set Force DW22 to KH0001 and observe DW14
PID2 setpoint does not track PID1 Cascade glue not executed each scan Verify L DB50.DW14 / T DB51.DW12 sequence in OB1
Output never updates CYCLE word initialized to 0 Initialize DW24 to a positive integer (10 ms units)

OB250 Variant (Single-Loop, No Internal Manual Mode)

If OB250 is in use instead of OB251, manual override must be implemented externally by a separate FB that bypasses the PID output during manual operation:

// External manual override for OB250 cascade slave
A   M 100.1                  // Manual active
JC  M010
L   DB51.DW14                // Auto: use PID2 output
SPA M011
M010: L   IW 36               // Manual: use panel value
M011: T   PAW 320

This is a common pattern and is the main reason OB251 is preferred for installations where manual override is required.

Verification Checklist

  • ☐ AG 135U Programming Guide chapter 6.11 (page 6-65) available on-site and matches the CPU928B firmware version.
  • ☐ OB251 called from OB1 with correct instance DB (DB50 for PID1, DB51 for PID2).
  • ☐ CYCLE word in DB initialized to the desired sample interval in 10 ms ticks (for example 10 = 100 ms).
  • ☐ Y_MIN and Y_MAX match the physical actuator range (0..27648 for unidirectional pump).
  • ☐ Manual mode produces output that tracks Y_HAND (DW16) within one scan.
  • ☐ Auto mode produces output that responds to setpoint changes without immediate step on mode transition.
  • ☐ Cascade output (PID1.Y) follows PID1 setpoint within the PID1 tuning envelope.
  • ☐ Final analog output clamped at the PAW (defensive programming in case DB is corrupted).
  • ☐ Pump fault input monitored and interlock with controller output enabled.

FAQ

Where is OB251 documented in the Siemens S5-135U manuals?

OB251 and its instance data block layout are described in the AG S5-135U Programming Guide, CPU 928B chapter 6.11 beginning at page 6-65. The chapter also documents the alternative OB250 single-loop controller. Always cross-check the printed page number against the actual manual revision on site, as different printings shift offsets by one or two pages.

Does OB251 need COM REG or FB102 to operate?

No. COM REG and FB102 are required only when the controller is implemented on an R64 regulator coprocessor. OB251 is a pure-software organization block and only requires a data block whose words correspond to the parameters in chapter 6.11. Without COM REG, online trend visualization is unavailable, so tuning must be done via STEP5 status display.

How do I cascade PID1 into PID2 using OB251?

Call OB251 twice per scan with two separate instance DBs (for example DB50 and DB51). After the first OB251 call, copy the manipulated variable from DB50.DW14 into DB51.DW12. The second OB251 call then uses the new setpoint on its process variable PEW from its own analog input. No additional FB is required; the cascade is purely DB-to-DB data movement.

Why is PID2 output zero even though OB251 is being called?

The three most common causes are: (1) the wrong DB is passed as the instance argument to OB251, so the controller writes its result into a DB that is never read; (2) the CYCLE word is initialized to zero, which suppresses the calculation; (3) the CTRL_BITS manual flag is set with Y_HAND = 0, leaving the output clamped. Verify DB50/DB51 selection in the OB251 call statement, initialize DW24 to a positive integer in 10 ms units, and clear DW22 before the first scan.

How is bumpless manual-to-auto transfer implemented in OB251?

Set DW22 bit 0 to 1 to enter manual mode; the controller then outputs the value from DW16 (Y_HAND) and freezes its integral sum (DW20). When transitioning back to automatic, clear DW22 bit 0; the controller initializes the integral component to the current output value so the manipulated variable does not step on the change. Do not overwrite DW20 in user logic or the transfer will no longer be bumpless.

Back to blog