Configuring CONT_S FB42 DISV for Feed-Forward Temperature Control

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

Configuring CONT_S FB42 DISV for Feed-Forward Temperature Control

1. Overview

Feed-forward control is a deterministic compensation path that runs in parallel with the closed-loop PID regulator. Instead of waiting for the process variable to deviate from setpoint and react with a corrective output, feed-forward measures a known disturbance directly, computes the required manipulated variable offset, and applies it immediately. The closed-loop PID then only has to deal with the residual modelling error and with disturbances the feed-forward path cannot see.

In a SIMATIC S7-300 / S7-400 controlled by STEP 7 V5.x, the standard continuous PID block is FB42 CONT_S from the Standard PID Control library. CONT_S exposes a dedicated input pin called DISV (Disturbance Variable) that is intended exactly for this kind of feed-forward injection. This article documents how to wire a second PT100 inlet sensor into DISV, how the signal is processed inside the block, and how to tune the feed-forward path against the closed loop so that a heat-exchanger process with a modulating water valve holds its product temperature near setpoint (around 70 degC) even when the inlet water temperature swings.

Source material for the CONT_S block behavior and pinout is the Siemens SIMATIC Standard PID Control manual, available as PDF on Siemens Industry Online Support.

2. CONT_S (FB42) Block Architecture

FB42 CONT_S is a continuous controller with a pulse-output option that can be configured as a pure continuous (analog output) controller, a pulse controller with a fixed period, or a step controller for motor-driven final control elements. For a temperature loop driven through a 4-20 mA proportional valve, the continuous configuration with PULSE_TM = FALSE is the correct choice.

Table 1 - CONT_S FB42 input pins relevant to feed-forward
Input Type Meaning
SP_INT REAL Internal setpoint in % (normalized engineering, typically 0.0-100.0 or scaled to engineering units)
PV_IN REAL Process variable (return temperature) - either in % or engineering units, selected by PV_FAC and PV_OFF
DISV REAL Disturbance variable - added directly to the PID output, range -100.0 to +100.0 (%)
MAN REAL Manual manipulated variable, used when MAN_ON = TRUE
LMN_FAC REAL Factor applied to manipulated variable
LMN_OFF REAL Offset added to manipulated variable
DEADB_W REAL Dead band width on the error signal
GAIN REAL Controller gain (proportional action)
TI TIME Reset time (integral action, T_i)
TD TIME Derivative time (T_d)
SAMPLE_T TIME Block sampling time, must match the calling OB cycle

The signal flow inside CONT_S is roughly:

  1. The error e = SP_INT - PV_IN is computed (or e = SP_INT - PV after scaling).
  2. The PID algorithm produces a raw manipulated variable LMN_PID in percent.
  3. The output is passed through LMN_FAC and LMN_OFF yielding LMN_PRE.
  4. DISV is added: LMN = LMN_PRE + DISV (in % units).
  5. The result is clipped to the limits LMN_HLM and LMN_LLM and written to LMN.

The crucial point is step 4: DISV is added after the PID action and before output limiting. This means DISV directly offsets the valve position request, independent of whether the loop is in auto or manual.

Important: DISV is in percent of valve travel, not in engineering units. If you scale the inlet temperature in degC, you must convert it to a 0-100 % offset that matches the percent scale the controller uses internally.

3. The Process: Heat Exchanger with Closed Hot-Water Loop

The system is a tank that contains a closed circuit of warm water. The water enters through a hot-water inlet, flows through piping inside the tank, and leaves through a hot-water return. A second, independent flow path runs through a coil or pipe bundle inside the tank: fertilizer (the actual product) flows through this coil, picks up heat from the surrounding warm water, and exits as heated fertilizer.

Two sensors are available:

  • PT100 in the hot-water return - the existing control PV. This represents the temperature of the warm water after it has lost some energy to the fertilizer. Holding this temperature stable keeps the heat-transfer rate stable.
  • PT100 in the hot-water supply (planned) - the inlet temperature of the warm water. This is the disturbance variable. The boiler upstream of the loop does not hold a perfectly constant supply temperature, and the supply temperature is the dominant measurable disturbance to the loop.

The final control element is a motorised proportional valve (modulating, not on/off) on the hot-water supply line, driven by a 0-100 % analog output. Setpoint is approximately 70 degC on the return sensor.

4. Feed-Forward Control Theory

Classical feed-forward decouples the controlled variable from a measurable disturbance by inverting the static process gain. If a change of delta_D in the disturbance D causes a steady-state change of delta_PV = K_pd * delta_D in the process variable, then the manipulated variable MV must be changed by delta_MV = -(1 / K_pd) * delta_D to cancel the effect.

For the heat-exchanger problem the static relationship between supply temperature T_sup and return temperature T_ret is approximately linear around the operating point:

T_ret = a * T_sup + b * q + c

where q is the hot-water flow rate (set by the valve). A rise in T_sup at constant flow drives T_ret up at slope a. Holding T_ret constant then requires the valve to close, i.e. to lower q, by an amount proportional to the rise in T_sup. The feed-forward gain is therefore K_ff = -a * dq / dT_ret evaluated at the operating point.

The key insight from the field discussion is that a static feed-forward of T_sup on its own is not sufficient: when the supply temperature is constant, the derivative of a constant is zero and the feed-forward contribution is zero, which is correct, but if the controller uses a raw feed-forward of T_sup directly into DISV, a slow drift in T_sup would still cause a permanent offset that the closed loop has to trim. The cleanest feed-forward signal is therefore the rate of change of the inlet temperature, not its absolute value.

5. DISV Input Behavior on CONT_S

DISV is summed into the output after PID computation. There is no filtering, scaling, or rate limiting inside the block on this input. Whatever value is written to DISV at the start of the cycle is added to the LMN signal. As a consequence, the engineer is fully responsible for:

  • Converting the measured physical disturbance to a percent-valued signal.
  • Applying the correct sign (negative for disturbances that raise the PV, positive for those that lower it).
  • Limiting the rate of change so a noisy sensor does not command violent valve motion.
  • Clamping the sum to a sane range so the controller does not command the valve outside its physical stroke.
Sign convention check: in this process a rise in supply temperature raises the return temperature at constant flow. To keep the return at setpoint, the valve must close (LMN decreases). Therefore the feed-forward component of DISV must be negative when the inlet temperature is rising, i.e. DISV_ff = -K_ff * dT_sup/dt.

6. Calculating the Feed-Forward Signal

The rate of change of the inlet temperature can be approximated in discrete time as a backward difference:

dT_sup / dt approx (T_sup(n) - T_sup(n-1)) / T_s

where T_s is the controller cycle time (default OB35 = 100 ms). The feed-forward contribution to DISV in percent of valve travel is then:

DISV_ff(%) = -K_ff * (T_sup(n) - T_sup(n-1)) / T_s

with K_ff in units of % valve travel per (degC per second). A first estimate of K_ff can be obtained by stepping the supply temperature and observing the steady-state change in valve position the closed loop produces; that closed-loop valve motion divided by the supply-temperature step rate gives an order-of-magnitude starting point.

The following STEP 7 STL snippet shows the calculation in the OB35 cycle, before calling FB42:

// OB35 - 100 ms cycle, feed-forward calculation for CONT_S feedforward path
// Inputs:  IW 100  - PT100 supply temperature in 0.1 degC (raw 0-27648 from AI)
//          IW 102  - PT100 return temperature in 0.1 degC (raw 0-27648 from AI)
// Outputs: DB42.DBD 24 (DISV) - already declared as input to FB42 instance
//          MD 200 - last-cycle supply value for derivative

      L     IW    100                 // load current T_sup, scaled in 0.1 degC
      ITD                            // integer to double integer
      DTR                            // double integer to real
      T     MD    204                // T_sup_now (REAL)

      L     MD    200                // T_sup_last
      -R                              // delta = T_sup_now - T_sup_last
      L     1.000000e+002            // T_s = 100 ms = 0.1 s
      /R                              // dT/dt in 0.1 degC / s
      L     3.000000e+000            // K_ff = 3.0 %/((0.1 degC)/s) - tune this
      *R                              // gain
      NEG_R                           // negative sign: rising T_sup closes valve
      T     MD    208                // DISV_ff in %

      L     MD    204
      T     MD    200                // shift T_sup_now into T_sup_last for next cycle

// Add anti-alias deadband on derivative to suppress PT100 quantisation noise
      L     MD    208
      ABS
      L     5.000000e-001            // 0.5 % deadband
      >R
      JC    APPL
      L     0.000000e+000
      T     MD    208
APPL: L     MD    208
      T     DB42.DBD    24            // write into DISV of FB42 instance

Key implementation rules:

  • All arithmetic is in REAL. Use ITD + DTR for the AI conversion, do not truncate to INT.
  • The cycle time used in the division must be in seconds, not milliseconds, to keep K_ff in intuitive units.
  • Initialise MD 200 to the current value at startup so the very first call does not generate a huge derivative from zero.
  • Clamp the final DISV to a sensible band, e.g. -20 % to +20 %, to prevent the feed-forward path alone from slamming the valve to a limit.

7. OB35 Sampling and Timing

FB42 CONT_S must be called in a cyclic interrupt OB. OB35 is the conventional choice, with a default cycle of 100 ms configured in HW Config under CPU Properties - Cyclic Interrupts. For a thermal process with time constants on the order of tens of seconds to minutes, 100 ms is well below the process dynamics and is appropriate.

Table 2 - Recommended SAMPLE_T settings on CONT_S
Calling OB Cycle SAMPLE_T input Comment
OB32 500 ms T#500MS Use for slow thermal loops, reduces CPU load
OB35 100 ms T#100MS Default and recommended for this application
OB38 10 ms T#10MS Too fast; derivative amplifies PT100 noise

Configure SAMPLE_T in the instance DB to match the OB cycle exactly. Mismatched SAMPLE_T is a common commissioning error and it changes the effective integral and derivative action: setting SAMPLE_T shorter than the actual cycle speeds the controller, setting it longer slows it down.

8. Implementation in STEP 7

Place the instance of FB42 in a dedicated DB (e.g. DB42) and call it from OB35. In the instance DB confirm the following configuration bits:

Table 3 - CONT_S configuration inputs
Parameter Value Reason
CYCLE TRUE Update LMN every call
SP_TRK TRUE Track setpoint during manual mode
PULSE_TM FALSE Continuous output to analog module
I_IT_ON TRUE Enable integral action
DPDT_ON FALSE (initially) Disable derivative on error - the feed-forward derivative is on the disturbance, not on the setpoint
DEADB_W 0.0 (initially) Add a small deadband (e.g. 0.5 degC) after tuning if the valve chatters
LMN_HLM 100.0 Full valve opening
LMN_LLM 0.0 Full valve closing
PV_FAC 1.0 Use scaled engineering units in PV path
PV_OFF 0.0 No offset on PV path

Wire the AI inputs as follows:

// FB42 CONT_S instance call in OB35
      CALL  FB    42
      DB    42
      COM_RST :=FALSE
      MAN_ON  :=FALSE
      SP_INT  :=MD100        // setpoint in engineering units (degC * 10)
      PV_IN   :=MD104        // PT100 return scaled in degC * 10
      DISV    :=MD208        // feed-forward output from OB35 code above
      GAIN    :=0.800        // start value, tune by Ziegler-Nichols or Lambda
      TI      :=T#45S        // start value, tune by observation
      TD      :=T#0S         // no derivative on error
      DEADB_W :=0.0
      PV_FAC  :=1.0
      PV_OFF  :=0.0
      LMN_FAC :=1.0
      LMN_OFF :=0.0
      LMN_HLM :=100.0
      LMN_LLM :=0.0
      SAMPLE_T:=T#100MS
      LMN     :=QW200        // 0-100 % valve command on analog output
      LMN_PER :=             // not used, pulse output disabled
      QLMN_HLM:=M250.0
      QLMN_LLM:=M250.1
      PV      :=MD300        // read-back of scaled PV
      ER      :=MD304        // read-back of error signal

9. Tuning Procedure

  1. Disable feed-forward first. Set MD 208 = 0 in OB35 so the closed loop runs without DISV injection. Verify the controller holds the return temperature near setpoint with a stable inlet temperature.
  2. Tune the closed loop with a step test. Drive the supply temperature up by 5 degC using the boiler setpoint, observe the controller reaction. Adjust GAIN and TI until the loop returns to setpoint in 3-5 cycles of overshoot. A conservative starting point for thermal processes is GAIN = 0.5 - 1.5 and TI = 30 - 90 s.
  3. Enable feed-forward at a small gain. Set K_ff = 0.5 and run the same supply-temperature step test. The closed-loop valve correction should be smaller than in step 2.
  4. Increase K_ff in steps of 0.5 and repeat the test. The optimum is reached when the closed-loop correction is no longer visible - the controller barely moves the valve during the supply-temperature step because the feed-forward has already done it.
  5. Watch for valve chatter. If the valve starts hunting, the K_ff is too aggressive for the noise on the PT100. Increase the derivative deadband in the OB35 code from 0.5 % to 1.0 % or apply a PT1 low-pass filter on the T_sup reading with a time constant of 1-2 seconds.
  6. Verify direction. If a supply-temperature step produces a transient in the wrong direction (return temperature drops), the sign of DISV is reversed. Invert the sign in the OB35 code (NEG_R removal or addition).
Safety: Clamp DISV to a maximum of plus or minus 20 % of valve travel during commissioning. The closed loop can compensate for an aggressive feed-forward, but a runaway feed-forward (e.g. from a wiring fault or sensor noise) can drive the valve to a hard limit. A clamped feed-forward degrades gracefully.

10. Verification and Commissioning

Acceptance criteria for the feed-forward path:

  • Step change in supply temperature of 5 degC produces a return-temperature excursion of less than 1.5 degC peak, returning to setpoint within 90 s.
  • Steady-state return temperature stays within plus or minus 0.5 degC of setpoint across the full range of expected supply-temperature variation.
  • Valve does not exceed 80 % or fall below 20 % at the operating point, leaving headroom for control.
  • Removing the feed-forward (setting MD 208 = 0) produces visibly worse return-temperature regulation under the same supply-temperature disturbance - this confirms the feed-forward is contributing.

Add the following HMI tags to the controller instance DB for live monitoring:

  • DB42.DBD 0 - SP_INT (setpoint)
  • DB42.DBD 4 - PV_IN (return temperature)
  • DB42.DBD 24 - DISV (feed-forward offset)
  • DB42.DBD 152 - LMN (final valve command after DISV addition)
  • DB42.DBD 116 - ER (control error, useful for closed-loop diagnosis)

Plot the LMN and the DISV trend together on the HMI during the supply-temperature step test. The DISV trace should be a sharp transient that returns to zero after the step has propagated, and the LMN trace should show a small step at the same time with no slow drift - that confirms the feed-forward is doing the work and the PID integrator stays quiet.

11. Limitations and Edge Cases

Derivative-on-supply noise. A PT100 has a noise floor of a few tens of mK after the AI conversion. Differentiating this noise at 10 Hz gives a meaningful signal only if the underlying process is moving by at least 0.1 degC/s. Below that rate the deadband suppresses the noise. Do not lower the deadband below the AI LSB or the valve will oscillate.

Sensor failure on the supply PT100. If the supply PT100 breaks, the AI will read a saturated value and the derivative will spike, slamming the valve. A watch-dog check should clamp DISV to zero and raise an operator alarm if the raw AI value goes out of range, e.g. below 0 degC or above 150 degC.

Two PT100s on the same return line. In the source process, the engineer considered putting the second PT100 in the supply line for disturbance measurement. This is the correct placement. A second PT100 in the return line would be a redundant measurement, not a disturbance, and would have no useful effect on DISV.

Modulating valve vs. on/off valve. The source thread contains a remark that on/off valves make good PID control difficult. The reference process uses a motorised proportional valve, which is the right choice. With an on/off valve, the feed-forward would still work in principle (the integrator would compensate), but the resulting valve cycling would be unacceptably fast for a motorised final control element.

Reset windup. Because DISV is added to the output, not the error, it does not affect integrator state. This is a feature: the integrator does not wind up from a feed-forward step, and it does not unwind when the feed-forward returns to zero. The integrator is then free to track only the true modelling error.

Process gain sign reversal at very low flow. At very low flow the static heat-exchanger gain can change sign due to thermal short-circuits or condensation effects. The feed-forward gain that was tuned at the operating point may then be wrong at the limit. Always tune at the intended operating point and re-tune if the operating point shifts more than 20 %.

12. FAQ

What does the DISV input on CONT_S FB42 actually do?

DISV is a REAL input in percent that is added directly to the controller's continuous output after the PID calculation and before the output limit. It lets you inject a feed-forward offset that the integrator does not see, so the feed-forward does not wind or unwind the I-term.

Should I use the raw supply temperature or its derivative on DISV?

Use the derivative (rate of change) of the supply temperature. A static raw-temperature feed-forward would push the valve away from the correct position for any supply temperature different from the design point and force the integrator to fight it. The derivative is zero at steady state, so it only acts when the disturbance is actually changing.

How do I compute the derivative of the PT100 signal in STEP 7?

Subtract the previous-cycle value from the current-cycle value, divide by the OB35 cycle time in seconds, and apply a feed-forward gain. Initialise the previous-cycle value to the first valid reading at startup. A small deadband (around 0.5 % of valve travel) prevents sensor noise from translating into valve chatter.

What is the right sign for the feed-forward in this heat-exchanger application?

Negative. A rise in the supply temperature at constant flow drives the return temperature up, so the valve must close to compensate. The feed-forward contribution to DISV must be negative when the supply temperature is rising.

Can DISV be used with the pulse output of CONT_S?

No, in pulse output mode CONT_S drives a digital output with a duty cycle. DISV only adds a continuous offset, so it has no defined meaning when the block is configured as a pulse controller. Use a continuous-output configuration for any application with feed-forward.

What happens if the supply PT100 fails?

A broken PT100 will report a saturated value and the derivative will spike, driving DISV to a hard limit. Add a software watch-dog that zeroes DISV and raises an operator alarm if the raw supply temperature is out of the expected physical range (e.g. below 0 degC or above 150 degC).

Back to blog