PLC Programming

Ladder Logic vs Structured Text: One Start/Stop Program in LAD, ST and SCL

Simon Adamek 9 min read

Ladder logic or Structured Text? The fastest way to understand the difference is not a feature list, but one program written in both languages. In this tutorial we take the classic motor start/stop circuit with a seal-in and write it four ways: as a ladder rung, as a Structured Text expression, as an IF / ELSIF statement and as SCL in TIA Portal. Then we compare what each version is good at, and show where to try both side by side in a free online PLC simulator.

The same start/stop program in ladder logic and Structured Text side by side in Virtual PLC Sim
One start/stop program: ladder logic on the left, Structured Text on the right.

The task: motor start/stop with seal-in

A motor is controlled by two momentary push buttons. Pressing START runs the motor, and the motor must keep running after START is released. Pressing STOP stops it, and STOP must win when both buttons are pressed. A green RUN lamp shows that the motor is on.

TagDirectionDeviceWhat TRUE means
Startinputmomentary NO push buttonSTART is pressed
Stopinputmomentary NC push buttonSTOP is released and its circuit is healthy
Motoroutputmotor contactormotor runs
RunLampoutputgreen pilot lampRUN lamp is on

Note the STOP input. The button is wired normally closed, so the input is TRUE while nobody presses it. Pressing STOP or breaking the wire makes it FALSE and stops the motor. This is why STOP appears as a normally open instruction in the program: the instruction tests the signal, not the physical contact type.

The logic in one line of Boolean algebra:

Motor = Stop AND (Start OR Motor)

The motor output reads its own previous state. That feedback is the seal-in, also called a holding or latching branch.

Version 1: ladder logic

In ladder logic the same idea looks like a contactor circuit. START and a contact of the motor itself are connected in parallel, and STOP is in series with the whole parallel group.

Ladder logic start/stop seal-in rung in Virtual PLC Sim with Start and Motor in parallel and Stop in series
Rung 0: START in parallel with the Motor contact, in series with STOP. Rung 1: the RUN lamp follows the motor.
// Rung 0
 Start        Stop      Motor
--+--[ ]--+----[ ]-----( )--
  | Motor |
  +--[ ]--+
// Rung 1
 Motor              RunLamp
-----[ ]-----------( )--

What ladder does well here:

  • It reads like a schematic. An electrician who has never programmed a PLC can follow the rung.
  • Online monitoring is visual. In a running controller you see the green power flow and spot which contact blocks the path.
  • STOP priority is visible. STOP sits in series with both branches, so nothing can bypass it.

Version 2: Structured Text as a Boolean expression

In Structured Text the rung becomes one assignment. The parentheses do the job of the parallel branch:

(* Motor start/stop with seal-in *)
Motor := (Start OR Motor) AND Stop;
RunLamp := Motor;

It is short and exact, but notice what you lose. When the motor does not start, you see a single FALSE result and have to evaluate the expression in your head. For two inputs that is easy; for twelve conditions it is not.

Version 3: Structured Text with IF / ELSIF

The same behaviour can be written as a decision. This is the version many programmers prefer, because the priority of STOP is stated explicitly:

Structured Text start/stop program with IF NOT Stop THEN and ELSIF Start THEN in Virtual PLC Sim
The IF / ELSIF version running in the simulator, with live values next to every tag.
(* Stop is TRUE when the NC button is released. *)
IF NOT Stop THEN
    Motor := FALSE;
ELSIF Start THEN
    Motor := TRUE;
END_IF;
RunLamp := Motor;

There is no seal-in branch here. If neither condition is true, the IF statement does not touch Motor, so the output simply keeps its value from the previous scan. The memory is in the variable, not in a feedback contact. Because STOP is checked first, it wins when both buttons are pressed.

Version 4: SCL in TIA Portal

SCL is Siemens' implementation of IEC 61131-3 Structured Text, so the logic is identical. The visible difference in TIA Portal is the tag syntax: global PLC tags are written in double quotes, and local block variables start with #.

// Global PLC tags in TIA Portal
"Motor" := ("Start" OR "Motor") AND "Stop";
"RunLamp" := "Motor";

Or with the explicit STOP priority:

IF NOT "Stop" THEN
    "Motor" := FALSE;
ELSIF "Start" THEN
    "Motor" := TRUE;
END_IF;

If you know Structured Text from CODESYS or Connected Components Workbench, you can read SCL from day one. For more SCL examples, see The SCL Text Language and PLC Programming.

Elmark Automatyka

Allen-Bradley hardware used in our materials (Micro800 controllers, HMI panels and accessories) is supplied by our technology partner Elmark Automatyka, an authorized Rockwell Automation distributor.

Bonus: the SET/RESET version

There is a fourth common pattern: set and reset coils. START sets the motor, STOP resets it.

// Rung 0
 Start          Motor
-----[ ]--------(S)--
// Rung 1
 Stop           Motor
-----[/]--------(R)--

In Structured Text:

IF Start THEN
    Motor := TRUE;
END_IF;
IF NOT Stop THEN
    Motor := FALSE;
END_IF;

Here the order matters. The reset is executed after the set, so when both buttons are pressed, the reset is the last write in the scan and STOP wins. Swap the two rungs and START would win. The STOP instruction here is normally closed, because the reset must act when the STOP signal is FALSE.

Ladder logic vs Structured Text: comparison

CriterionLadder logic (LD, LAD)Structured Text (ST, SCL)
Readability for electricians and maintenancevery high, looks like a schematiclower, needs programming background
Online troubleshootingvisual power flow, fast to find the blocking contactvalues per variable, slower for long conditions
Boolean interlocks and machine I/Onatural fitworks, but long expressions get hard to read
Math, data, loops and arraysawkwardnatural fit
Sequences and state machinespossible, many rungscompact with CASE
Code reuse and version controlharder to compareplain text, easy to diff in Git

In practice, most machine programs mix both. Interlocks, safety-related permissives and I/O mapping are often in ladder, because the maintenance team reads them at 3 a.m. Calculations, recipes, communication and state machines go to Structured Text. The Micro800 beginner guide to Structured Text and ladder shows the same split on a real controller.

Does the language change scan time?

For simple Boolean logic like this start/stop circuit, the difference in scan time between ladder logic and Structured Text is usually negligible. Both are compiled to machine code by the controller's engineering tool, and the result depends far more on the controller, the compiler and how the program is written than on the editor you used. Structured Text can be faster for heavy math or loops over arrays, simply because it expresses them more directly. If timing really matters, measure the cycle time on your target controller instead of guessing.

Other IEC 61131-3 languages and vendor platforms

Ladder logic and Structured Text are two of the languages defined by IEC 61131-3. The others are Function Block Diagram (FBD), Sequential Function Chart (SFC) for step sequences and the older Instruction List (IL), which the standard has marked as deprecated. Siemens STL is a similar text language in older Siemens controllers.

Which languages you can use depends on the platform:

  • Siemens TIA Portal: LAD, FBD, SCL, GRAPH (SFC) and STL on S7-1500.
  • Rockwell Studio 5000 (ControlLogix, CompactLogix): ladder diagram, function block diagram, structured text and SFC.
  • Rockwell Connected Components Workbench (Micro800): ladder diagram, function block diagram and structured text.
  • CODESYS: all IEC 61131-3 languages, plus CFC.

You can mix languages in one project: a ladder routine for interlocks can call a Structured Text function block for calculations. That combination is common in real machine programs.

Three common mistakes

  • STOP only in the START branch. Then the holding branch bypasses STOP and the motor cannot be stopped. STOP must be in series with the whole parallel group.
  • A normally closed instruction for an NC button. The NC wiring already makes the signal TRUE when released. Inverting it again in the program reverses the logic.
  • Testing with START held down. A missing seal-in is invisible while START is pressed. Always test a short press followed by release.

Try it in the simulator

You can write both versions next to each other in Virtual PLC Sim, a free online PLC simulator. The Allen-Bradley Micro850 profile has ladder (LD) and Structured Text sheets, and the Siemens S7-1200 profile has LAD and SCL. Add a second sheet, switch between them and watch live values change as you press START and STOP.

The free sandbox lets you build the principle with your own tags. The full start/stop exercises with automatic checks are part of the course exercise path. The public tutorial PLC Motor Start/Stop with Seal-In Logic explains the test sequence step by step, and the complete guide to Virtual PLC Sim lists every exercise.

This is an educational control circuit, not a safety-rated emergency stop design. Real emergency stop functions need safety-rated hardware and a risk assessment.

Learn ladder logic and Structured Text properly

FAQ

Is ladder logic better than Structured Text?

Neither is better in general. Ladder logic is better for Boolean interlocks and for troubleshooting by maintenance teams. Structured Text is better for math, data handling, loops and state machines. Most programs use both.

Are LAD and LD the same language?

Yes. LD (Ladder Diagram) is the IEC 61131-3 name, and LAD is the name Siemens uses for the same ladder language in TIA Portal. Rockwell and CODESYS use LD.

What is a seal-in circuit in a PLC?

A seal-in, holding or latching circuit keeps an output on after a momentary input is released. In ladder logic it is a contact of the output itself, connected in parallel with the START contact.

Why is the STOP button wired normally closed?

For safety of the control function. With an NC button, a broken wire has the same effect as pressing STOP, so the machine stops instead of becoming impossible to stop.

Is SCL the same as Structured Text?

SCL is Siemens' implementation of IEC 61131-3 Structured Text. The syntax is almost the same; the main differences are TIA Portal specifics such as quoted global tags and # for local variables.

Should I learn ladder logic or Structured Text first?

Most beginners start with ladder logic, because it shows the logic visually. Learn Structured Text next, because you will need it for anything beyond simple I/O logic.

Author Simon Adamek

The ControlByte team - automation engineers who teach PLC programming on real projects.

Online courses

Want to program PLCs in practice?

Siemens, CODESYS, communication and safety courses with a certificate and instructor support. Start with a free mini-course.

See courses
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare