Overview: Bidirectional DC Drive Speed Control with FB41
The Siemens standard PID block FB41 "CONT_C" from the STEP 7 V5.x Standard Library (folder Standard Library > PID Control Blocks > FB41..FB43) is one of the most widely deployed continuous PID controllers for SIMATIC S7-300 and S7-400 CPUs. It is commonly used to close a speed loop on analog-driven machinery, including DC drives commanded through a +/-10 V speed reference, 4-quadrant armature converters, or analog interface modules such as the 6RA70 series.
When the engineering requirement is a normalized setpoint and actual value in the range -100.0 ... 0 ... +100.0 % of rated speed, with motor rotation direction defined by the sign of the speed demand, FB41's PV_IN, SP_INT, and LMN signals map directly to that range without further conversion inside the block. The integration work is done around the block:
- Scale the raw analog input (e.g., PIW 0..65535) to
-100.0 ... +100.0usingFC105 "SCALE"orFC106 "UNSCALE"on the way out. - Configure
LMN_HLMandLMN_LLMto+100.0and-100.0so the manipulated variable cannot exceed the drive's bipolar speed reference. - Decide whether
LMNdrives the analog output directly, or whether it must be re-scaled byFC106to a different engineering range (e.g., 0..27648 for a unipolar 6RA70 reference). - Tune
GAIN,TI, andTDfor the mechanical time constant of the DC drive / load combination.
The block is suitable for moderately fast processes, but the loop bandwidth of a DC drive speed loop is bounded by the drive's own current-loop bandwidth and the tachogenerator / encoder resolution. Typical commissioning practice is to start with the drive's current loop tuned first, then close the speed loop with FB41.
PID_Compact (V1.x/V2.x/V3.x firmware) or the legacy CONT_C in the legacy block library. Pin mapping and behavior differ — see the migration section at the end of this article.Prerequisites: Hardware, Firmware, and Software
| Item | Requirement / Selection |
|---|---|
| CPU | S7-300 (e.g., CPU 315-2 PN/DP) or S7-400 (e.g., CPU 414-3 PN/DP). FW must support the PID instructions in the Standard Library. |
| STEP 7 | STEP 7 V5.5 SP2 / SP3 or STEP 7 V5.6. TIA Portal V15..V18 for the migration path. |
| Library | Standard Library > PID Control Blocks (FB41, FB42, FB43, FB58, FB59). Located in ...\Step7\S7LIBS\Standard\PID. |
| DC drive | Analog-setpoint DC drive accepting +/-10 V (e.g., Siemens SIMOREG DC-MASTER 6RA70) or a unipolar 0..10 V / 0..20 mA reference with sign derived from a digital output. |
| Speed feedback | Analog tachogenerator (PIW) or incremental encoder (FM 350-1 / FM 350-2 / ET200S 1COUNT) scaled to -100.0 ... +100.0 %. |
| Analog I/O | SM 331 (e.g., 6ES7331-7KF02-0AB0) for input, SM 332 (e.g., 6ES7332-5HD01-0AB0) for bipolar output. |
| Wiring | Shielded twisted pair for the speed reference and tachogenerator; analog ground tied at drive end only. |
| Tools | STEP 7 PLCSIM for offline testing; S7-PCT (Port Configuration Tool) if commissioning through PROFINET. |
Before opening the editor, confirm the CPU firmware version tolerates the cyclic OB1 call. FB41 is designed for use in OB35 (cyclic interrupt) when a deterministic sampling rate is required. Calling it in OB1 with a long cycle time will degrade tuning stability.
FB41 CONT_C Signal Flow and Block Architecture
The internal structure of FB41 is a parallel-form PID with anti-windup, setpoint ramp, dead-band, and output slew limiting. From a programming standpoint, the engineer sees the following input and output pins.
| Pin | Type | Default | Function in a DC drive speed loop |
|---|---|---|---|
SP_INT |
REAL (IN) | 0.0 | Speed setpoint in %. Wire to your operator panel or recipe value normalized to -100.0 ... +100.0. |
PV_IN |
REAL (IN) | 0.0 | Process variable, the actual speed. Wire to the FC105-scaled tachogenerator reading. |
PV_FAC |
REAL (IN) | 1.0 | Gain on PV. Use only if the input scaling is asymmetric. |
PV_OFF |
REAL (IN) | 0.0 | Offset on PV. Use for trim calibration (e.g., 0.5 % drift compensation). |
DEADB_W |
REAL (IN) | 0.0 | Deadband width. Recommended 0.5..1.0 % for DC drives to suppress jitter from the tachogenerator ripple. |
GAIN |
REAL (IN) | 2.0 | Proportional gain (dimensionless, on a per-cent basis). |
TI |
TIME (IN) | T#20s | Integral action time. For DC drive speed loops, typically T#0.5s..T#5s. |
TD |
TIME (IN) | T#0s | Derivative action time. Often T#0s for the outer speed loop; the derivative is on the error, so tachogenerator noise is amplified. |
LMN_HLM |
REAL (IN) | 100.0 | High limit on LMN. Set to +100.0 for bipolar drives. |
LMN_LLM |
REAL (IN) | 0.0 | Low limit on LMN. Set to -100.0 for bipolar drives. |
LMN |
REAL (OUT) | — | Manipulated variable. The speed reference sent to the drive. -100.0 ... +100.0. |
LMN_FAC |
REAL (IN) | 1.0 | Output gain (e.g., to remap 0..100 % to 0..27648). |
LMN_OFF |
REAL (IN) | 0.0 | Output offset. |
I_ITVAL |
REAL (OUT) | — | Internal integrator value (use for bumpless transfer). |
DISV |
REAL (IN) | 0.0 | Disturbance feedforward. Wire the load torque estimate here if available. |
MAN, MAN_ON
|
REAL / BOOL | — | Manual mode interface for hand operation. |
For a continuous DC drive speed loop, the recommended signal chain is:
-
SP_INT← operator panel / recipe (REAL,-100..+100). -
PV_IN← output ofFC105scaling PIW to-100..+100%. -
LMN→ either a direct bipolar analog output (SM 332 in bipolar range) or the input ofFC106if the drive is unipolar with a separate digital direction signal.
Input Signal Scaling: FC105 for -100% to +100% Engineering Units
FC105 ("SCALE") converts an integer analog input word (PIW) into a real engineering value across a defined bipolar range. For a speed feedback signal that should land on -100.0 % ... +100.0 %:
- Set
HI_LIM = 100.0 - Set
LO_LIM = -100.0 - Set
BIPOLAR = TRUE(the input range is bipolar +/-27648) - Wire
IN = PIWxxx,OUT → FB41.PV_IN
A typical call looks like the following in STL or LAD/FBD. LAD/FBD form is shown for clarity.
// In OB35, called every 100 ms:
// SCALE: PIW 288 (6ES7331-7KF02 bipolar) -> MD 200 (REAL, -100..+100)
// FB41 instance: DB 30 (background)
// SP_INT source: MD 204 (operator)
// LMN target: PQW 290 (6ES7332 bipolar) or FC106 to PQW 290
CALL "SCALE"
IN := PIW 288
HI_LIM := 1.000000e+002
LO_LIM := -1.000000e+002
BIPOLAR := TRUE
RET_VAL := MW 210
OUT := MD 200 // -> FB41.PV_IN
CALL "CONT_C" , DB30
SP_INT := MD 204
PV_IN := MD 200
PV_FAC := 1.0
PV_OFF := 0.0
DEADB_W := 0.5
GAIN := 1.2
TI := T#2s
TD := T#0s
LMN_HLM := 100.0
LMN_LLM := -100.0
DISV := 0.0
MAN := 0.0
MAN_ON := FALSE
LMN := MD 208 // bipolar -100..+100
LMN_FAC := 1.0
LMN_OFF := 0.0
The bipolar FC105 output and the bipolar LMN drive the analog module's bipolar mode. On SM 332, configure the channel as "Voltage +/-10 V" in STEP 7 HW Config, otherwise the output clamps to 0..10 V even though LMN is negative.
LMN is correct in the DB online view but the drive never reverses, the cause is almost always the SM 332 channel being configured as unipolar. Verify with HW Config > Properties > Outputs > Output type = V, Range = +/-10 V. On SM 332 modules in the 6ES7332-5HD01-0AB0 family, the bipolar output is selected via HW Config and a corresponding terminal assignment on the front connector.Step-by-Step: Building the FB41 Instance DB and Wiring
Step 1 — Open the Standard Library
In the SIMATIC Manager, navigate to Libraries > Standard Library > PID Control Blocks. Drag FB41 CONT_C into your S7 program blocks folder. If your project does not yet contain FB100..FB105 and the matching UDTs, copy them in.
Step 2 — Create the Instance DB
Right-click FB41, choose Insert in S7 Program as > Instance DB, accept the default DB number (e.g., DB 30). The instance DB now contains the full CONT_C static data, including SP_INT, PV_IN, GAIN, TI, TD, integrator I_ITVAL, and so on. Mark the DB as non-optimized (classic S7-300 DB; "non-optimized" is automatic).
Step 3 — Create the FB call in OB35
For deterministic execution, place the call in OB35 (cyclic interrupt). On a CPU 315-2 PN/DP, OB35 can be configured to 100 ms by default. The call-out above is the canonical wiring.
Step 4 — Configure the analog input scaling
Use FC105 as shown above, with BIPOLAR = TRUE and LO_LIM = -100.0, HI_LIM = 100.0. If your tachogenerator is unipolar but the drive is bipolar (e.g., the drive reverses internally from a digital direction signal), use BIPOLAR = FALSE and a separate polarity bit to add the sign to the scaled value.
Step 5 — Wire the LMN to the drive
For a bipolar drive, route LMN directly to PQW in HW Config bipolar mode. For a unipolar drive with digital direction, call FC106 ("UNSCALE") to remap -100..+100 → 0..27648 and combine with a Q-bit direction: Q_negative = LMN < 0.0, ABS(LMN) → PQW.
Step 6 — Set LMN_HLM / LMN_LLM
Set both limits so that the integrator cannot run away into the saturation region of the drive. For a 4-quadrant drive accepting +/-10 V with a rated top speed of 100 %, use LMN_HLM = 100.0 and LMN_LLM = -100.0. If the speed reference is intentionally limited to +/-80 % of rated, set LMN_HLM = 80.0, LMN_LLM = -80.0.
Step 7 — Add operator enable and fault handling
The integrator can only stop accumulating if the loop is closed. A common fault is the FB41 call being bypassed when the drive trips, leaving the integrator railed. Add the following safety logic before the FB41 call:
// Drive OK and run enable, otherwise force PV_IN = 0.0 to bleed the integrator
// and zero LMN to ramp the drive down.
A "Drive_Ready"; // OK bit from drive
A "Run_Enable"; // Operator enable
= #Loop_Active;
// If loop is inactive, replace PV_IN with SP_INT to avoid error accumulation
// and force LMN to 0.0 externally by switching to MAN mode.
Use MAN_ON = TRUE, MAN = 0.0 when the loop is inactive. The PID is then a pure track-and-hold with anti-windup behavior.
Tuning the PID Branch: GAIN, TI, TD for a DC Drive
For a separately excited DC drive (e.g., SIMOREG 6RA70) the speed loop is typically the outer loop of a cascade; the inner current loop is closed by the drive itself at a bandwidth of 100..200 Hz. The mechanical plant, expressed in normalized speed as a function of torque, is a first-order lag with a time constant equal to the mechanical time constant of the load, T_mech = J · ω_n / M_load.
A practical starting-point set is:
| Parameter | Value | Reasoning |
|---|---|---|
GAIN |
0.8 .. 1.5 | Per-cent gain. The plant gain from % torque to % speed is 1/(s · T_mech) for the integrated motor+load. |
TI |
T#0.5s .. T#5s | Integral action time. Set to approximately 0.5..1.0 × T_mech of the mechanical system. For a small servo with T_mech ≈ 0.2 s, use T#0.1..0.3s; for a large winder, T_mech ≈ 5..10 s, use T#3..5s. |
TD |
T#0s | Derivative on the error is rarely useful in a speed loop. The tachogenerator noise is amplified. If needed, put a first-order filter on PV_IN instead. |
DEADB_W |
0.3 .. 1.0 % | Suppresses steady-state jitter caused by the tachogenerator ripple and the FB41 floating-point resolution. Too high a deadband causes a static error. |
Use Ziegler-Nichols open-loop step response as a starting point:
- With
TI = T#100s(effectively integral off) andTD = T#0s, setGAIN = 1.0. - Apply a small
SP_INTstep (e.g.,0 → 20 %). - Record the open-loop speed response. Measure the apparent time constant
T_pand the steady-state plant gainK_p = ΔPV/ΔLMN. - Set
GAIN ≈ 0.5 / K_p,TI ≈ T_p,TD = 0. - Close the loop and fine-tune for a critically damped response with a settling time of 3..5 × T_mech.
Output Limiting, Anti-Windup, and 4-Quadrant Drive Hand-Off
The two most important practical features of FB41 for a DC drive application are the LMN limits and the internal anti-windup. Setting LMN_HLM = LMN_LLM to asymmetric values is a common way to clamp a drive that should never reach 100 % even in error conditions.
For a winder/unwinder, the limit is asymmetric: a winder that is fed web from a master roll should be able to go to 110 % of rated speed for a short period to keep tension, but not below 0 %; the controller operates only in the positive quadrant. The same FB41 instance with LMN_HLM = 110.0, LMN_LLM = 0.0 handles this, and the drive is unipolar.
Anti-windup inside FB41 freezes the integrator when LMN is saturated. This is critical when the loop is opened, e.g., during a tacho loss. Without anti-windup, the integrator keeps accumulating SP_INT - PV_IN until the controller is re-engaged, and the output then jumps to the limit for an extended time. With the default FB41 configuration, anti-windup is automatic — verify by stepping SP_INT to a value above LMN_HLM and observing that I_ITVAL stops changing while LMN is clamped.
Bumpless transfer
To switch from manual to automatic mode without bumping the drive, FB41 supports MAN and MAN_ON. When MAN_ON = TRUE, the LMN tracks MAN and the integrator is forced to follow SP_INT - PV_IN = (MAN - PV_IN)/GAIN. To make a hand-off:
- Set
MAN = LMN(read from the previous automatic output). - Set
MAN_ON = TRUE. - Wait at least one OB35 cycle.
- Set
MAN_ON = FALSE. The integrator is already aligned, so the output is unchanged.
Without this procedure, the drive will "kick" on a manual-to-auto transition because the integrator starts at zero.
Bidirectional Setpoint Handling and Error Polarity
A DC drive running in 4-quadrant mode with a bipolar speed reference has a sign convention that the engineer must make consistent across the program:
-
SP_INT > 0→ forward direction, positive speed demand. -
SP_INT < 0→ reverse direction, negative speed demand. -
PV_INmust follow the same sign convention: a positivePV_INmeans actual forward rotation.
If the tachogenerator is wired in reverse (negative voltage on forward rotation), either swap the field leads in the drive or invert the sign in the program. The simplest place is in the FC105 call: LO_LIM = +100.0, HI_LIM = -100.0, with BIPOLAR = TRUE. FC105 then outputs the sign-inverted value.
An engineer will frequently see this problem manifest as a positive feedback (runaway) when the loop is first closed. The classic symptom is the drive accelerating to the limit immediately, the integrator racking up against LMN_HLM, and the speed never settling. The fix is to invert the sign of either the feedback (tachogenerator leads) or the output, not to lower the gain. Lowering GAIN in this condition will not stop the runaway — only the polarity fix will.
Verification: Loop Monitoring, Trend, and Acceptance Test
After the program is downloaded to the CPU, perform this sequence to confirm the loop is correct:
-
Open-loop verification: Force
MAN_ON = TRUE, setMANto0, +20, +50, +100, +50, 0, -20, -50, -100, -50, 0 %in steps. Confirm with a hand tachometer or the drive's own display that the actual speed is linear withMANand the sign is correct. -
Closed-loop step test: Set
MAN_ON = FALSE,SP_INT = 0, wait for the drive to settle. Then apply a step0 → +20 %. Observe the rise time, overshoot, and settling. A well-tuned loop overshoots < 10 % and settles in 3..5 × T_mech. -
Direction reversal: Apply a step
0 → -20 %and confirm the drive reverses without sustained oscillation. If oscillation is present, increaseTIor reduceGAIN. - Disturbance rejection: Apply a load step (e.g., engage a brake) and confirm the speed returns to setpoint within 2..3 × T_mech.
-
Limit clamping: Set
SP_INT = 150 %and confirm LMN clamps atLMN_HLMandI_ITVALstops growing. -
Anti-windup recovery: Drop
SP_INTto0 %and confirm the loop responds immediately, not after a long delay caused by a saturated integrator.
Use a curve recorder on FB41's monitor screen to plot SP_INT, PV_IN, and LMN simultaneously. The variables are visible in the instance DB.
Troubleshooting Matrix
| Symptom | Probable Cause | Diagnostic | Corrective Action |
|---|---|---|---|
| Drive runs to positive limit immediately on loop close | Sign of PV_IN inverted relative to SP_INT | Force MAN_ON=TRUE, set MAN=+10 %, observe PV sign |
Swap tachogenerator leads OR swap LO_LIM and HI_LIM in FC105 |
| Drive runs to negative limit immediately on loop close | Same as above with opposite sign | Same procedure with MAN=-10 %
|
Same as above |
| Output saturated at LMN_HLM, PV never reaches SP | LMN_LLM = 0, plant is unidirectional, plant cannot track the setpoint direction | Inspect LMN limits and plant limits (drive direction) | Recheck whether unipolar or bipolar configuration is correct; if unipolar, ensure SP is always positive |
| Strong oscillation, period of 2..3 s | GAIN too high or TI too short | Halve GAIN, double TI, retest | Retune via Ziegler-Nichols |
| Slow response, long settling time | TI too long, plant is sluggish | Halve TI, retest | Continue halving until limit cycle appears, then double |
| Output jumps on manual-to-auto transition | I_ITVAL not aligned with previous MAN | Online: read I_ITVAL before and after switch | Implement the bumpless transfer procedure in OB35 |
| PIW reads correctly in online monitor but FB41 does not see it | PIW is updated only at the end of OB1, FB41 is in OB35; the input is read at the beginning of OB35 | Cross-check by using PIW directly in the FB41 input | Move FC105 into OB35 as well, or use a temporary variable updated in OB1 |
| LMN reaches LMN_HLM but PV_IN does not reach SP_INT | Tacho is missing or drive is in current limit | Check the drive's current readout and tacho feedback | Lower SP to confirm current limit; check tacho wiring |
| Bipolar SM 332 output clamped to 0..10 V | HW Config output type set to unipolar | Inspect HW Config > Properties > Outputs | Change to V, range +/-10 V |
| Heavy jitter on PV_IN | Tachogenerator ripple, EM noise | Scope the PIW raw value | Increase DEADB_W; add a PT1 filter on PV_IN via FC; check shield grounding |
| FB41 call returns SF (system fault) on the CPU | Invalid TIME format, OB35 not present, instance DB overwritten | CPU diagnostic buffer | Use T#2s format, not 2000 (ms); restore DB; confirm OB35 is loaded |
Migration Notes: FB41 vs TIA Portal PID_Compact / CONT_C
On a TIA Portal S7-300/400 to S7-1500 migration path, the equivalent function block is PID_Compact (V1.x in TIA V13, V2.x in TIA V14/V15, V3.x in TIA V16..V18). Pin mapping for the speed loop:
| FB41 pin | PID_Compact equivalent |
|---|---|
SP_INT |
Setpoint (input on the function block) or Config.SetpointValue on the HMI tag interface |
PV_IN |
Input parameter; for analog input PER, use Input_PER
|
GAIN, TI, TD
|
Retain.CtrlParams.Gain, Retain.CtrlParams.Ti, Retain.CtrlParams.Td
|
LMN_HLM, LMN_LLM
|
Config.OutputScaling.UpperPointIn / LowerPointIn |
LMN |
OutputValue (REAL) or OutputPER (INT) for direct analog output |
DEADB_W |
Retain.CtrlParams.Deadband |
MAN, MAN_ON
|
ManualEnable + ManualValue
|
For an S7-1500 controller with a 6RA70 drive, the migration of a STEP 7 V5.x FB41 program into a TIA Portal project is supported by the porting tool, but field engineers should expect to re-tune. The PID_Compact block includes an auto-tuning function that, after a single step, will compute a new starting GAIN, TI, TD. The result is usually a good baseline but not a final tuning.
Field-Commissioning Checklist
- Confirm hardware configuration in HW Config: SM 331 bipolar, SM 332 bipolar, tacho on channel 0.
- Confirm FB41 and FC105/FC106 are loaded from the Standard Library in the S7 program.
- Place FB41 in OB35 with cycle time = 100 ms (default).
- Set
LMN_HLM = +100.0,LMN_LLM = -100.0. - Set
DEADB_W = 0.5 %. - Set
GAIN = 1.0,TI = T#2s,TD = T#0s. - Open-loop verification with MAN_ON = TRUE.
- Polarity check: positive
SP_INT→ positivePV_INat steady state. - Closed-loop step test 0 → +20 %.
- Tune to spec.
- Document the final
GAIN,TI,TD,DEADB_W, andLMNlimits in the drive's commissioning record.
Frequently Asked Questions
Why does my FB41 output jump to 100 % on a small setpoint step and not decay as the trend shows?
The PID trend in your reference is theoretical; FB41 with TI set correctly will show a fast rise to a peak followed by exponential decay back to the setpoint. A true step to 100 % output with no decay indicates the integrator is saturated, the plant is open, or the polarity is wrong. Reduce SP_INT to a small step and confirm the decay is visible on a trend.
Can I use FB41 with a unipolar DC drive and a digital direction bit?
Yes. Set LMN_LLM = 0.0, LMN_HLM = 100.0 for one direction. For four-quadrant behavior, the engineer can either use a bipolar drive (preferred, single reference signal) or wire two FB41 instances with LMN gated by a direction interlock. The bipolar approach is simpler and avoids the deadband at zero.
What is the difference between PV_FAC / PV_OFF and the FC105 LO_LIM / HI_LIM scaling?
PV_FAC and PV_OFF apply an additional linear transform inside FB41 after the FC105 conversion: PV_used = PV_FAC * PV_IN + PV_OFF. Use FC105 for the primary scaling from PIW to engineering units and use PV_FAC/PV_OFF only for small calibration trim. Mixing both will make the loop tuning harder to track.
Does FB41 support automatic anti-windup?
Yes, FB41 has built-in anti-windup. When LMN reaches LMN_HLM or LMN_LLM, the integrator is frozen automatically. You can verify this by monitoring I_ITVAL in the instance DB while LMN is clamped — the value should remain constant.
What OB should I call FB41 in?
Use OB35 (cyclic interrupt) for deterministic sampling. Calling FB41 in OB1 will give a variable cycle time (depending on user program length), which is poor for PID stability. Typical OB35 periods: 100 ms for slow speed loops, 20..50 ms for high-bandwidth servo speed loops, 10 ms for current-loop-equivalent applications.
Can I replace FB41 with PID_Compact in an existing S7-300 project?
Not directly. PID_Compact is a TIA Portal block; on a STEP 7 V5.x S7-300, the equivalent is FB41/FB58/FB59 in the Standard Library. To migrate to PID_Compact, the S7-300/400 project must be ported to a TIA Portal S7-1500 project, which is a separate engineering effort and will require re-tuning.