How TIMER_P Sampling Time Affects Short Delays in PCS 7

How TIMER_P Sampling Time Affects Short Delays in PCS 7

In PCS 7, TIMER_P measures time in calls separated by its SAMPLE_T task sampling interval. Its documented default is 1.0 s, but CFC can assign the block's task interval when the input carries S7_sampletime = true and the compile option Update sampling time is selected. On a 100 ms task, a 10 ms TIME0 is below the documented sampling interval requirement; choose a faster cyclic task or a delay greater than the configured sampling interval.

Table of Contents

How SAMPLE_T is determined

The current Siemens TIMER_P block reference describes SAMPLE_T as the task sampling time in seconds and lists 1.0 s as its default. The default is a block parameter value, not proof that a block in a compiled chart will execute on a one-second schedule.

CFC's documented Update Sampling Time compilation option updates inputs tagged with the system attribute S7_sampletime = true. CFC determines the cyclic interrupt OB containing the block and writes that OB's cycle time; if a runtime group scan rate applies, it is included in the calculation. Therefore, automatic assignment depends on the attribute and compilation option, and must be checked in the applicable installed CFC release.

Why the timer interval matters

TIMER_P decrements its remaining time (PTIME) periodically by SAMPLE_T; when time expires, it changes Q0 according to MODE. Siemens specifies that SAMPLE_T must be less than TIME0. With a 100 ms sampling interval, setting TIME0 to 10 ms violates that documented relationship. The manual does not say this setting causes a CPU error, so do not infer a CPU fault from the parameter mismatch alone.

Because evaluation occurs at the task sampling interval, the block cannot provide output transitions with 10 ms resolution while executing only once per 100 ms. The ticket's 350 ms example is a reported illustration, not a guaranteed timing result. For timing requirements finer than the task interval, use an appropriately faster task and validate the resulting behavior for the target CPU and project.

Configure and check the sampling time

Use this workflow when a CFC chart uses TIMER_P in a cyclic interrupt or runtime group and its elapsed-time calculation must track that execution interval.

  1. Confirm the block is assigned to the intended cyclic interrupt OB or runtime group and identify its actual cycle and any runtime-group reduction.
  2. Confirm the block input has the S7_sampletime system attribute enabled. Do not assume a visible parameter value will be updated if the attribute is absent.
  3. In the CFC compilation dialog, select Update sampling time (wording may vary by release), then compile the chart using the documented workflow for the installed version.
  4. Inspect the resulting SAMPLE_T value in the compiled/chart parameter context and confirm it represents the effective task interval in seconds, including any applicable reduction.
  5. Set TIME0 greater than SAMPLE_T, as required by the TIMER_P reference. If the required switching time is shorter than or near the task interval, redesign the task assignment or select a suitable timing mechanism only after verifying its support for the target configuration.
  6. Test the behavior under the project's approved commissioning conditions and observe PTIME and Q0 against the actual task execution. Do not treat a successful compile alone as proof of timing performance.

Understand timing precision and version scope

The current Siemens reference says TIMER_P uses REAL values and warns that accumulated sampling-time inaccuracies can occur when SAMPLE_T cannot be represented exactly as a REAL number. It gives values such as x.5, x.25, x.125 and x.0625 as exactly representable examples, and x.1 and x.2 as inexact examples. This caveat matters when interpreting accumulated timer intervals; it does not provide a universal error bound.

The source does not identify the PCS 7, CFC, or TIMER_P library version. The opened TIMER_P manual is dated June 2023, and the opened CFC update-option manual is an older CFC for S7 manual. Check the corresponding documentation and compile-dialog behavior for the project's installed versions before applying the procedure.

Verification

After compilation, verify the effective task assignment, runtime-group scan rate if used, and resulting SAMPLE_T value. Confirm TIME0 > SAMPLE_T. During a controlled test, observe the triggering edge, PTIME progression and Q0 transition over repeated task executions. Compare the observed timing with the requirement and the task interval; do not use the ticket's timing example as a guaranteed measured result.

Limitations and Operational Precautions

The CFC behavior cited here depends on the S7_sampletime attribute and the Update sampling time compile option. The cited compiler description is from legacy CFC for S7 documentation, so verify exact labels and applicability in the installed PCS 7/CFC release. Siemens' TIMER_P reference requires SAMPLE_T to be less than TIME0 and warns about REAL accumulation precision; it does not state that a short TIME0 alone causes the CPU to enter STOP. Changes to task assignment or execution timing can affect control behavior: review the project, protect the running process, and follow site change-control, backup, test and rollback practices before downloading modifications.

Engineer FAQ

Does SAMPLE_T always equal the OB cycle? No. The cited CFC documentation describes an update when the parameter is tagged S7_sampletime = true and the Update sampling time option is selected during compilation.

What is the documented default? The June 2023 TIMER_P reference lists SAMPLE_T default as 1.0 seconds. That is the block default and need not be the effective compiled value.

Can TIME0 be 10 ms when SAMPLE_T is 100 ms? That does not meet the documented condition SAMPLE_T < TIME0. The reference does not identify this mismatch alone as a CPU error.

What does runtime-group reduction change? The CFC manual says the scan rate is considered in sampling-time calculation when the block is installed in a runtime group.

Will a 350 ms setting produce exactly 350 ms? Not necessarily. Execution is sampled at the task interval, and the TIMER_P reference also warns that REAL sampling intervals such as 0.1 s may accumulate inexactly.

Technical References

  • Siemens, Help on CFC – Elementary blocks, Programming and Operating Manual, 06/2023, A5E41367261-AE, §15.2 “TIMER_P: Pulse generator,” pp. 91–93: https://cache.industry.siemens.com/dl/files/212/109825212/att_1157276/v1/s7jbib_b_en-US.pdf
  • Siemens, CFC for S7, A5E00083002-02, §3, “Update Sampling Time” option, p. 3-36: https://cache.industry.siemens.com/dl/files/062/1139062/att_29131/v1/Cfcs7_e.pdf
  • Siemens, PCS 7 V7.0 – Programming Instructions for Blocks, A5E00807905-01, §1.4, “Time dependency,” pp. 1-26–1-27: https://cache.industry.siemens.com/dl/files/702/24449702/att_60229/v1/s7jpa70b_e.pdf

Related Articles

Related Tags

PCS 7, CFC, TIMER_P, cyclic interrupt

20 respuestas