Siemens FB58 Negative Gain: Configuring Cooling Process PID

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

Overview of FB58 in Cooling Applications

The Siemens FB58 (PID_TC) function block is the PID temperature controller from the STEP 7 Standard Library (PID Control Blocks) used with SIMATIC S7-300 and S7-400 CPUs. The block is invoked identically for heating and cooling loops, but the polarity of the proportional gain must be inverted when the manipulated variable (LMN) drives the process in the opposite direction of the setpoint. For Direct Reduced Iron (DRI) bed cooling, where the goal is to drive the bed temperature down to 30 °C by increasing nitrogen flow through a 4–20 mA control valve, the loop is reverse-acting and FB58.GAIN must be loaded with a negative floating-point value.

This reference documents the wiring, instance-DB layout, scaling, FB102 simulation, auto-tuning, verification, and field-validated failure modes for a negative-gain FB58 cooling loop. It complements the official Siemens PID Control standard-library manual and the S7-300/400 PID Programming Guidelines entry on Siemens Industry Online Support.

Prerequisites

  • STEP 7 V5.5 SPx or STEP 7 Professional (TIA Portal V13 SP1 or later for migration). Confirm installed PID Control library version in Help > About.
  • SIMATIC S7-300 CPU 31x (e.g., 6ES7 315-2EH14-0AB0) or S7-400 CPU 41x, with OB35 free for cyclic PID execution.
  • Analog input module for thermocouple/RTD, e.g., 6ES7 331-7PF10-0AB0 (SM331, 8 AI TC) configured for the DRI bed sensor.
  • Analog output module for the nitrogen valve, e.g., 6ES7 332-5HF00-0AB0 (SM332, 8 AO, 4–20 mA).
  • STEP 7 Standard Library > PID Control Blocks installed; FB58 (PID_TC) and FB102 (PID_ES) available in the catalog.
  • One instance DB (e.g., DB1) created as the working data for FB58.

FB58 Block Layout and Instance DB Offsets

The FB58 instance DB exposes every input, output, and static parameter. The offsets below reflect the standard PID Control Blocks V5.x/V6.x layout shipped with STEP 7 V5.5. Open FB58 in the LAD/FBD/ST editor, select the Interface tab, and confirm the offsets against the values shown in the "Symbols" pane of DB1. Never hardcode offsets based on third-party listings.

Offset (DBD / DBW) Parameter Type Description
DBD 0 SP_INT REAL Setpoint, internal (°C)
DBD 8 PV_IN REAL Process value input (°C)
DBD 16 PV_FAC REAL Process value factor (default 1.0)
DBD 24 PV_OFF REAL Process value offset (default 0.0)
DBD 32 DEADB_W REAL Dead-band width (set 0.0 for tuning)
DBD 36 GAIN REAL Proportional gain (NEGATIVE for cooling)
DBD 40 TI TIME Integral action time / reset time
DBD 44 TD TIME Derivative action time
DBD 48 TM_LAG TIME Derivative lag (T#2s recommended)
DBD 60 ER REAL Error signal = SP_INT − PV_IN
DBD 92 LMN REAL Manipulated value (REAL, %)
DBW 96 LMN_PER WORD Manipulated value, peripheral (0–27648)
Address verification: field installations occasionally report GAIN at DBD 166 instead of DBD 36. This typically indicates the FB58 source has been re-instantiated from a customized library, or the developer is viewing the wrong instance DB. Always right-click the FB58 in the call, choose Go To > Instance DB, and read the actual offset from the "Interface" view. Operating on an assumed offset will silently corrupt the controller.

Negative Gain Theory for Cooling Loops

FB58 computes error with the conventional definition:

ER = SP_INT − PV_IN

The proportional component of the controller output is:

LMN_P = GAIN × ER

For a heating loop where LMN drives PV upward, ER is positive when PV < SP, GAIN is positive, and LMN rises to drive temperature up. This is the textbook configuration used in the Siemens STEP 7 sample projects.

For a cooling loop where LMN drives PV downward, the controller is reverse-acting. Consider what happens with a positive GAIN at startup, PV > SP:

  • PV = 65 °C, SP = 30 °C → ER = −35
  • GAIN = +1.0 → LMN_P = −35 (valve closes, less nitrogen)
  • Reduced nitrogen flow → PV continues to rise toward ambient → ER grows more negative
  • Integral action compounds the wrong direction; LMN_PER saturates at 0 mA
  • The controller "saturates cold" and never recovers.

Reversing GAIN to a negative value corrects the action:

  • PV = 65, SP = 30 → ER = −35
  • GAIN = −1.0 → LMN_P = +35 (valve opens, more nitrogen)
  • Increased nitrogen → PV falls toward SP → ER approaches zero → LMN stabilizes

For DRI cooling with temperature ranges on the order of 0–100 °C, LMN_PER at 0–27648, and a thermal time constant of 30–120 seconds, GAIN magnitude typically falls between 0.5 and 10.0. Always start with a small magnitude (e.g., −0.1) and increase in steps of 0.5 after observing step-response stability.

Magnitude cap: do not exceed |GAIN| ≈ 50 for temperature loops with the default CYC_TIM of 100 ms. Large negative GAIN combined with derivative action amplifies high-frequency noise from the thermocouple and trips anti-windup on the first scan. Pre-tune with TI ≥ T#5s and TM_LAG = T#2s before raising the gain magnitude.

Signal Conditioning and Scaling

FB58 expects PV_IN as a normalized REAL in engineering units. Raw analog values must be scaled before passing to the block. For an SM331 configured as 4–20 mA with a temperature transmitter set to 0–100 °C, the scaling function is:

// Scale 0..27648 to 0.0..100.0 deg C
// IN  : WORD   (raw value 0..27648)
// HI  : REAL   (100.0)
// LO  : REAL   (0.0)
// OUT : REAL

OUT := (REAL(IN) / 27648.0) * (HI - LO) + LO;

For SM331 channels configured directly for thermocouple input, the module returns a temperature value already scaled in 0.1 °C increments (or 0.01 °C for some ranges). Divide the raw value by 10.0 (or 100.0) and pass directly to FB58.PV_IN.

LMN_PER (WORD 0–27648) is wired directly to the analog output process image, e.g.:

L  DB1.LMN_PER
T  PQW 272    // SM332, slot 4, channel 0

FB102 Simulation Block Setup

FB102 (PID_ES) is the integrated process simulation block delivered with the PID Control Blocks library. It is intended for STEP 7 PLCSIM and offline loop verification. To configure a closed cooling loop in simulation:

  1. Open the STEP 7 Standard Library > PID Control Blocks and copy FB58 and FB102 into the project Blocks folder.
  2. Create instance DB1 for FB58 and instance DB2 for FB102.
  3. Wire DB2.PV_OUT → scaling FB → DB1.PV_IN.
  4. Wire DB1.LMN_PER (WORD) → normalize to 0–100 % REAL → DB2.LMN_IN (REAL).
  5. Configure DB2 parameters:
    • GAIN = −1.0 (negative for reverse-acting plant)
    • TM_LAG = T#2s
    • TM_INT = T#30s (process integration)
    • PV_OFF = 30.0 (initial DRI bed temperature)
    • PV_FAC = 1.0
  6. Place both FB58 (DB1) and FB102 (DB2) in OB35. Verify OB35 cycle time matches the CYC_TIM input on FB58 (default T#100ms).

If you want to keep FB102.GAIN positive (direct-acting), invert the manipulated variable before driving FB102.LMN_IN:

// Negate LMN for cooling plant simulation
SIM_LMN_PER := 27648 - DB1.LMN_PER;
DB2.LMN_IN := REAL(SIM_LMN_PER) / 27648.0 * 100.0;

Step-by-Step Configuration Procedure

1. Insert FB58 in OB35

Open OB35 and call FB58 with the necessary I/O. A minimal LAD call:

// OB35 - 100 ms cyclic interrupt
CALL FB 58, DB1
   SP_INT  := MD100     // Setpoint, deg C
   PV_IN   := MD110     // Process value, deg C
   GAIN    := MD120     // Proportional gain (negative)
   TI      := T#2S      // Reset time
   TD      := T#0S      // No derivative
   TM_LAG  := T#2S
   MAN_ON  := FALSE
   MAN     := 0.0
   COM_RST := FALSE
   LMN_PER := MW130     // WORD output to AO module

2. Load Negative GAIN

Write the negative gain into the instance DB before the FB58 call, or via a VAT/HMI tag:

// Set GAIN = -2.5 for initial cooling tune
DB1.DBD36 := -2.5;

Equivalent STL:

L  -2.500000e+000
T  DB1.DBD36

3. Wire the Analog Output

Move LMN_PER (WORD) to the analog output process image:

L  DB1.LMN_PER
T  PQW 272

If the AO module is on a different slot, change PQW to match the slot base address. SM332 6ES7 332-5HF00-0AB0 in slot 4 starts at PQW 272 by default.

4. Verify the Loop in Monitor/Modify

Open DB1 online (right-click > Monitor/Modify) and observe:

  • DB1.DBD0 = 30.0 (setpoint)
  • DB1.DBD8 = 65.0 (simulated PV, drifting down)
  • DB1.DBD60 = -35.0 (error)
  • DB1.DBD36 = -2.5 (GAIN, negative)
  • DB1.DBD92 = rising from 0 toward positive
  • DB1.DBW96 = rising from 0 toward 27648

If the ER sign and the LMN_PER direction track each other correctly, the controller is wired right.

Loop Signal Flow (ASCII Topology)

FB58 Cooling Loop - Signal Flow FB58 (DB1) GAIN < 0 ER = SP - PV LMN_PER >= 0 TI = T#2s..T#20s SM332 AO 4-20 mA PQW 272 N2 Valve Pneumatic Actuator Air-to-Open DRI Bed PV > SP Reverse Acting TC / RTD SM331 AI LMN_PER mA N2 flow Temp PV feedback (scaled to deg C) setpoint reference path (HMI/VAT)

Auto Tuning Procedure

FB58 has a built-in controller-tuning routine. Auto tune is appropriate only when the loop is at a stable operating point and the process is repeatable.

  1. Bring the loop to a steady condition with FB58.MAN_ON = TRUE; drive MAN to a value that holds PV near SP (e.g., PV = 55 °C when SP = 30 °C is too far; pick a midpoint like SP = 50).
  2. Switch MAN_ON = FALSE; the controller goes to automatic with the existing GAIN and TI.
  3. Open DB1 online, navigate to the static-parameter section, and locate CONT_TUNE (BOOL). Set it to TRUE.
  4. Monitor the STATUS output (INT) for the following values:
    • 0 – idle / tuning complete (new params written)
    • 1–4 – tuning in progress (phase 1–4)
    • 5–7 – tuning fault (process too noisy, asymmetric, or unstable)
  5. Once STATUS returns to 0, the tuned GAIN, TI, TD values are written to DB1.
  6. Set CONT_TUNE back to FALSE to prevent re-triggering on every cycle.
Auto-tune hazards on a real plant: during tuning, FB58 swings LMN_PER across the full 0–27648 range. On a real DRI bed, this drives the nitrogen valve full open and full closed. Confirm nitrogen supply pressure and mechanical limits, and verify that downstream equipment (cyclone, scrubber, baghouse) can absorb the resulting temperature and flow excursion. Auto tune is safest in PLCSIM with FB102.

Verification and Loop Check

Test Procedure Expected Result
Sign check Force PV = 70, SP = 30, GAIN = -1.0, TI = T#10s ER = -40, LMN rises from 0 to +40 over TI
Steady state Run for 5 × TI PV settles within ±2 °C of SP; LMN_PER stabilizes
Anti-windup Force SP = 0 (far below PV) LMN_PER saturates at 27648; integral freezes
Step response Step SP 30 → 50 → 30 PV tracks with overshoot < 10 %; settling time < 4 × TI
Disturbance rejection Step FB102.PV_OFF by +10 LMN rises; PV returns to SP within 3 × TI
Manual transition Toggle MAN_ON TRUE → FALSE Bumpless transfer; no LMN step at switchover

Common Faults and Field Pitfalls

  • Wrong OB35 cycle time. The CYC_TIM input on FB58 must match the OB35 runtime period. Default OB35 is 100 ms; changing OB35 to 200 ms without updating CYC_TIM doubles the integral contribution per scan and destabilizes the loop.
  • Default GAIN after copy/paste from sample project. The STEP 7 sample projects ship with GAIN = +1.0 for heating. If the project is reused for cooling without changing GAIN, the controller will saturate cold.
  • Excessively large negative gain. |GAIN| > 50 saturates LMN on the first scan. Combined with TD, derivative kick can drive LMN_PER to the rail instantly.
  • Sign of the analog output. The SM332 4–20 mA channel is unipolar; LMN_PER < 0 is clamped to 0 mA. If your normalized LMN is allowed to go negative (e.g., inverted scaling), the valve will slam shut instead of producing a positive flow.
  • PV sign inversion. A reversed thermocouple or a polarity-flipped transmitter makes PV rise when temperature falls. The PID algorithm treats this as a heating loop even with negative GAIN. Verify with an ice-bath (0 °C) calibration.
  • FB58 not called every cycle. Placing FB58 in OB1 instead of OB35 produces wrong CYC_TIM and erratic integral action.
  • GAIN overwritten by HMI. HMI tag lists sometimes map an unsigned integer HMI variable to the REAL GAIN, rounding negative values. Confirm the HMI tag type is REAL (32-bit IEEE-754), not INT or WORD.
  • Ti and Td swapped. TI is the integral (reset) time; TD is the derivative time. In S7 TIME, T#2S is 2 seconds. Mistakenly swapping labels causes derivative kick without integration, which looks like fast oscillation that does not settle.

Troubleshooting Matrix

Symptom Likely Root Cause Corrective Action
LMN_PER stuck at 27648 even when PV at SP Integral windup; TI too small; GAIN sign wrong (PV < SP when expected PV > SP) Increase TI ≥ T#5s; verify GAIN polarity against PV/SP
LMN_PER stuck at 0 even when PV > SP Positive GAIN with PV > SP; analog output wiring missing; MAN_ON = TRUE with MAN = 0 Set GAIN negative; verify PQW assignment; release manual mode
LMN_PER oscillates wildly |GAIN| too large; TI too small; derivative noise Reduce |GAIN| by 30 %; double TI; add TM_LAG = T#2s
PV climbs above SP even with negative GAIN Thermocouple polarity reversed; FC105 scaling inverted Reverse TC leads; inspect HI_LIM/LO_LIM polarity
Sustained oscillation around SP Loop gain margin too low Reduce |GAIN| by 30 %; double TI
PV stuck at high limit; LMN_PER = 0 PV scaling wrong (raw 27648 never reaches FB58); GAIN overwritten to 0 Trace PV path to FB58; confirm DB1.DBD36 is non-zero negative
Controller unexpectedly in manual HMI toggled MAN_ON; program logic forced MAN_ON = TRUE Audit HMI tag list for MAN_ON; verify OB1 logic
Auto tune aborts with STATUS = 5 Process noise too high; asymmetry in heating/cooling response Reduce thermocouple noise; warm up process before tuning

FB58 versus TIA Portal PID_Compact and PID_Temp

Engineers migrating from STEP 7 Classic to TIA Portal have access to PID_Compact (FB 1130) and PID_Temp (FB 1131) in the "PID Control" library. These TIA Portal blocks offer the same closed-loop behavior with additional features: a structured commissioning editor, automatic controller tuning, integrated simulation, and dedicated "Retain.Ctrl.InvertControl" and "Retain.Ctrl.Gain" tags. For new S7-1500 projects, prefer PID_Compact or PID_Temp; FB58 remains the canonical choice for S7-300/400 installations running STEP 7 V5.5.

The negative-gain principle applies identically in TIA Portal. PID_Compact offers a GUI checkbox for inverted control action, which internally multiplies the controller output by −1; this is mathematically equivalent to entering a negative gain manually in FB58.

Safety Considerations for DRI Cooling Control

  • Sensor break behavior: on thermocouple break, SM331 typically returns 32767 (overrange). With negative GAIN, FB58 will interpret this as PV > SP → LMN_PER rises to 27648, the nitrogen valve opens fully, and the bed is quenched with maximum flow. Verify with operations whether this is the desired safe direction. If not, route the sensor-break bit to force LMN_PER = 0 or to a safe value.
  • Loss of nitrogen supply: if the pneumatic supply to the actuator fails, the valve defaults to its fail-safe position (fail-open or fail-closed). Verify the actuator specification; for a fail-closed actuator on a DRI bed, a nitrogen loss will leave the bed uncooled. Add an independent high-temperature interlock in a separate FB or hardwired relay that trips the upstream nitrogen shut-off valve on high temperature.
  • Anti-windup interaction: if the analog output saturates and the controller is left in auto, the integral term will keep accumulating. When the disturbance clears, the controller will swing in the opposite direction with a large overshoot. Use FB58's built-in anti-windup (P-bound & I-bound clamping via LMN_HLM / LMN_LLM) or implement external clamping on the LMN_PER value.
  • OB35 overrun: if OB35 is starved (e.g., due to a long-running OB1), the FB58 instance is not called regularly, and the controller effectively runs at a slower cycle. Monitor OB35 cycle time with SFC26 and alarm on overrun.

Field Commissioning Tips

  • Start in manual mode. Set FB58.MAN_ON = TRUE and FB58.MAN = 50.0 to drive the nitrogen valve to 50 %. Confirm the plant responds (temperature falls). This validates the plant direction-of-action before any closed-loop tuning.
  • Document the gain sign explicitly on the HMI faceplate. Show both the numeric GAIN and a derived BOOL COOL_MODE := GAIN < 0.0 so operators see "DIRECTION: COOL" rather than a confusing minus sign.
  • Rate-limit LMN_PER. Implement a separate FB that compares last LMN_PER to new LMN_PER and clamps the change to ±10 % per second. This prevents the nitrogen valve from slamming on a step disturbance.
  • Watch the saturation flags. FB58 exposes LMN_HLM and LMN_LLM in its static area. Use them to fire HMI alarms and to inhibit integration in any upper-level supervisory logic.
  • Bumpless transfer. FB58's internal initialization tracks the manual value when MAN_ON transitions to FALSE; verify with a step test. If a step appears, the internal initialization is not engaged — check that COM_RST is FALSE and that the MAN input is held at the last LMN_PER before transition.
  • Save the tuned DB. After successful auto tune, save the instance DB to the offline project so a CPU download does not overwrite the tuned parameters with FB58 defaults.

Reference Documentation

What sign should GAIN have for a cooling process in Siemens FB58?

Set GAIN to a negative REAL value. For a cooling loop the process value decreases when the manipulated variable rises, so the algorithm must invert the sign of the error-driven proportional output. Typical magnitudes for temperature loops are 0.5 to 10.0; start at -0.1 and increase during tuning.

Where is the GAIN parameter in the FB58 instance DB?

In the standard FB58 (PID_TC) shipped with STEP 7 V5.5 PID Control Blocks V5.x, GAIN is at DBD 36. Some customized library variants place GAIN at DBD 166. Always verify by opening FB58 in the editor and reading the Interface tab, not from external listings.

Why does LMN_PER stay at zero even though I set a negative GAIN?

Verify four conditions: (1) GAIN in DB1.DBD36 is actually negative, not zero or positive; (2) ER in DB1.DBD60 is negative (which requires PV > SP, so confirm scaling); (3) MAN_ON is FALSE and MAN is 0.0; (4) LMN_PER is wired to the analog output process image (e.g., PQW 272). If ER is positive, your PV scaling is inverted.

How do I run the built-in auto tuning on FB58?

Open the FB58 instance DB online, set the static flag CONT_TUNE to TRUE, and watch the STATUS output. When STATUS returns to 0, tuning is complete and the new GAIN, TI, and TD values are written back to the instance DB. Reset CONT_TUNE to FALSE after completion. Auto tune swings LMN_PER across its full range, so verify mechanical and process limits first.

Can I use FB102 to simulate a cooling process with negative GAIN on FB58?

Yes. Either set FB102.GAIN to a negative value (reverse-acting plant) OR invert the LMN signal between FB58 and FB102 by computing SIM_LMN_PER = 27648 - LMN_PER before driving FB102.LMN_IN. The first approach is cleaner because it keeps the manipulated variable scaling direct. Default FB102.GAIN is positive and represents a heating plant.

What cycle time must I configure for FB58 in OB35?

FB58 uses the CYC_TIM input to compute integral and derivative contributions correctly. The default is T#100ms, which matches the default OB35 runtime. If you change OB35 to a 200 ms cycle, update FB58.CYC_TIM to T#200ms; otherwise the integral term effectively doubles and the loop destabilizes.

Back to blog