PCS 7 Programming Foundations: Memory Tag Storage, SFC Timers, and Dynamic WinCC Object Linking
In SIMATIC PCS 7, automation programming follows strict architectural paradigms that diverge from classic PLC ladder logic. Intermediate computational variables (such as loop counters or calculation flags) should be stored within Function Block (FB) static instance variables or dedicated internal CFC chart blocks, entirely avoiding global bit memory (Merker flags). For timing sequences inside Sequential Function Charts (SFC), using the step's built-in Minimum Step Time (TImin) is standard practice for step-dwell delays, whereas long-running independent timers mandate dedicated library timer blocks (TimerP). To link PLC variables to WinCC graphics without risking broken links when data block addresses shift during recompilation, engineers must rely on symbolic interconnection via the S7_m_c attribute rather than absolute DB addressing.
Table of Contents
- Paradigm Shift: DCS Architecture vs. Classic STEP 7 Programming
- Memory Tag Storage: Instance Variables vs. Global Bit Memory (Merker)
- SFC Sequence Timing: Minimum Step Time vs. Dedicated Timer Blocks
- Connecting PLC Variables to WinCC: Preventing DB Address Shift Failures
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Paradigm Shift: DCS Architecture vs. Classic STEP 7 Programming
Engineers transitioning from classic STEP 7 (S7-300/400) or TIA Portal to SIMATIC PCS 7 must adapt to automated database-driven engineering:
- No Manual DB/Address Management: In PCS 7, the engineer does not assign absolute data block numbers (e.g., DB100.DBX0.0) or global bit memory (M0.0).
- Object-Oriented Encapsulation: All technological functions are encapsulated within Function Blocks (FBs). The CFC compiler manages memory allocation, automatically assigning and reorganizing instance DBs.
- Unified AS-OS Integration: Data exchange between the controller and the operator station is handled through symbolic attribute propagation rather than manual HMI tag creation.
Memory Tag Storage: Instance Variables vs. Global Bit Memory (Merker)
In classic PLC programming, scratchpad calculations often use the Symbol Table and global memory flags (MW, MD):
* Why Global Merkers are Prohibited in PCS 7: Global bit memory (flags M) lacks instance encapsulation, is susceptible to unintentional overwrites across charts, and does not support automatic WinCC OS compilation.
* The Approved PCS 7 Practice:
1. Custom SCL/STL Function Blocks: When writing custom algorithmic logic (such as an iterative valve position formula), declare intermediate variables in the VAR (Static) section of the Function Block. The value persists safely in the block's instance DB.
2. Standard Calculation Blocks in CFC: If developing logic graphically in CFC, use standard mathematical and storage blocks from the PCS 7 Basic Library (e.g., Add04, Mul04, Count, or FlipFlop).
SFC Sequence Timing: Minimum Step Time vs. Dedicated Timer Blocks
When implementing dwell times or phase delays in Sequential Function Charts (SFC):
TImin)TI >= TImin before evaluating transition conditions.TimerP)Start = 1), and the transition monitors the timer's output flag (TimeOut = 1).Using TImin is the universally recommended, clean, and standard methodology for simple in-step dwell delays.
Connecting PLC Variables to WinCC: Preventing DB Address Shift Failures
A common beginner mistake is using absolute DB addresses (e.g., DB501.DBD12) in WinCC Graphics Designer:
- The Address Shift Hazard: Whenever you add a new block, reorder charts, or execute Compile -> Charts as Program, the CFC compiler dynamically optimizes memory, shifting block instance DB numbers and internal byte offsets. Absolute WinCC links will suddenly read the wrong data or cause runtime script crashes.
- The Correct Method (Symbolic AS-OS Compilation):
1. On the block parameter in CFC (or in the SCL source code), ensure the system attribute S7_m_c := 'true' is enabled.
2. In the Plant View, structure your charts under the Plant Hierarchy.
3. Right-click the OS project in SIMATIC Manager and select Compile OS.
4. The compiler automatically creates a named WinCC tag formatted as:
PlantHierarchy/ChartName/BlockName.Parameter
5. In WinCC Graphics Designer, open the dynamic dialog or tag connection for your object (e.g., motor status color), and browse the WinCC Tag Management tree. Select the symbolic process tag.
6. Result: Even if the compiler reallocates DB numbers, the symbolic tag connection is maintained seamlessly.
Verification
To verify that your architecture adheres to PCS 7 standards:
- In SIMATIC Manager, check the Cross-Reference Data (Options -> Reference Data -> Display -> Bit Memory): verify that bit memory utilization (M0.0–M255.7) is 0% or restricted solely to legacy hardware clock memory.
- In CFC online Test Mode, monitor your SFC sequence: verify that steps hold for their exact configured minimum time (TImin) before transitioning.
- Execute a full CFC compilation with memory compression: verify in WinCC Runtime that graphic displays and color changes continue to track motor states without broken tag indicators.
Limitations and Operational Precautions
- Clock Memory Byte: The only acceptable use of bit memory in a PCS 7 CPU is the hardware clock byte (e.g.,
MB0) configured in HW Config for flash frequencies (1 Hz, 2 Hz). - Direct DB Write Hazards: Never write logic that directly accesses or overwrites instance data blocks (
DI) belonging to standard APL blocks. Always interface via the exposed CFC block pins. - SFC Maximum Step Time (
TImax): WhileTIminholds a step, settingTImaxenables step execution monitoring, triggering a sequence alarm if an expected transition condition fails to materialize within the timeout window.
Engineer FAQ
Can I pass an SFC step time into a WinCC faceplate?
Yes. The SFC runtime system provides standard internal tags (StepName.TI) that can be mapped to WinCC for displaying elapsed phase timers on operator screens.
Why do instance DB numbers change when I recompile CFC?
The CFC compiler optimizes memory defragmentation. If blocks are deleted or inserted, the compiler renumbers data blocks unless individual block instances are specifically pinned with fixed numbers in their object properties.
What data type should I use for loop counters in SCL?
Use DINT (32-bit signed integer) or INT (16-bit integer). In PCS 7, DINT is generally preferred to prevent integer overflow errors in high-iteration loops.
How do I color an object in WinCC based on a multi-state integer?
Use the Dynamic Dialog in Graphics Designer. Set the evaluation type to Analog or Bit, link your symbolic block output tag, and define distinct colors for each numerical state (e.g., 0 = Gray, 1 = Green, 2 = Red, 3 = Yellow flashing).
Technical References
- Siemens Industry Online Support: SIMATIC PCS 7 CFC for S7 Manual (A5E00278782).
- Siemens Industry Online Support: SIMATIC PCS 7 SFC for S7 Manual.
- SIOS Entry 109742323: PCS 7 Compendium Part A - Configuration Guidelines (Section: AS-OS Engineering).
- SIOS Entry 109809264: SIMATIC Process Control System PCS 7 Advanced Process Library Manual.
Related Articles
- How to Structure Program Data in PCS 7: Moving from TIA Portal to Control Module Types
- How to Create and Name Custom Block Icons in SIMATIC PCS 7 OS
- How to Automatically Trigger Cascaded Start Sequences in PCS 7 SFC Types
Related Tags
- CFC
- SFC
- WinCC
- S7_m_c
- Best Practices
- Architecture
- Industrial Automation