IEC 61131-3 defines five PLC programming languages. Two dominate practical use: Ladder Diagram (LD) and Structured Text (ST). Each has clear strengths – and knowing when to use each is a mark of a seasoned automation engineer.
Ladder Diagram
Ladder logic evolved from relay panel diagrams. Its visual metaphor – rungs between two power rails – makes it intuitive for electrical engineers and maintenance technicians who understand relays.
Best for:
- Discrete I/O control (motors, valves, sensors)
- Sequential machine logic (start/stop, interlocks)
- Sites where maintenance staff need to read the code
- Safety functions requiring IEC 62061 / IEC 61511 review
Limitations: Verbose for mathematical calculations. Poorly suited to data manipulation, string handling, or algorithm implementation.
Structured Text
Structured Text reads like Pascal or C. It supports full programming constructs: FOR loops, WHILE loops, CASE statements, functions, and function blocks.
Best for:
- PID algorithms, recipe management, data calculations
- String manipulation and data parsing
- Complex sequencing (state machines)
- IIoT data processing and edge computing logic
The Practical Approach: Use Both
Most professional programs combine both languages. A common pattern:
- Write equipment interlocks and discrete I/O in Ladder (readable by electricians)
- Implement analog scaling, PID, and data handling in Structured Text (compact and maintainable)
- Use Function Block Diagram (FBD) for control loop configurations
State Machine Pattern in Structured Text
One of the most powerful ST patterns is the CASE-based state machine:
CASE eState OF
STATE_IDLE:
IF xStartCmd THEN eState := STATE_RUNNING; END_IF;
STATE_RUNNING:
rOutput := rSetpoint * rGain;
IF xFaultDetected THEN eState := STATE_FAULT; END_IF;
STATE_FAULT:
rOutput := 0.0;
IF xFaultReset THEN eState := STATE_IDLE; END_IF;
END_CASE;
This pattern is deterministic, easy to test, and maps directly to the equipment mode structure required by ISA-88 batch standards.
Decision Guide
- Use LD when the code will be read by non-programmers or when discrete control clarity matters
- Use ST when logic is algorithmic, mathematical, or involves complex data structures
- Mix both in any real-world project – there’s no rule that says you must pick one

