SAMPLE_T in PCS7 INT_P Block: Integration Time Explained

David Krause15 min read
Process 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

SAMPLE_T in the PCS 7 INT_P (FB40) Block: Sampling Time, Integration, and Unit Consistency

The INT_P continuous-action integrator from the PCS 7 Library is one of the most frequently used CFCs in any flow totalization, mass-balance, or energy-cumulation loop. Despite its simple appearance, it is also one of the most misunderstood blocks because of a single input named SAMPLE_T. Engineers who manually overwrite this input typically see a runaway totalizer (10×, 100×, or 0.1× the expected value), and the symptom is often misdiagnosed as a faulty meter, bad scaling, or a CFC compile error. In reality the bug is almost always a unit-consistency error introduced by tampering with the sampling time.

This reference explains exactly what SAMPLE_T does inside INT_P, why the CFC compiler normally writes it for you, how the trapezoidal integration formula uses it, and what the correct values are for common OBs and process units. It is written for commissioning engineers working on PCS 7 V8.x and V9.x with the standard PCS 7 Library (APL or older "PCS 7 Library V7.1+ Library" blocks). The principles also apply to S7-300/400 AS stations in STEP 7 with the same FB40 from the PCS 7 Library.

Block identity: In the classic PCS 7 Library (the one shipped before the APL rework), the continuous integrator is FB40, instance DB is generated automatically by CFC, and the block icon is INT_P. In the current Advanced Process Library (APL) the equivalent block is CTRL_PID/INTEG variants; the trapezoidal math described below is identical.

1. Overview: What INT_P Does

INT_P is a digital approximation of a continuous-time integrator:

v(t) = ∫ u(t) dt / TI

Where u is the process input (e.g. instantaneous flow in kg/h), v is the integrator output (e.g. totalized mass in kg), and TI is the integration time constant in seconds. The block outputs a value that grows linearly with the area under the input curve, normalized to the integration time.

In a totalization application the integrator is reset at the end of a batch (e.g. hourly, per shift, or per production run), and the value at the moment of reset is the totalized quantity. The accuracy of that total depends entirely on two things:

  1. How well the discrete-time approximation matches the continuous integral (governed by the integration algorithm — trapezoidal rule in INT_P).
  2. Whether the input is correctly scaled to a per-second rate before integration (governed by SAMPLE_T and TI).

Most totalization errors come from item 2.

2. The SAMPLE_T Input: System Attribute and Automatic Population

SAMPLE_T is an INPUT of type REAL on INT_P. What makes it special is the S7 system attribute assigned to its declaration in the FB source:

SAMPLE_T : REAL := 0.1;   // S7_sampletime := 'true'

The attribute S7_sampletime := 'true' tells the CFC compiler that this parameter should receive the cycle time of the OB in which the block is instantiated. When the user performs a CFC Compile → Charts → Download sequence, the compiler:

  1. Reads the OB1…OB38 cycle time from the CPU hardware configuration (S7-300/400: HW Config → CPU Properties → Cycle/Clock Memory).
  2. Inserts that cycle-time value, in seconds, into the runtime DB at the offset of SAMPLE_T.
  3. Marks the parameter as invisible on the CFC faceplate if S7_sampletime is set, so operators cannot change it from the OS.

The result is that after a successful CFC download, SAMPLE_T on the live block equals the configured OB period. For the standard PCS 7 time slices the expected values are:

OB Typical PCS 7 Use Default Cycle (s) SAMPLE_T After Compile (s)
OB32 Slow totalization / diagnostic 1.000 1.000
OB33 Reserved / spare 0.500 0.500
OB34 Reserved / spare 0.200 0.200
OB35 Cyclic interrupt — default CFC level 0.100 0.100
OB36 Reserved / spare 0.050 0.050
OB37 Reserved / spare 0.020 0.020
OB38 Reserved / spare 0.010 0.010
In modern PCS 7 V9.x the default CFC chart run level is OB35 (100 ms). If you see a SAMPLE_T other than 0.1 s on a freshly compiled block, verify that the chart was placed in a different run level group, or that the OB cycle time was changed in HW Config without recompiling the CFC.

3. The Trapezoidal Integration Formula

The block comment in FB40 documents the algorithm explicitly:

V(n) = V(n-1) + (SAMPLE_T / (2*TI)) * (U(n) - U(n-1))

Where:

  • V(n) — integrator output at the current scan (REAL)
  • V(n-1) — integrator output at the previous scan (held internally)
  • SAMPLE_T — current scan period in seconds (from the OB attribute)
  • TI — integration time in seconds (operator-tunable, default 1.0)
  • U(n) — process input at the current scan
  • U(n-1) — process input at the previous scan

The factor 1 / (2·TI) normalizes the integration to a per-second rate. This is the key to understanding every totalization bug in the block.

If we re-arrange the equation to make the per-second scaling visible:

V(n) = V(n-1) + SAMPLE_T * (U(n) - U(n-1)) / (2 * TI)

Each call of the block adds a chunk of area to the output. The chunk size is proportional to SAMPLE_T. If SAMPLE_T is wrong by a factor of 10, the integrator accumulates 10× too fast or 10× too slowly, and the total at the end of the integration window is wrong by the same factor.

4. Why You Should Not Manually Change SAMPLE_T

The recommended workflow is:

  1. Place INT_P in a CFC chart on the run-level group that runs in OB35 (default 100 ms).
  2. Connect U to the process input (e.g. AI_SCALE.OUT).
  3. Connect TI to a constant or operator input. Leave the default of 1.0 unless you are using non-1/s units.
  4. Do not connect SAMPLE_T from anywhere in the chart. The compiler fills it in.
  5. Compile, download, and verify with an online watch table that SAMPLE_T reads 0.1.

Manually writing a constant of 1.0 on SAMPLE_T to "make it independent of the OB" is the most common mistake. The block is already independent of the OB at the math level; the OB period is simply the most accurate source of the true cycle time. Hard-coding a value works only as long as the block is actually called at that exact period — which the runtime cannot verify.

Engineering rule: SAMPLE_T must equal the actual time between two consecutive calls of INT_P. The OB system attribute is the only place that guarantees this, because the OB itself is the only thing that decides when the block runs.

5. The 3600 vs 36000 Field Example

The original question in this article was raised on a real flow totalizer. The application and the observed behavior are reproduced below verbatim because they illustrate the failure mode precisely.

Setup:

  • Flowmeter output: 3600 kg/h, fed as an analog input scaled to engineering units (kg/h).
  • Integrator: INT_P in OB35 (100 ms cycle, so SAMPLE_T = 0.1 s after compile).
  • Timer set to 1 hour (3600 s) to read the totalizer once per hour.
  • TI set to 3600 (because the input is in kg/h, not kg/s — see section 6).

Observed: After 1 hour, the totalizer reads 3600 kg. Correct. The engineer then manually changes SAMPLE_T from 0.1 to 1.0 in the instance DB and re-runs. After 1 hour the totalizer reads 36000 kg — exactly 10× too high.

Why: With SAMPLE_T = 0.1 and TI = 3600, the per-second scaling factor inside the block is 0.1 / (2·3600) = 1.39e-5. The block is called 10 times per second (every 100 ms), so the integrated contribution per real second is 10 × 1.39e-5 × (U(n) − U(n-1)) = 1.39e-4 × (U(n) − U(n-1)). For a constant 3600 kg/h input, this produces exactly 1 kg per real second. After 3600 s → 3600 kg. ✓

With SAMPLE_T = 1.0 and the block still being called every 100 ms, the scaling factor becomes 1.0 / (2·3600) = 1.39e-4, but it is multiplied 10 times per real second — yielding 10 kg per real second, i.e. 36000 kg per hour. The integrator is being told "one second passed since the last call", but in reality 100 ms passed, so it counts each 100 ms tick as a full second and runs 10× too fast.

Configuration SAMPLE_T TI Calling OB Real dt Result after 1 h, input = 3600 kg/h
Correct (auto from CFC) 0.1 3600 OB35 0.1 s 3600 kg ✓
Manual override (wrong) 1.0 3600 OB35 0.1 s 36000 kg ✗ (10×)
Block moved to OB32 1.0 3600 OB32 1.0 s 3600 kg ✓

6. The TI Parameter and Unit Conversion

TI is the integration time in seconds. The block divides by TI to convert the raw integrated input into the desired output unit. TI is also the parameter that absorbs the difference between per second process units and per hour process units.

The general rule:

TI [s] = number of seconds in the input's time base

So:

Input U unit Output V unit TI [s] Comment
kg/s kg 1 Direct integration
kg/min kg 60 Convert min → s
kg/h kg 3600 Convert h → s
m³/h 3600 Same as above
Nm³/min Nm³ 60 Same as above
t/h t 3600 Same as above
% (per second of full scale) %-s 1 No conversion
Common pitfall: Setting TI = 1 with a kg/h input. The integrator will then add SAMPLE_T · U / 2 per call, but the input is in kg/h, so the result will be wrong by a factor of 3600. The 3600/1 ratio is by far the most common engineering error on flow totalizers using INT_P.

7. OB Cycle Times and Where to Place INT_P

Choosing the OB for INT_P is a tradeoff between integration accuracy and AS scan load:

  • OB35 (100 ms) — recommended default. Good accuracy for most flow loops; 10 calls per real second is more than sufficient for the trapezoidal rule.
  • OB32 (1 s) — slow totalization only. Acceptable for hourly or shift totals of slowly varying flows, but loses accuracy on fast transients (e.g. start-up, batch dosing).
  • OB36 / OB37 (50 ms / 20 ms) — high-frequency energy meters. Use for steam, gas, or power totalization where the flow can change by > 5 % within 100 ms.
  • OB38 (10 ms) — rarely used in PCS 7. Reserved for special high-speed applications; will increase AS scan time significantly.

Critical constraint: the OB in which the chart runs is set in the CFC chart properties → Run sequence. If you move a chart that contains INT_P from OB35 to OB32 without recompiling, the runtime DB will continue to read SAMPLE_T = 0.1 (the old value) and your totalizer will be off by a factor of 10. Always recompile the chart after a run-level change.

8. Step-by-Step: Commissioning a Flow Totalizer with INT_P

Use this checklist to commission a clean totalizer from scratch in PCS 7 V8.x / V9.x.

  1. Open the CFC chart that contains the flow input (typically the regulatory or supervisory chart for the line).
  2. Insert INT_P from the PCS 7 Library (or APL INTEG_P if you are on APL). Place it on the same run level as the rest of the chart, usually OB35.
  3. Wire U to the engineering-unit output of the flow signal. If using AI_SCALE or CH_AO, the output is already in physical units (e.g. kg/h).
  4. Set TI:
    • Input is in /s → TI = 1.0
    • Input is in /min → TI = 60.0
    • Input is in /h → TI = 3600.0
  5. Leave SAMPLE_T unconnected in the chart. Do not add an input, do not write a constant. The compiler will populate it.
  6. Wire the reset input (R or RESET depending on APL/legacy) to the batch-end or shift-end logic, usually a pulse from a timer block.
  7. Wire the output V to the OS tag, the historian, and any alarm/limit logic.
  8. Compile → Download the chart. In CFC this is Charts → Compile → Download; in modern TIA-based PCS 7, Compile > Software > Download to AS.
  9. Verify online: open the instance DB in STEP 7 online or in the CFC online view. Confirm SAMPLE_T reads 0.1 (or whatever your OB period is). If it reads 0.0, the attribute was not set, or the chart is in OB1 (free cycle) which has no deterministic period.
  10. Functional test: force the input to a known constant (e.g. 3600 kg/h for one hour), read the totalizer, and confirm it matches 3600 kg within 1 %.

9. Common Configuration Mistakes and How to Diagnose Them

Symptom Likely Root Cause Diagnostic Step Fix
Totalizer reads 10× too high SAMPLE_T manually set to OB period in seconds, but block is called in a faster OB Online watch on SAMPLE_T vs. CFC run-level setting Clear the SAMPLE_T connection; recompile
Totalizer reads 100× too high SAMPLE_T = OB period in seconds, block in a 10× faster OB, TI also off by 10 Same as above; check TI Recompile and re-verify TI
Totalizer reads 0.1× too low SAMPLE_T = 0.01 (manually forced), block in OB35 Online watch on SAMPLE_T Recompile
Totalizer drifts by 5–10 % Flow input not in true engineering units (e.g. raw 4–20 mA value) Trace U with online trend Insert AI_SCALE upstream; verify with multimeter at the terminals
Totalizer resets unexpectedly R input wired to a level that is briefly high Online trace of R Add a one-shot or edge detection block
Totalizer zero on every scan SAMPLE_T attribute stripped from FB source after manual edit Open FB40 in STEP 7 → Declaration → check S7_sampletime Restore the original PCS 7 Library FB40

10. SAMPLE_T and Sampling Time Concepts in Other Siemens Controllers

The principle of an automatic sampling time attached to a system attribute is not unique to PCS 7. The S7-1200 / S7-1500 family uses the same idea for its built-in analog inputs, where the integration time (rejection frequency) determines the sample time:

Rejection Frequency Integration Time Sample Time
60 Hz 16.6 ms 4.17 ms
50 Hz 20.0 ms 5.00 ms
10 Hz 100.0 ms 25.0 ms

Source: SIMATIC S7-1200 Manual Collection — Sample time for the built-in analog inputs.

While the specific parameter and the rejection-frequency table are S7-1200 features (and the URL above is the S7-1200 reference, not the PCS 7 AS 410 manual), the underlying concept is the same: the sample time is a property of the calling environment, not of the function block instance, and it must match the actual scan period for numerical integration to be correct. Engineers moving between PCS 7 and TIA Portal will encounter the same pattern in the APL INTEG and PID blocks.

11. Verification Procedure After a Code Change

After any modification to the chart — adding, moving, or recompiling — perform this verification before resuming production:

  1. Online view of the instance DB. Confirm SAMPLE_T matches the calling OB cycle in seconds (0.1 for OB35, 1.0 for OB32, etc.).
  2. Online trend on U and V. Force U to a known constant (e.g. 100.0). Within one second, the output should increase by 100.0 / TI. If TI = 3600, the output should increase by ~0.0278 per second.
  3. Totalization spot-check. Run for a fixed duration (e.g. 60 s) and compare the totalizer reading to U × duration / TI. They should match within 0.1 %.
  4. Reset test. Trigger a reset and confirm V returns to zero on the next scan.
  5. OS tag check. Confirm the OS shows the same value as the AS. If not, check the CFC → OS compile and the WinCC tag connection.

12. Best Practices Summary

  • Never connect SAMPLE_T from the chart. Let the CFC compiler populate it from the OB system attribute.
  • Always set TI explicitly. The default of 1.0 is wrong for any input not in per-second units.
  • Place the integrator on the same run level as the rest of the control loop, usually OB35.
  • Recompile the chart after every change to chart properties, run level, or the underlying FB source.
  • Document the unit of the input and the unit of the output on the CFC faceplate so future engineers do not have to reverse-engineer them.
  • If you must use a non-standard OB period, change the OB cycle in HW Config and recompile — do not hard-code SAMPLE_T.
  • For high-accuracy energy metering (steam, gas, electricity), prefer OB36 or OB37 to minimize integration error on fast transients.
  • Never edit FB40 directly. If the library is corrupted, restore the FB from the original PCS 7 Library installation media.
Safety note: In any totalizer that drives a fiscal, billing, or custody-transfer reading (e.g. custody-transfer natural gas, exported product), the integrator must be placed in a chart that is part of the AS's user program and protected against unauthorized modification. In PCS 7 this is done with the standard user-rights model in the SIMATIC Manager. Do not allow operator-level accounts to write to the instance DB of INT_P.

What does SAMPLE_T do in the PCS 7 INT_P block?

SAMPLE_T holds the actual calling period of the block in seconds, populated automatically by the CFC compiler from the OB system attribute (S7_sampletime := 'true'). It is used inside the trapezoidal integration formula V(n) = V(n-1) + (SAMPLE_T / (2*TI)) * (U(n) - U(n-1)) to scale the discrete-time integration to real time. For an INT_P in OB35, the compiler writes 0.1; in OB32, it writes 1.0.

Why does my flow totalizer read 10× too high when I manually set SAMPLE_T to 1.0?

Because the block is still being called every 100 ms in OB35. SAMPLE_T = 1.0 tells the block "one second passed between scans," but in reality only 0.1 s passed, so the integrator counts each 100 ms tick as a full second and accumulates 10× too fast. The fix is to leave SAMPLE_T unconnected in the chart, recompile, and let the compiler write 0.1 automatically.

What value should I set for TI in INT_P?

TI must equal the number of seconds in the input's time base. For kg/s, m³/s, t/s — TI = 1. For kg/min, m³/min, Nm³/min — TI = 60. For kg/h, m³/h, t/h, Nm³/h — TI = 3600. The most common error is leaving TI = 1.0 with an input in kg/h, which makes the totalizer 3600× too high.

What is FB40 in the PCS 7 Library?

FB40 is the legacy continuous-action integrator from the classic PCS 7 Library, instantiated as INT_P in CFC charts. The current APL library uses INTEG / INTEG_P variants, but the trapezoidal math and SAMPLE_T behavior are equivalent. The same FB40 ships with STEP 7 for S7-300/400 use outside PCS 7.

Do I need to recompile INT_P after moving its chart to a different run level?

Yes. If you move a chart containing INT_P from OB35 to OB32, the runtime DB still holds the old SAMPLE_T = 0.1 until you recompile. The compiler will then write 1.0 from the new OB period. Skipping the recompile will cause the same 10× error as manually overwriting SAMPLE_T.

Back to blog