Skip to content

Reviewing SCL Output

AI-generated code should always be reviewed before it goes into a live machine. This page describes what to look for when checking the SCL output from a Ladder migration.

The agent can review its own output critically:

Review the migrated SCL for FB_MotorControl.
Flag any logic that differs from what a direct Ladder-to-SCL translation would produce.
Pay special attention to timer resets, set/reset coils, and FB instance calls.
Compare network 5 in the original PDF to the migrated SCL.
Is the reset condition correctly implemented?

Ladder SET/RESET (SR) coils have priority semantics — if both SET and RESET are energised in the same scan, the last one wins based on rung order.

In SCL, the equivalent is:

IF reset_condition THEN
output := FALSE;
END_IF;
IF set_condition THEN
output := TRUE;
END_IF;

The order matters. Confirm the agent preserved the correct priority.

IEC timers (TON, TOF, TP) are FB instances — each call in Ladder is a distinct instance with its own state. Check that:

  • Each timer uses a unique instance name (e.g. TON_1, TON_2)
  • The PT (preset time) matches the original
  • The IN (enable) condition matches the original rung contacts exactly

Complex FB calls (e.g. motion or PID blocks with 10+ parameters) are the most likely source of migration errors. The PDF may not clearly show all parameter assignments.

Read the PDF page for network 8 again and compare each parameter name and value to the SCL call.

Some programs use outputs from one network as inputs to the next (implicit sequencing). Confirm the variable names used as outputs match exactly what the next network expects as inputs.

Ladder contacts and coils are BOOL. If the PDF shows numeric comparisons (e.g. =, >) against constants, check the data type of the comparison operand matches the variable’s declared type in the block interface.

Situation What happens What to do
FB instance call structure in Ladder The agent reconstructs from PDF — parentheses and parameter assignments are inferred Verify all parameter names and values against the original
ENO := TRUE patterns ENO handling may be simplified or omitted Acceptable unless your program explicitly reads ENO downstream
Ladder comment text Preserved as // comments; formatting may vary Cosmetic only
Unmapped scopes in XML export Some rare variable types render as blank Check for any unexpected blank expressions in the output

Before downloading to a PLC:

  1. Import and compile in TIA Portal. Use Compile → Software to check for type errors and reference issues.
  2. Test offline if possible using PLCSIM Advanced.
  3. Do a controlled online test — monitor the block inputs and outputs against known-good values from the original Ladder behaviour.

After migration, update the block’s comment in TIA Portal to note it was AI-migrated:

// Migrated from LAD to SCL by S7 PLC Buddy on 2026-07-22.
// Source: MotorControl_LAD.pdf, 12 networks.
// Reviewed by: [your name]

This helps future engineers understand the block’s history.