Calling Functions (FC) in SIMATIC PCS 7 CFC Charts: Integration and Runtime Scheduling

Calling Functions (FC) in SIMATIC PCS 7 CFC Charts: Integration and Runtime Scheduling

In SIMATIC PCS 7 CFC, Function (FC) blocks can be integrated directly into charts by dragging them from the block catalog onto the chart canvas. Unlike Function Blocks (FB), FCs do not allocate instance Data Blocks (DBs) and execute statelessly. By default, CFC assigns the placed FC to the chart's cyclic interrupt organization block (e.g. OB35 at 100 ms); engineers can reassign execution to background OB1 using the Run Sequence editor (Ctrl + F9).

Table of Contents

Architectural Distinctions: FC vs. FB in SIMATIC CFC

In standard SIMATIC STEP 7 Classic programming (Ladder, FBD, or STL), engineers frequently write custom calculation routines, mathematical algorithms, or Boolean mapping functions inside Functions (FC) and call them unconditionally in the main cyclic program loop: Organization Block 1 (OB1).

When transitioning to SIMATIC PCS 7 (such as PCS 7 V8.1), engineers often question whether custom FC blocks can be utilized within Continuous Function Charts (CFC) and how their execution cycle is scheduled.

In SIMATIC PCS 7 CFC:
1. Full Support for Functions (FC): CFC fully supports placing and interconnecting FC blocks alongside standard Function Blocks (FB).
2. Deterministic Process Automation Philosophy: In PCS 7 process control, executing control logic in the non-deterministic background cycle OB1 is generally discouraged. Instead, all process control algorithms, interlocks, and mathematical conversions are executed deterministically within Cyclic Interrupt Organization Blocks (OB30 through OB38, such as OB35 running at a guaranteed 100 ms cycle).
3. Automated Runtime Group Assignment: When an FC is dragged onto a CFC sheet, the CFC editor automatically integrates the function call into the active runtime group of that chart, ensuring synchronized data exchange with adjacent technological blocks.

State Retention and Instance DB Memory Rules

Understanding the execution mechanics between FCs and FBs is critical to avoid logic malfunctions:

  1. Memory Allocation and Stateless Execution:
    * Function Block (FB): Allocates an instance Data Block (DB) in the controller memory. Variables declared under VAR (static variables) retain their values across execution cycles. This allows FBs to implement timers, integrators, state machines, and hysteretic filters.
    * Function (FC): Allocates zero instance memory. Variables declared under VAR_TEMP exist only on the local data stack (L-stack) during the specific CPU cycle in which the FC executes. As soon as the FC finishes, its temporary memory is discarded. An FC cannot store state history internally from one scan to the next.

  2. Parameter Passing and In/Out Pins:
    * In CFC, all inputs (IN), outputs (OUT), and in/out (IN_OUT) pins of an FC can be interconnected to other blocks or parameterized with constants.
    * If an FC requires state tracking across cycles, the state value must be passed outward via an IN_OUT or OUT pin and stored in an external memory location (such as a shared global DB or another FB's static pin).

  3. CFC System Driver and Code Generation:
    * During CFC compilation, the compiler translates the graphical diagram into compiled SCL/STL machine code.
    * For an FB, CFC generates a CALL FB_Number, DB_Number.
    * For an FC, CFC generates a simple parameter-loaded call: CALL FC_Number.

Step-by-Step Procedure for Calling FCs in CFC

1. Prepare and Compile the FC in STEP 7

  1. In SIMATIC Manager, expand the S7 Program container and open the Blocks folder.
  2. Author your Function (FC) in SCL, STL, or FBD.
  3. Adhere to strict modular programming standards:
    * Do not access absolute global memory bits (e.g. M 10.0) inside the FC code; define explicit formal parameters (IN, OUT, IN_OUT).
    * Compile the FC without syntax errors.

2. Import the FC into the CFC Block Catalog

  1. Open the target CFC chart in the CFC editor.
  2. Select menu Options > Block Types....
  3. In the Block Types dialog, select source container: S7 Program (or the respective user library).
  4. Locate your FC block in the left pane, select it, and click the arrow button --> to transfer the block type into the chart folder.
  5. Click Close. The FC is now available in the CFC catalog under the Block Types folder.

3. Place and Wire the FC on the CFC Canvas

  1. In the CFC catalog tree, expand Block Types (or the library folder).
  2. Click and drag the FC block onto the desired sheet.
  3. Wire inputs and outputs to adjacent channel drivers (e.g. Pcs7AnIn) or technological blocks (MotL, PIDConL).

4. Configure Runtime Group and Organization Block Scheduling

  1. By default, the FC is placed inside the chart's default runtime group in OB35 (100 ms).
  2. To inspect or change the execution task:
    * Press Ctrl + F9 to open the Run Sequence editor.
    * Locate the block within the OB task list.
    * If background execution is explicitly required, drag the runtime group or block from OB35 into OB1.
    * Position the block in the exact execution sequence relative to other blocks to prevent 1-cycle calculation lag.

Function (FC) vs. Function Block (FB) in SIMATIC PCS 7 Matrix

Feature / CharacteristicFunction (FC)Function Block (FB)Instance Data Block (DB)None (Zero DB allocation)Required (1 Instance DB per block instance)Internal Memory PersistenceStateless (Temporary L-Stack only)Stateful (Static VAR retained in DB)Typical PCS 7 Use CasePure math, conversions, stateless logicTechnological control (MotL, PIDConL, VlvL)WinCC Operator Control (s7_m_c)Unsupported (Cannot generate OS tags directly)Fully Supported (Generates WinCC tags and faceplates)Default Runtime TaskAssigned to Chart's cyclic OB (e.g. OB35)Assigned to Chart's cyclic OB (e.g. OB35)Execution Relocation to OB1Supported via Run Sequence (Ctrl + F9)Supported via Run Sequence (Ctrl + F9)

Verification

  1. In the CFC editor, verify the FC block appears on the sheet with solid interconnections.
  2. Press Ctrl + F9; confirm the FC block is listed under the target OB task (e.g. OB35 or OB1).
  3. Execute Chart > Compile > Changes only; confirm compilation completes with 0 Errors.
  4. Download the chart to S7-PLCSIM.
  5. In CFC, activate Test Mode (glasses icon); confirm live numerical values update on the FC output pins matching the mathematical logic.

Limitations and Operational Precautions

  • No Direct WinCC Faceplate Binding: Functions (FC) cannot be assigned the s7_m_c = 'true' attribute for automated WinCC block icon and faceplate generation. If an asset requires operator interaction, an alarm message, or faceplate display, it must be authored as a Function Block (FB).
  • Temporary Variable Initialization: In an FC, never read a VAR_TEMP variable before writing to it within the same scan. Because L-stack memory is shared across all blocks in the CPU, reading uninitialized temp variables will load random residual values.
  • Avoid OB1 in Closed-Loop Control: Never place time-dependent mathematical blocks (such as integration, flow totalization, or PID algorithms) into OB1. OB1 execution time fluctuates based on communication load, corrupting time-base calculations.

Engineer FAQ

Can an FC call another FC or FB in CFC?

Yes, an FC can internally invoke other functions or system functions (SFC), provided parameter allocations and stack depth limits are respected.

Why does PCS 7 default to OB35 instead of OB1 for CFC charts?

PCS 7 enforces deterministic execution: cyclic interrupt OBs (OB30 to OB38) guarantee fixed, jitter-free execution intervals (e.g. exactly 100 ms), which is essential for stable process control and alarm timestamps.

Can I delete an FC from a CFC chart in runtime?

Yes, you can delete an FC and perform a download of changes in RUN (CiR), provided the block is not interconnected to critical safety trips.

Technical References

Related Articles

Related Tags

  • CFC
  • FC
  • Function Block
  • Run Sequence
  • OB35
  • OB1
6 respuestas