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.
Use the agent to help review
Section titled “Use the agent to help review”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?What to check manually
Section titled “What to check manually”1. SET / RESET coil patterns
Section titled “1. SET / RESET coil patterns”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.
2. Timer instance calls
Section titled “2. Timer instance calls”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
3. FB instance calls with many parameters
Section titled “3. FB instance calls with many parameters”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.4. Transition conditions between networks
Section titled “4. Transition conditions between networks”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.
5. Data types
Section titled “5. Data types”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.
Known structural limitations
Section titled “Known structural limitations”| 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 |
Compile first, then test
Section titled “Compile first, then test”Before downloading to a PLC:
- Import and compile in TIA Portal. Use Compile → Software to check for type errors and reference issues.
- Test offline if possible using PLCSIM Advanced.
- Do a controlled online test — monitor the block inputs and outputs against known-good values from the original Ladder behaviour.
Documenting what changed
Section titled “Documenting what changed”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.