Use the CFC S7_sampletime Attribute to Read a Cyclic OB Interval

Use the CFC S7_sampletime Attribute to Read a Cyclic OB Interval

For a PCS 7 CFC block placed in a cyclic interrupt OB, declare a REAL input with the S7_sampletime attribute and enable CFC's sampling-time update during compilation. CFC can then write the assigned OB cycle time (including run-time-group scan rate where applicable) to that input, allowing the block to use its configured sample interval. This is compiler-provided metadata, not a runtime API that discovers any arbitrary OB interval.

Table of Contents

How CFC provides the interval

Siemens CFC documentation describes an I/O with attribute S7_sampletime = true as a sampling-time input. With “Update the sampling time” enabled in the compile dialog, CFC checks the cyclic interrupt OB where the block is installed and writes the OB cycle time to the input. For a block in a runtime group, the group scan rate is also included in the calculation.

Declare a sample-time parameter

The source provides this SCL declaration pattern:

SampleTime {S7_visible := "false"; S7_sampletime := "true"} : REAL := 1.0;

Confirm exact SCL attribute syntax and Boolean/string conventions supported by the installed STEP 7/CFC compiler. The parameter name is not significant to the compiler; the S7_sampletime attribute is.

Compile and inspect the assigned value

  1. Add the attribute-bearing REAL I/O to the function block interface.
  2. Compile the block/chart using the PCS 7 CFC compiler version supported by the project.
  3. In the compile dialog, enable the “Update the sampling time” option.
  4. Place the block instance in the intended cyclic interrupt OB and assign its runtime group if used.
  5. Compile the CFC charts and inspect the generated parameter value for the instance.
  6. Use that value in calculations that require the configured execution interval, and validate it after moving the block or changing OB/run-group timing.

Keep the interval and unit consistent

The source describes the value as seconds and gives 0.1 for an example OB35 configuration with a 100 ms interval. Treat that as an example tied to its OB timing. Do not hard-code the example for another OB or runtime group. Ensure calculations convert seconds to the units expected by their timers/counters.

Limitations

The value represents the configured CFC execution interval, not a measured wall-clock interval, current jitter or proof of actual scheduling latency. It does not automatically track a changed OB interval unless CFC compilation updates the parameter. The exact supported attribute syntax depends on the installed compiler.

Verification

After compiling, compare the assigned parameter against the cyclic OB and runtime-group configuration in the engineering project. Then verify the block uses the value with consistent units and behavior. Recompile after changing OB timing or moving the instance to a different runtime group.

Limitations and Operational Precautions

The source does not state PCS 7/CFC/STEP 7 version. The cited Siemens CFC manual is for S7 CFC and documents the sampling-time attribute and compile option; check the version-matched PCS 7 manual and attribute syntax. A configured interval should not be mistaken for measured cycle time, especially in load/overrun diagnostics.

Engineer FAQ

Which attribute signals a sample-time I/O? S7_sampletime.

What does CFC write to it? With sampling-time update enabled, the configured cyclic OB time, accounting for a runtime-group scan rate where used.

Is the value seconds? The ticket's example and Siemens CFC documentation context use a sampling interval value; confirm units and scaling in the applicable block/compile environment.

Does it report real measured jitter? No. It represents the configured interval, not observed execution latency.

What if the OB timing changes? Recompile with sampling-time update enabled and verify the instance value.

Technical References

  • Siemens, CFC for S7, “Update Sampling Time” option and S7_sampletime attribute: https://support.industry.siemens.com/cs/attachments/1139062/Cfcs7_e.pdf
  • Siemens, PCS 7 Compendium Part A – Configuration Guidelines V9.0, CFC/PCS 7 engineering context: https://support.industry.siemens.com/cs/attachments/109756485/pcs7_compendium_part_a_en-US_en-US.pdf

Related Articles

Related Tags

PCS 7 CFC, SCL, Cyclic interrupt OB, Sample time

20 respuestas