Migrating Legacy SIMATIC S5 Statement List (STL) Logic and Jumps into SIMATIC PCS 7

Migrating Legacy SIMATIC S5 Statement List (STL) Logic and Jumps into SIMATIC PCS 7

Direct line-by-line conversion of SIMATIC S5 Statement List jumps (SPB/SPA) into PCS 7 CFC is an anti-pattern because CFC is an graphical signal-flow language that does not support arbitrary jumps. To migrate S5 code effectively into PCS 7, encapsulate complex jump structures and mathematical algorithms inside Structured Control Language (SCL) Function Blocks (IF...THEN, CASE), or replace the logic entirely with standard Advanced Process Library (APL) technological blocks.

Table of Contents

The Architectural Divide: S5 Step Programming vs. PCS 7 CFC

When modernizing legacy manufacturing plants controlled by SIMATIC S5 (e.g. S5-115U, S5-135U, or S5-155U) into modern SIMATIC PCS 7, engineers face the task of converting decades-old Statement List (STL) logic into the PCS 7 engineering environment.

Engineers frequently attempt direct transliteration of raw S5 assembly code:

L   DW 3
L   KF +11
!=F
SPB =M004
SPA =M003
M004:
L   KF +1
T   DW 3
UN  E 15.1
SPB =M005
L   DD 15
L   KG +19500
+GT
T   DD 15
SPA =M003
M005:
ON  E 15.2
SPB =M003
L   DD 15
L   KG +19500
-GT
T   DD 15
M003: ***

When importing this into PCS 7, engineers discover that:
1. CFC Does Not Support Jump Instructions: The Continuous Function Chart (CFC) editor is a graphical signal-flow engine based on interconnected blocks. It has no native concept of labels, jumps (SPA, SPB), or conditional skipping.
2. S5 Converter Limitations: The automated 'S5 to S7 Converter' utility translates S5 STL into standard S7 Classic STL. However, raw STL blocks cannot be directly interconnected or visualized inside PCS 7 without violating module driver generation and APL faceplate standards.

Dissecting S5 Jump Mechanics and Data Formats

To translate S5 code successfully, one must analyze the underlying control intent rather than individual assembly instructions:

  1. S5 Jump Instructions:
    * SPB (Springe bedingt): Jump if RLO (Result of Logic Operation) is 1.
    * SPA (Springe absolut): Unconditional Jump to a label.
    * In the example logic, jumps are utilized to implement standard if-else branching and state selection.

  2. Legacy S5 Data Types vs. Modern IEEE Standards:
    * KF (Festpunktzahl): 16-bit signed integer (equivalent to S7 INT).
    * KG (Gleitpunktzahl): Proprietary S5 floating-point format (32-bit floating point, non-IEEE 754). S7 uses standard 32-bit IEEE 754 floating point (REAL).
    * +GT / -GT: S5 floating-point addition and subtraction (equivalent to S7 +R and -R).
    * DW 3 / DD 15: Data Word 3 (16-bit word) and Data Double Word 15 (32-bit dword) inside the active open data block.

  3. Technological Intent of the S5 Snippet:
    * The logic checks whether a mode word (DW 3) equals 11. If not, it initializes DW 3 to 1.
    * If digital input E 15.1 is low (0), it increments process accumulator DD 15 by 19500.0.
    * If digital input E 15.2 is low, it decrements the accumulator by 19500.0.
    * In modern terms, this is an incremental ramp / accumulator function with direction control.

Recommended Migration Strategies: SCL Encapsulation vs. APL

Strategy 1: Encapsulating Logic in Structured Control Language (SCL - Recommended)

The cleanest method to migrate complex jump structures into PCS 7 is authoring a custom Function Block (FB) using Structured Control Language (SCL):
1. SCL natively expresses jumps through structured control statements: IF...THEN...ELSE and CASE...OF.
2. Cleanly defines formal inputs and outputs, eliminating absolute memory accesses.

Example SCL Implementation:

FUNCTION_BLOCK FB1200
TITLE = 'Accumulator Controller'
{ S7_m_c := 'true' }
VAR_INPUT
    ModeSelect : INT;
    DecrInput  : BOOL; // Corresponds to E 15.1
    IncrInput  : BOOL; // Corresponds to E 15.2
    StepValue  : REAL := 19500.0;
END_VAR
VAR_OUTPUT
    AccumulatorValue { S7_m_c := 'true' } : REAL;
    ModeStatus       : INT;
END_VAR

BEGIN
    // Replaces: L DW 3 / L KF 11 / !=F / SPB M004
    IF ModeSelect <> 11 THEN
        ModeStatus := 1;
    ELSE
        ModeStatus := ModeSelect;
    END_IF;

    // Replaces conditional increments and decrements
    IF NOT DecrInput THEN
        AccumulatorValue := AccumulatorValue + StepValue;
    ELSIF NOT IncrInput THEN
        AccumulatorValue := AccumulatorValue - StepValue;
    END_IF;
END_FUNCTION_BLOCK
  1. Compile the SCL block into an FB, place it onto a CFC chart, and wire its inputs directly to channel drivers (Pcs7DiIn).

Strategy 2: Replacing with Standard APL Technological Blocks

In many cases, legacy S5 custom code was written because S5 lacked standard process libraries. In PCS 7, this entire routine can often be replaced by standard Advanced Process Library blocks:
* Use Ramp (FB1886) for rate-of-change control.
* Use TotalL (FB1906) for accumulated totalization.
* Use SelA16In (FB1888) for mode selection.

S5 Instruction Conversion to PCS 7 SCL Matrix

S5 Assembly InstructionS5 Operational MeaningModern S7 / PCS 7 EquivalentModern SCL SyntaxL KF +11Load 16-bit signed integerL 11ModeSelect := 11;L KG +19500Load S5 floating pointL 19500.0 (IEEE 754)StepValue := 19500.0;SPB =LabelJump if RLO = 1JC Label (STL)IF Condition THEN ... END_IF;SPA =LabelUnconditional jumpJU Label (STL)GOTO Label; (or structured loop)!=FCompare Integer Not Equal<>IIF Var1 <> Var2 THEN+GT / -GTAdd / Subtract Floating Point+R / -RResult := Val1 + Val2;

Verification

  1. Compile the custom SCL block in SIMATIC Manager; confirm 0 Errors.
  2. Open a test CFC chart and insert the compiled FB.
  3. In S7-PLCSIM, set ModeSelect = 5, DecrInput = 0; verify AccumulatorValue increments by 19500.0 every execution cycle.
  4. Set DecrInput = 1, IncrInput = 0; verify AccumulatorValue decrements by 19500.0.
  5. Set ModeSelect = 11; verify ModeStatus reports 11.
  6. Confirm the block executes deterministically inside cyclic interrupt OB35 with zero cycle overruns.

Limitations and Operational Precautions

  • Sampling Time Sensitivity: In the legacy S5 program, the code may have executed once per OB1 scan. In PCS 7, placing the block into OB35 executes it at a fixed interval (e.g. 100 ms). Ensure the increment rate accounts for the exact cyclic interrupt sample time.
  • Avoid GOTO in SCL: While SCL supports the GOTO statement, its use is considered poor engineering practice in PCS 7. Always use structured IF, CASE, or WHILE constructs.
  • Signal Inversion Nuances: Note that in S5, UN (Und Nicht) checks for a 0 signal state. In SCL, this translates to IF NOT Signal THEN.

Engineer FAQ

Why did the S5 to S7 Converter produce code that won't run in CFC?

The Siemens S5-S7 Converter generates linear STL code designed for standard S7-300/400 Classic controllers. It does not generate CFC block types or PCS 7 driver structures.

What is the difference between S5 floating point (KG) and S7 REAL?

S5 used a proprietary 32-bit floating-point format with a different exponent bias and mantissa sign bit. S7 adheres strictly to standard IEEE 754 floating-point encoding.

Can I compile STL code directly into a CFC block?

Yes, you can write a Function Block in STL with formal input/output parameters and place it into CFC, but SCL is far superior for maintaining readable mathematical and branching logic.

Technical References

Related Articles

Related Tags

  • S5 Migration
  • SCL
  • CFC
  • STL Jumps
  • SPB
  • PCS 7 Engineering
6 respuestas