Ladder Logic

A programming language for a ProgrammableLogicController (PLC). LadderLogic is used heavily in automation and SupervisoryControlAndDataAcquisition systems.


Simple Example (I - Digital Inputs) (O - Digital Outputs) (C - Conditional Contact)

 |  Pushbutton  Required     Pushbutton     Permissive To       Motor      |
 |     Start    To Start       Stop           Start/Run       Contactor    |
 |     I1          C1           I2               C2               O1       |
 +-----] [-----+---] [----+------]/[------+------] [------+------(  )------+
 |                        |                                                |
 |  Seal in Contact       |                                                |
 |      O1                |                                                |
 +------] [---------------+                                                |
 |
Note that for the contacts represented in the logic diagram above, there is a one to one relationship between the symbols I1, I2, O1, and the physical device which is electrically wired to an input or output module of the PLC. C1 and C2 represent operating conditions which are the result of a number of inputs and outputs combined with logic to singly represent complex relationships and a desired functionality. Other means of programming of ControlSystem?s exist.

This is the LadderLogic representation of a control (Stop-Start with Permissives).

Is it TuringComplete? Above are shown AND and OR; additionally it would need NOT, delays (either fixed or programmable, and in practice achievable as a side effect of other things, like NOT NOT), and cycles/feedback, to be TuringComplete. Does it have those, or equivalents?

As far as what is included, the sets of functions not only include NOT, & Timers, but a host of other functions as well.

Typical implementations of ladder are TuringComplete, just about, as is the standardized IEC-1131 version. The "]/[" gate in the above example is negated; it means "not I2". It isn't possible to negate an arbitrary subexpression (except in Mitsubishi's implementation), so you sometimes have to add temporary relays for that, in cases where applying DeMorgansLaws would be too complicated.

Programmable delay timers and up-down counters are always supported, and most implementations have conditional GOTOs and subroutines (even though these break the relay/gate metaphor), but see below. Array indexing is supported, but differently by every implementation.

Overall, ladder is one of the worst languages I've ever had the misfortune to have to program in. It is almost impossible to achieve OnceAndOnlyOnce; ladder programs often contain vast amounts of almost identical DuplicatedCode. Even though the language is not TuringComplete without conditional jumps, trying to use jumps to avoid duplication is a disaster in practice, because the notation doesn't give you any indication of the control structure. Don't get me started on the proprietary programming environments you have to use.

The most serious problem with ladder is the difficulty in avoiding race conditions, especially in code that uses pulses that last for a single cycle. Most of the time, the order of rungs in a ladder program doesn't matter, but it does if you have one of these race conditions. See http://www.cs.ucdavis.edu/~su/publications/sttt00.pdf

(Nice quote: "I liken writing a program in Ladder Logic to building a house out of toothpicks; yes, you can do it, but...")

Given these deficiencies, the fact that ladder is probably the most commonly used language for Safety Critical Control Systems is quite scary. -- DavidSarahHopwood

SafetyCriticalSystems? are hardwired, software might include Operator Notifications, such as Audible and Visual Alarms. For more on SafetyCriticalSystems:


Because of its wide acceptance, the standards and design employed in its use, together with training of those who must employ and maintain the machines employing it, it is, has been and will be utilized successfully in such widely diverse applications as that of controlling the power plants which generate your electricity, manufacture your automobiles, produce your gasoline, prepare and package your food, manufacture many of the products you use, also to sort, store and pick and distribute items in warehouses, and so on. LadderLogic can be said to be one of the most consistently successful programming techniques for a number of reasons beyond that of programming issues.

-- DonaldNoyes


What is IEC-1131?

Developed with the input of vendors, end-users and academics, IEC 1131 consists of five parts:

  1. General information
  2. Equipment and test requirements
  3. PLC programming languages
  4. User guidelines
  5. Communications

IEC 1131-3 is the international standard for programmable controller programming languages. As such, it specifies the syntax, semantics and display for the following suite of PLC programming languages:


One of the primary benefits of the standard is that it allows multiple languages to be used within the same programmable controller. This allows the program developer to select the language best suited to each particular task. An analogy is that a mechanic wouldn't attempt to repair an automobile using only a screwdriver. The mechanic has a variety of tools available and chooses the best one for each task. Follow the above links for a description of each of the IEC 1131-3 languages and the types of applications they are best suited to.

From: http://www.software.rockwell.com/corporate/reference/Iec1131/


CategoryProgrammingLanguage CategoryControlSystemsSoftware


EditText of this page (last edited October 12, 2013) or FindPage with title or text search