Generating and Exporting Source Code and Block Structures from PCS 7 SFC and SFC Types

Generating and Exporting Source Code and Block Structures from PCS 7 SFC and SFC Types

In SIMATIC PCS 7, engineers cannot directly export human-readable text source code (such as SCL or STL) from a graphical Sequential Function Chart (SFC) or SFC Type because the SFC Editor is a compiled graphical state-machine environment that compiles directly into executable S7 machine blocks. When compiled (SFC -> Compile), an SFC Type compiles into 1 Function Block (FB) and 2 Functions (FCs), while an SFC chart compiles into 1 instance Data Block (DB), multiple sequencer DBs, and 2 FCs. To export, backup, or transfer SFC logic in text or structured format, engineers must use the SFC XML Export utility (Options -> XML Export), generate comprehensive SFC printouts to PDF, or export the compiled blocks from the S7 Program.

Table of Contents

SFC Compilation Architecture and Internal Block Mapping

In SIMATIC PCS 7, Sequential Function Charts (SFC) provide graphical sequence control adhering to IEC 61131-3 and ISA-88. Unlike classic STEP 7 programming where text sources (.awl, .scl) compile into binary blocks and can be reverse-generated, the PCS 7 SFC subsystem operates as a high-level state-machine compiler.

When an engineer clicks SFC -> Compile... in the SFC Editor, the compiler validates chart consistency, transitions, and interlocking conditions, translating the graphical chart into a coordinated group of executable S7 blocks:

  • SFC Type (Reusable Template):
  • Generates 1 Function Block (FB) (e.g., FB1025) containing the state machine algorithm.
  • Generates 2 Functions (FCs) handling internal transition evaluations and step coordinator routines.

  • SFC Chart / SFC Instance (Runtime Object):

  • Generates 1 Instance Data Block (DB) (holding static parameters, step numbers, and operating modes).
  • Generates n Sequencer DBs (dynamic memory structures tracking execution time, elapsed step durations, and flags).
  • Generates 2 FCs (for standalone SFC charts).

Why Direct SCL/STL Source Generation Is Not Supported

Engineers coming from standard PLC programming frequently look for a menu command like File -> Generate Source to obtain an SCL or STL text representation of their sequence steps.

However, direct STL/SCL generation from SFC is intentionally not supported because:
1. Proprietary State Machine Engine: The compiled FB does not contain straightforward ladder logic; it contains compiled pointer tables and state-transition arrays evaluated by the central SFC Runtime System (ES_SFC FB1050 / SFC_RCON FB1051).
2. OS Interconnection Binding: SFC steps and transitions are heavily cross-linked with WinCC OS faceplate attributes, operator authorizations, and batch recipe interfaces (QBA_ID, QSTEP_NO). Decompiling this to raw STL would strip all technological metadata.

To achieve interoperability, version control, or modular reuse, PCS 7 provides structured XML Export and comprehensive printable audit trails.

Comparison of SFC Export and Documentation Formats

The following table compares the available export mechanisms for SFC and SFC Types in PCS 7:

Export MechanismOutput FormatHuman Readable?Re-Importable into PCS 7?Engineering ApplicationSFC XML ExportStructured XML (.xml)Yes (searchable markup)Yes (Options -> XML Import)Version control (Git/SVN), automated auditing, script analysisSFC Print to PDF / FilePDF / Multi-page documentYes (visual diagrams + tables)NoOfficial plant handover, TÜV validation, commissioning manualsProcess Object View ExportCSV spreadsheetYes (tabular parameters)Yes (CSV re-import)Mass parameterization of step times and setpointsDecompiled STL in STEP 7Text STL (.awl)Barely (raw bytecode)No (breaks SFC links)Low-level firmware debugging (Not recommended)Master Library ArchiveCompressed PKZIP (.zip)No (binary project)Yes (File -> Retrieve)Official library transfer between PCS 7 systems

Step-by-Step Procedure to Export SFC Data via XML and Print Reports

Follow this procedure to extract structured XML sources and documentation from SFCs:

  1. Exporting SFC / SFC Type via XML:
    - In SIMATIC Manager, navigate to the S7 Program 'SFC Types' or 'Charts' folder.
    - Open the target SFC or SFC Type in the SFC Editor.
    - Select menu Options -> XML Export....
    - Choose the export destination folder and confirm.
    - The utility generates an XML document containing every step name, transition condition, action statement, and block contact in structured markup.

  2. Generating Comprehensive Printable Audit Documentation:
    - With the SFC open, select SFC -> Print....
    - Select print scope: All sequencers, steps, transitions, and object properties.
    - Select a PDF virtual printer (e.g. Microsoft Print to PDF) to produce a complete graphical and tabular specification document.

  3. Re-Importing XML into a New Project:
    - In a target project chart folder, open the SFC Editor and select Options -> XML Import... to reconstruct the SFC.

Verification

Verify exported SFC data integrity:
1. Open the exported .xml file in a text editor (e.g. VS Code, Notepad++). Verify that all step names (e.g. Step_Heating, Step_Dosing) and transition logic formulas appear clearly formatted.
2. Open the generated PDF documentation. Confirm that state diagrams, transition logic, and step actions are completely rendered.
3. In SIMATIC Manager Component View, inspect the S7 Program 'Blocks' folder. Verify that the compiled FB (for SFC Type) or instance DBs exist with healthy timestamps matching the compilation run.

Limitations and Operational Precautions

  1. Never Attempt to Edit Compiled SFC FBs in STL: Modifying the generated FB or FCs of an SFC Type directly in the LAD/STL/FBD editor destroys internal pointer consistency. The next SFC compile will overwrite all edits.
  2. XML Version Compatibility: XML schema structures can change between major PCS 7 versions (e.g. V7.1 vs V9.0). When importing XML across versions, always verify chart syntax in the SFC Editor.
  3. CFC Cross-Dependencies: An exported SFC that references technological blocks in CFC charts cannot function in isolation; the referenced CFC blocks must be present in the target project before importing.

Engineer FAQ

Can I convert an SFC directly into an SCL source file?

No. PCS 7 does not support translating graphical SFC charts into SCL text sources. The official structured text exchange format is the SFC XML Export (Options -> XML Export).

What blocks are created when an SFC Type is compiled?

Compiling an SFC Type generates 1 Function Block (FB) containing the state machine logic and 2 Functions (FCs) for internal transition and step management. When instantiated, each instance generates 1 instance DB and multiple sequencer DBs.

How do I store SFC code in a version control system like Git?

Use the Options -> XML Export function in the SFC Editor. The resulting XML files are plain text, human-readable, and ideal for tracking line-by-line diffs in Git or SVN repositories.

Technical References

Related Articles

Related Tags

  • SFC Compilation
  • SFC Source
  • SFC XML Export
  • SFC Types
  • Sequencer DB
  • IEC 61131-3
6 respuestas