A programming language for a P
rogrammableLogicController (PLC). LadderLogic
is used heavily in automation and S
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.
- I1 Pushbutton Start
- Electrically Normally Open Contact, closed momentarily by Operator Action
- I2 Pushbutton Stop
- Electrically Normally Closed Contact, opened momentarily by Operator Action
- O1 Motor Contactor
- Electrically Similar to Heavy Duty Relay with overcurrent functions, when actuated starts and continues to run the motor until Pushbutton Stop or Permissive to Start/Run interrupt and open the auxiliary contact on the Motor Contactor used to Seal the Starter.
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.
- C1 Required to Start
- C2 Permissive to Start/Run
Other means of programming of ControlSystem?
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
. 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...")
- you probably won't have to do so, and will likely never be required to do so, since millions of programs written by thousands of people trained specifically to do so, are already making it possible for thousands and thousands of products, take bread, for an example, it is mixed, baked, boxed and then loaded for transport to your local market using equipment controlled by LadderLogic. Another example: An automobile is built with a great number of PLCs controlling robots, conveying systems, and other automated machinery . Once completed and tested, the programs will work until the hardware has a malfunction, or a mechanical component fails, or the Mechanical System in modified or replaced. It is rare, once running, that a LadderLogic program will require updates or require reprogramming 18 months down the line because of an OperatingSystem change. Programs written twenty or more years ago are still running and performing nicely. LadderLogic is nothing like building with toothpicks. It is more like building with stainless steel lego blocks. -- DonaldNoyes
Given these deficiencies, the fact that ladder is probably the most commonly used language for Safety Critical Control Systems is quite scary. -- DavidSarahHopwood
are hardwired, software might include Operator Notifications, such as Audible and Visual Alarms. For more on Safety
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.
- It is considered an Engineered product, and as such is prepared and signed off by Professional Engineers.
- It is made in ladder form for maintenance purposes because it mimics wired electrical controls and was created first as a substitute for wired control panels.
- Those who are necessarily familiar with it are mostly those who are familiar with electrical controls and actuators and are charged with the maintenance of both the ladders and the field devices connected to the controllers employing it. They are familiarized and trained in every new system to enable full and proper maintenance of the equipment controlled within the system.
- Life and Safety Critical systems are subject to strenuous, standardized and exhaustive testing before employment and must follow legal codes and standards before being utilized. It should cause no one concern that ladder logic can be utilized under such controls and standards and that it might be one of the components in the operation of SafeSystems? or CriticalSystems?.
- Because of its continuing employment and success, and the wide acceptance of it as a cost and operationally successful technology, LadderLogic will probably be around for many years to come.
- As stated above, there are other means which are employed in programming and using PLCs.
- There also exist preformatted special elements which carry out specific functions in the software system as well as electronic elements which allow communication between and control of groups and separated machines and field devices within in an overall ControlSystem? which is and must be synchronized and integrated.
- As new field devices become employed using SmartSensors? and EmbeddedControls?, it is likely that LadderLogic will continue to be widely and successfully employed for decades to come.
What is IEC-1131?
Developed with the input of vendors, end-users and academics, IEC 1131 consists of five parts:
- General information
- Equipment and test requirements
- PLC programming languages
- User guidelines
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:
- Ladder diagram (LD)
- Sequential Function Charts (SFC)
- Function Block Diagram (FBD)
- Structured Text (ST)
- Instruction List (IL)
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.