Comparing SCL Source Files in SIMATIC PCS 7: Native Tools, Text Diffs, and Version Management
To compare two Structured Control Language (SCL) source files in SIMATIC PCS 7 effectively, export the SCL sources as ASCII text files and utilize a specialized visual file diff tool such as Beyond Compare, WinMerge, or Total Commander, or employ the native Siemens SIMATIC Version Cross Manager (VXM). While the STEP 7 'Compare Blocks' utility compares compiled binary byte-code in the blocks folder, it cannot evaluate high-level SCL source text, variable comments, or algorithmic formulas. Exporting sources via SCL Editor (File -> Export Source) enables precise line-by-line syntax comparison, whitespace filtering, and bidirectional merging.
Table of Contents
- Structured Control Language (SCL) Sources vs Compiled Binary Blocks
- Limitations of the STEP 7 Native 'Compare Blocks' Utility
- Recommended Workflow 1: Exporting SCL Sources for Visual Text Diff
- Recommended Workflow 2: SIMATIC Version Cross Manager (VXM)
- Comparing SCL Sources vs Binary Blocks: Technical Tradeoffs Matrix
- Step-by-Step Export and Comparison Procedure
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Structured Control Language (SCL) Sources vs Compiled Binary Blocks
In SIMATIC PCS 7 and STEP 7 engineering, custom algorithmic blocks, complex mathematical calculations, and communication drivers are frequently authored in Structured Control Language (SCL), an IEC 61131-3 compliant high-level programming language similar to Pascal. Within an S7 program, SCL code exists in two distinct representations:
- The SCL Source Text (
Sourcescontainer): A human-readable ASCII text file containing high-level code, variable declarations, engineering formulas, comments, and compiler directives ({ S7_m_c := 'true' }). - The Compiled Block Binary (
Blockscontainer): The machine-executable Function Block (FB) or Function (FC) generated when the SCL source is compiled into S7 Machine Code (Statement List / AWL machine instructions).
When engineers seek to compare two versions of an SCL algorithm, conflating these two layers leads to ineffective analysis.
Limitations of the STEP 7 Native 'Compare Blocks' Utility
Engineers familiar with the native STEP 7 utility Compare Blocks (s7wbmpbx.exe - Bausteine vergleichen) often attempt to use it to compare SCL algorithms. However, Compare Blocks is designed strictly for compiled binary blocks:
- Loss of SCL Abstraction: Compare Blocks decompiles both blocks into raw Statement List (AWL) mnemonics. Complex high-level constructs (such as
FOR...TO...DOloops,CASEstatements, and array index calculations) are expanded into dozens of raw register jumps and accumulator operations, making algorithmic comparison virtually incomprehensible. - Missing Comments and Layout: The compiled binary in the PLC or offline block folder strips all programmer comments and variable indentation. Comparing compiled blocks reveals that differences exist, but fails to explain why or show the original source line that was altered.
- Spurious Differences: Changes in SCL compiler optimization settings or timestamp headers trigger false mismatch alerts in Compare Blocks even when the high-level source code is identical.
Recommended Workflow 1: Exporting SCL Sources for Visual Text Diff
The industry-standard, most effective method for comparing SCL source code relies on external visual diff utilities:
- Exporting SCL Text: Inside the S7 SCL Editor, SCL sources can be exported directly to standard text files (
*.sclor*.txt). - Visual Diff Engines: Modern utilities—such as Beyond Compare, WinMerge, KDiff3, or Total Commander (Compare by Content)—provide advanced visual text analysis specifically suited for programming:
- Side-by-side color-coded syntax highlighting.
- In-line character difference tracking.
- Ignorable whitespace, line-ending (CRLF vs LF), and case-sensitivity filtering.
- Direct three-way merging and conflict resolution.
Recommended Workflow 2: SIMATIC Version Cross Manager (VXM)
For plants requiring an integrated, audit-trailed Siemens environment, SIMATIC Version Cross Manager (VXM) is the certified optional package:
- Native S7 Project Parsing: VXM opens two STEP 7 projects, multiprojects, or library archives directly without requiring manual text exports.
- Object-Level Diff: VXM parses the
Sourcescontainer directly, highlighting differences between SCL sources, CFC charts, hardware configurations, and symbol tables. - Change History and Tracking: Integrated with SIMATIC Version Trail (VT), VXM generates structured discrepancy reports conforming to regulatory change management standards (such as FDA 21 CFR Part 11 or ISO 9001).
Comparing SCL Sources vs Binary Blocks: Technical Tradeoffs Matrix
The following table compares the capabilities of SCL source text comparison against compiled binary block comparison:
*.scl)Blocks.scl or .txt)Step-by-Step Export and Comparison Procedure
Follow this sequence to execute a precision SCL comparison using external diff tools:
- Export Source 1: In SIMATIC Manager, navigate to Project A, open the
Sourcesfolder, and double-click the SCL source. In the SCL Editor, selectFile -> Export Source.... Save the file asSource_v1.scl. - Export Source 2: Repeat the process for Project B or the library folder, saving as
Source_v2.scl. - Launch Visual Diff Tool: Open Beyond Compare or WinMerge.
- Load Files: Drag
Source_v1.sclto the left pane andSource_v2.sclto the right pane. - Configure Filter Rules: Enable Ignore Unimportant Differences (comments, trailing spaces) to isolate pure algorithmic logic changes.
- Analyze Discrepancies: Review highlighted differences in variable declarations, logic branches (
IF...THEN...ELSE), and block attributes.
Verification
Verify accurate SCL source alignment and compilation:
- After merging or reconciling differences in the SCL Editor, click File -> Save.
- Execute
File -> Compilein the SCL Editor (or pressCtrl + F9). - Confirm that the compiler output window reports '0 Errors, 0 Warnings'.
- In SIMATIC Manager, verify that the compiled FB/FC in the
Blocksfolder reflects the updated timestamp. - Run the native STEP 7 'Compare Blocks' utility against the target AS; confirm that code differences are resolved.
Limitations and Operational Precautions
Adhere to the following operational precautions:
- Source-to-Block Divergence: Never assume the compiled block in the AS matches the SCL source file in the
Sourcescontainer; if an engineer edited the block in AWL directly or failed to recompile the SCL source, the source text and running block will diverge. - Interface Attribute Changes: Modifying SCL input/output variables or block attributes (
S7_m_c) alters the block interface; updating the block in CFC requires recompilation and may invalidate delta downloads. - Character Encoding: Ensure visual diff tools are configured for ANSI / Windows-1252 encoding to prevent corruption of special German umlauts (
ä, ö, ü) in block comments.
Engineer FAQ
Can I compare an SCL source directly against a running PLC?
No. PLCs execute compiled machine code (MC7) and do not store SCL source text. You can only compare the compiled block binary against the PLC using Compare Blocks.
What happens if an SCL source is edited but not compiled?
The SCL source text updates in the Sources container, but the compiled FB/FC in the Blocks container and in the running AS remains unchanged, creating a dangerous code divergence.
Does exporting an SCL source strip any block properties?
No. Exporting an SCL source exports the entire ASCII file, including compiler directives, attributes (such as S7_m_c, S7_alarm_ui), and variable declarations.
Technical References
- SIMATIC S7-SCL V5.6 for S7-300/400 Manual (Entry ID: 109751826)
- SIMATIC Process Control System PCS 7 Version Cross Manager (VXM) Manual (Entry ID: 109746516)
- STEP 7 V5.6 Programming with STEP 7 Manual (Entry ID: 109751825)
- Siemens Industry Online Support (SIOS) FAQ: Exporting SCL Source Files (Entry ID: 22123987)
Related Articles
- Tracing Origin of Instantiated Function Blocks (FB/FC) in SIMATIC PCS 7
- Batch Editing Sequential Function Charts (SFC) and SFC Types
- Understanding Textual References, Block Variables, and Global Data References in PCS 7 CFC and CMT
Related Tags
- SCL Programming
- Source Code Compare
- WinMerge / Beyond Compare
- Version Cross Manager (VXM)
- STEP 7 Compare Blocks
- SCL Source Export