Ladder logic

Ladder logic was originally a written method to document the design and construction of relay racks as used in manufacturing and process control.

The name is based on the observation that programs in this language resemble ladders, with two vertical rails and a series of horizontal rungs between them.

Ladder diagrams were once the only way to record programmable controller programs, but today, other forms are standardized in IEC 61131-3.

For example, instead of the graphical ladder logic form, there is a language called Structured text, which is similar to C, within the IEC 61131-3 standard.

Ladder logic is widely used to program PLCs, where sequential control of a process or manufacturing operation is required.

Ladder logic is useful for simple but critical control systems or for reworking old hardwired relay circuits.

[2] Implementations of ladder logic may have characteristics, such as sequential execution and support for control flow features, that make the analogy to hardware somewhat inaccurate.

When implemented in a programmable logic controller, the rules are typically executed sequentially by software in a continuous loop, or "scan".

A way to recall these is to imagine the checkers (contacts) as a push button input, and the actuators (coils) as a light bulb output.

After the circuit is latched the "Stop" button may be pushed causing its NC contact to open and consequently the input to go false.

For safety reasons, an emergency stop ("ES") may be hardwired in series with the "Start" switch, and the relay logic should reflect this.

They include timers, arithmetic operators and comparisons, table lookups, text processing, PID control, and filtering functions.

The large library of special blocks along with high-speed execution has allowed use of PLCs to implement very complex automation systems.

Like all parallel programming languages, the sequential order of operations may be undefined or obscure; logic race conditions are possible which may produce unexpected results.

Analog quantities and arithmetical operations are clumsy to express in ladder logic and each manufacturer has different ways of extending the notation for these problems.

There is usually limited support for arrays and loops, often resulting in duplication of code to express cases that in other languages would call for use of indexed variables.

Part of a ladder diagram, including contacts and coils, compares, timers and monostable multivibrators