How-to
Why FB41 PV_PER and LMN_PER need OB35 and matching CYCLE
Short answer
Connect the S7-300 analog channel word, for example PIW256, to PV_PER and set PVPER_ON := TRUE, then take the output from LMN_PER into PQW256. Call FB41 CONT_C unconditionally from a cyclic interrupt OB such as OB35 and set CYCLE exactly to that OB's configured interval; if OB35 runs every 100 ms, CYCLE := T#100ms. A mismatch makes TI and TD act at the wrong speed.
On this page
- How do I assign the analog input PIW256 to PV_PER?
- How do I send the FB41 output to an analog output word like PQW256?
- What does a working FB41 call look like?
- Why must FB41 run in OB35 and not OB1?
- What value does the CYCLE input need?
- What happens when CYCLE and the OB35 interval disagree?
- How do I connect an operator setpoint to SP_INT?
- How do I commission and verify the FB41 loop?
- Questions asked
The analog side of FB41 CONT_C is wired through its peripheral pins: connect the channel's process-image word, for example PIW256, to PV_PER with PVPER_ON := TRUE, and take the manipulated value from LMN_PER into the analog output word, for example PQW256. Call the block unconditionally from a cyclic interrupt OB such as OB35 — never from OB1 — and set CYCLE to exactly that OB's configured interval, because TI and TD are applied against the time CYCLE claims. Miss that match and the loop integrates at the wrong multiple of its tuned speed, which the worked arithmetic below makes exact. The sections walk the input pin, the output pin, a complete call, the OB choice, the CYCLE value, the mismatch numbers, the setpoint link and a commissioning sequence.
How do I assign the analog input PIW256 to PV_PER? #
Connect the channel's own peripheral address — PIW256 in the worked example — directly to the PV_PER input, and set PVPER_ON := TRUE in the call; that switch makes CONT_C read the periphery word and ignore PV_IN.
PV_PER is a WORD input: it expects the raw periphery integer exactly as the analog module delivers it into the process image. PV_IN expects a REAL and is the path for a value already scaled in the program; with PVPER_ON left FALSE the block ignores PV_PER entirely, and a connected but unselected PIW leaves PV sitting still while the loop controls against nothing. In TIA Portal's CONT_C configuration the documented way to select the periphery format at PV_PER is the Enable I/O check box; classic STEP 7 exposes the same selection as the PVPER_ON parameter at the call.
Confirm the address in the hardware configuration before trusting the example: open the analog input module's properties, read the address configured for the channel wired to the transmitter, and put that exact word on PV_PER. PIW256 comes from one working installation, not from a standard — your hardware configuration decides the number.
How do I send the FB41 output to an analog output word like PQW256? #
Connect LMN_PER directly to the analog output channel's peripheral word — PQW256 in the example — and leave LMN unconnected when you do; the block writes the manipulated value to both, so exactly one of them may drive hardware.
LMN_PER applies the same convention on the output side: the block converts its internal manipulated value back to periphery format for the output channel, so PQW256 delivers the loop's full drive across the channel's rated span on a unipolar output. The REAL output LMN carries the same value in the normalized scale for displays or further logic; if the analog world is fed from a REAL path instead, that path needs its own conversion to output counts, as worked through in Scale a PID real output to analog output counts. Keep LMN_FAC := 1.000000e+000 and LMN_OFF := 0.000000e+000 so the conversion out to LMN_PER stays one-to-one with the internal value.
What does a working FB41 call look like? #
A minimal working call selects the peripheral process value, keeps the P, I and D paths enabled, and declares its time base through CYCLE, which must equal the interrupt OB's configured interval; the STL below shows that pattern with the pin assignments from the sections above.
CALL "CONT_C", DB41
COM_RST := FALSE
MAN_ON := FALSE
PVPER_ON := TRUE
P_SEL := TRUE
I_SEL := TRUE
INT_HOLD := FALSE
I_ITL_ON := TRUE
D_SEL := TRUE
CYCLE := T#100ms
SP_INT := MD0
PV_PER := PIW256
MAN := FALSE
GAIN := 2.000000e+000
TI := T#20S
TD := T#10S
TM_LAG := T#2S
DEADB_W := 0.000000e+000
LMN_HLM := 8.000000e+001
LMN_LLM := 4.000000e+000
PV_FAC := 1.000000e+000
PV_OFF := 0.000000e+000
LMN_FAC := 1.000000e+000
LMN_OFF := 0.000000e+000
I_ITLVAL := 0.000000e+000
DISV := 0.000000e+000
LMN_PER := PQW256
Three lines carry this article's decisions: PVPER_ON := TRUE selects the peripheral process value, CYCLE declares the time base and is valid only while the hardware configuration really schedules OB35 at that interval, and SP_INT := MD0 expects the panel to write a REAL into MD0. MAN_ON := FALSE keeps the block in automatic. I_ITL_ON := TRUE is an initialization setting: while it stays set, the block reloads I_ITLVAL into the integral path on every call and the loop cannot accumulate integral action, so clear it after the first pass.
Why must FB41 run in OB35 and not OB1? #
Call FB41 unconditionally from a cyclic interrupt OB such as OB35 because the block needs a fixed, known interval between executions; OB1 is driven by program size and communication load, has no constant cycle time, and therefore cannot supply a truthful CYCLE value.
The block's timing arithmetic has no clock of its own; it only knows how much time CYCLE says passed since the previous call, so the calling OB must deliver a fixed interval. A conditional call breaks the promise just as badly: in LAD put no contact in front of the CALL, and in STL let no jump skip it. If the loop should run less often, move it to a slower cyclic interrupt OB instead of gating a fast one. The behavior difference between the two OBs is set out on the page describing how timer execution differs between OB1 and an OB35 cyclic interrupt. When you run several loops, calling FB41 and FB42 PID loops in OB35 with one instance DB per bank keeps every loop's states separate.
What value does the CYCLE input need? #
Set CYCLE to exactly the interval configured for the interrupt OB that calls the block: an OB35 set to 100 ms in the hardware configuration takes CYCLE := T#100ms, and a 1 s OB35 takes CYCLE := T#1s.
CYCLE is the block's assumed time since the previous call, and TI, TD and TM_LAG are all applied against that assumed time. The OB's interval is entered per OB in the hardware configuration under the cyclic interrupt settings, and the page on configuring the OB35 cyclic interrupt interval for S7-300 and S7-400 CPUs shows where that time sits. Read the configured value back after the download and set CYCLE equal to it, character for character; the sample call's T#10s is only correct if the OB truly runs at ten seconds, and the next section works out what it costs when it does not.
What happens when CYCLE and the OB35 interval disagree? #
The block applies TI and TD against CYCLE, so a mismatch scales both by the ratio between the setting and the true interval: with CYCLE := T#10s against a ten-times-faster OB, a TI of 20 s acts like 0.2 s, one hundred times faster than tuned.
Worked example with the sample call's numbers — OB35 scheduled every 100 ms, ten calls per second, CYCLE := T#10s, TI := T#20S, TD := T#10S:
- Tuned intent per call: true interval / TI = 0.1 s / 20 s = 0.005 of a full integral step.
- What the block applies per call: CYCLE / TI = 10 s / 20 s = 0.5 — one hundred times more.
- 0.5 / 0.005 = 100, so the integral reaches in 10 s of real time what the tuning intended for 1000 s, and the reset time behaves as 20 s / 100 = 0.2 s.
- TD scales by the same ratio, so the derivative also acts one hundred times too fast.
- The reverse mismatch — OB at 1 s, CYCLE := T#100ms — runs integral action at 0.1 s / 1 s = one tenth of the tuned rate: the loop crawls and the reset time acts like 200 s.
Decision rule: divide the CYCLE setting by the OB's configured interval and divide TI and TD by that same ratio before retuning anything — the loop was never mistuned, its clock was.
How do I connect an operator setpoint to SP_INT? #
SP_INT takes the setpoint as a REAL in the same normalized scale as PV, so connect a 32-bit REAL memory location such as MD0 or DBD0 that the operator panel writes, and set the panel tag to REAL format so both sides interpret the bits the same way.
The storage is 32 bits either way — the block reserves a double word for SP_INT — but those bits mean an IEEE 754 REAL, so a panel tag typed as a raw double-word integer delivers nonsense. The scale of that REAL comes from the process-value normalization: with defaults PV_FAC := 1.000000e+000 and PV_OFF := 0.000000e+000, the block converts PV_PER to percent of the channel's rated span, 0 to 27648 counts on a unipolar input, so SP_INT is in percent of span and 6.000000e+001 is 60 %. Set PV_FAC and PV_OFF to move the loop into engineering units, then type the setpoint, the PV display and the panel tag on that one scale. Decide it once and write it on the loop's faceplate; a percent setpoint entered against a degree-C PV display is the classic silent commissioning error.
How do I commission and verify the FB41 loop? #
Verify the wiring and the time base before the first tuning move, in this order: channel addresses, unconditional call, CYCLE match, PV response, setpoint link, output response, then the timing cross-check.
- Open the hardware configuration and read the analog input channel's address and the analog output channel's address; put those exact words on PV_PER and LMN_PER, substituting your installation's addresses for the example pair if they differ.
- Confirm the CALL sits directly in OB35 with nothing in front of it — no contact in LAD, no jump around it in STL — and that the instance DB belongs to this loop alone.
- Set CYCLE equal, character for character, to the interval configured for that OB in the hardware configuration.
- Clear I_ITL_ON for normal running; TRUE is for the initialization pass only, because it reloads I_ITLVAL into the integral path on every call.
- Go online and move the transmitter across its range; the PV value must track the physical input through the whole span.
- Enter a setpoint from the panel and confirm SP_INT receives the identical REAL value, in the scale you decided above.
- Watch LMN_PER respond to error: the loop must drive toward the setpoint, and if it drives away, flip the sign of GAIN or LMN_FAC to reverse the action.
- If integral or derivative action feels too fast or too slow, divide the CYCLE setting by the configured OB interval and correct TI and TD by that ratio before re-tuning anything.
Decision: FB41 CONT_C runs unconditionally in OB35 with PVPER_ON := TRUE, the input channel's word on PV_PER, the output channel's word on LMN_PER, a REAL the panel writes on SP_INT, and CYCLE identical to the configured interrupt interval — the mismatch arithmetic above is what every one of those five conditions protects. Set the five and the tuning times on the block mean what they say.
Questions asked
Can two FB41 loops share one instance DB?
No. Every CALL of CONT_C needs its own background DB — the example uses DB41 for one loop, and a second loop gets DB42. The instance DB stores that loop's integral accumulator and filter states, so a shared DB lets two loops overwrite each other's integral action and oscillate for no visible reason.
How do I make SP_INT read in engineering units instead of percent?
Scale the process value with PV_FAC and PV_OFF. A 0–20 mA transmitter spanning 0 to 100 °C already lands the defaults in degrees: the normalized 100 % equals 100 °C, so SP_INT := 7.500000e+001 is 75 °C with PV_FAC := 1.000000e+000 and PV_OFF := 0.000000e+000. For a 0 to 250 °C span on the same channel, set PV_FAC := 2.500000e+000 and the setpoint reads directly in degrees.
Can I call FB41 conditionally, for example every second OB35 cycle?
Only if CYCLE equals the true time between executions. A call on every second pass of a 100 ms OB35 executes at 200 ms intervals and needs CYCLE := T#200ms; whatever gates the call, the CYCLE input must match the real gap between two consecutive executions. The safe pattern stays the unconditional call.
What limits the value FB41 writes to LMN_PER?
LMN_HLM and LMN_LLM clamp the manipulated value before either output is written, so the example's 8.000000e+001 and 4.000000e+000 hold LMN and LMN_PER inside 4 to 80 % of the output span. If an output channel never moves beyond those bounds, check the two limits first, because they clamp the automatic output before the periphery conversion.