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
- State Retention and Instance DB Memory Rules
- Step-by-Step Procedure for Calling FCs in CFC
- Function (FC) vs. Function Block (FB) in SIMATIC PCS 7 Matrix
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
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:
-
Memory Allocation and Stateless Execution:
* Function Block (FB): Allocates an instance Data Block (DB) in the controller memory. Variables declared underVAR(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 underVAR_TEMPexist 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. -
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 anIN_OUTorOUTpin and stored in an external memory location (such as a shared global DB or another FB's static pin). -
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 aCALL 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
- In SIMATIC Manager, expand the S7 Program container and open the Blocks folder.
- Author your Function (FC) in SCL, STL, or FBD.
- 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
- Open the target CFC chart in the CFC editor.
- Select menu Options > Block Types....
- In the Block Types dialog, select source container: S7 Program (or the respective user library).
- Locate your FC block in the left pane, select it, and click the arrow button
-->to transfer the block type into the chart folder. - 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
- In the CFC catalog tree, expand Block Types (or the library folder).
- Click and drag the FC block onto the desired sheet.
- Wire inputs and outputs to adjacent channel drivers (e.g.
Pcs7AnIn) or technological blocks (MotL,PIDConL).
4. Configure Runtime Group and Organization Block Scheduling
- By default, the FC is placed inside the chart's default runtime group in OB35 (100 ms).
- 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 fromOB35intoOB1.
* 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
L-Stack only)VAR retained in DB)MotL, PIDConL, VlvL)Ctrl + F9)Ctrl + F9)Verification
- In the CFC editor, verify the FC block appears on the sheet with solid interconnections.
- Press Ctrl + F9; confirm the FC block is listed under the target OB task (e.g. OB35 or OB1).
- Execute Chart > Compile > Changes only; confirm compilation completes with 0 Errors.
- Download the chart to S7-PLCSIM.
- 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_TEMPvariable before writing to it within the same scan. BecauseL-stackmemory 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
- SIMATIC Process Control System PCS 7 CFC for S7 (V8.1) Programming and Operating Manual
- SIMATIC STEP 7 V5.5 Programming with STEP 7 - Functions and Function Blocks
- SIMATIC S7-400 Programmable Controller CPU Specifications and Organization Blocks
- Siemens Industry Online Support: Using FCs and FBs in Continuous Function Charts (SIOS Entry ID 109780813)
Related Articles
- Understanding 'Generate Module Drivers' in SIMATIC PCS 7
- Resolving Disabled Control Buttons and Freezes in SIMATIC PCS 7 SFC Test Mode
- Optimizing Execution Cycles Across Organization Blocks OB30 to OB38
Related Tags
- CFC
- FC
- Function Block
- Run Sequence
- OB35
- OB1