Revision as of 13:08, 14 December 2014 edit86.174.67.173 (talk) Undid revision 637959743 by Wtshymanski (talk)Still no linked clue.← Previous edit | Latest revision as of 01:08, 1 July 2024 edit undoKvng (talk | contribs)Extended confirmed users, New page reviewers107,736 edits Restored revision 1188984166 by MrOllie (talk): Restore last known goodTags: Twinkle Undo | ||
(158 intermediate revisions by 90 users not shown) | |||
Line 1: | Line 1: | ||
{{Short description|Programming language for industrial controllers}} | |||
{{about|the programming language|the FIRST competition|Ladder Logic}} | |||
{{about|the programming language|the FIRST competition game|Ladder Logic}} | |||
{{refimprove|date=May 2012}} | {{refimprove|date=May 2012}} | ||
'''Ladder logic''' was originally a written method to document the design and construction of relay racks as used in manufacturing and process control.<ref>http:// |
'''Ladder logic''' was originally a written method to document the design and construction of ] as used in manufacturing and ].<ref>{{cite web |url=http://ecmweb.com/archive/basics-ladder-logic |title=The Basics of Ladder Logic |quote=Ladder logic uses switch or relay contacts to implement Boolean expressions. In years past, ladder logic was made possible with discrete relays and was sometimes termed relay logic.}}</ref> Each device in the relay rack would be represented by a symbol on the ladder diagram with connections between those devices shown. In addition, other items external to the relay rack such as pumps, heaters, and so forth would also be shown on the ladder diagram. | ||
'''Ladder logic''' has evolved into a ] that represents a program by a graphical diagram based on the ]s of ] hardware. Ladder logic is used to develop software for ]s (PLCs) used in industrial control applications. The name is based on the observation that programs in this language resemble ]s, with two vertical rails and a series of horizontal rungs between them. While ladder diagrams were once the only available notation for recording programmable controller programs, today other forms are standardized in ]. | |||
Ladder logic has evolved into a ] that represents a program by a graphical diagram based on the ]s of ] hardware. Ladder logic is used to develop software for ]s (PLCs) used in industrial control applications. The name is based on the observation that programs in this language resemble ]s, with two vertical rails and a series of horizontal rungs between them. While ladder diagrams were once the only available notation for recording programmable controller programs, today other forms are standardized in ] (For example, as an alternative to the graphical ladder logic form, there is also a language more like C called ] within the ] standard). | |||
==Overview== | ==Overview== | ||
] and ]s]] | |||
Ladder logic is widely used to program ]s, 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 ] relay circuits. As programmable logic controllers became more sophisticated it has also been used in very complex automation systems. Often the ladder logic program is used in conjunction with an ] program operating on a computer workstation. | |||
The motivation for representing ] ] in a ladder diagram was to allow factory engineers and technicians to develop software without additional training to learn a language such as ] or other general-purpose computer language. Development and maintenance were simplified because of the resemblance to familiar relay hardware systems.<ref name="Kamen99">Edward W. Kamen ''Industrial Controls and Manufacturing'', (Academic Press, 1999) {{ISBN|0123948509}}, Chapter 8 ''Ladder Logic Diagrams and PLC Implementations''</ref> 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. | |||
Ladder logic can be thought of as a ] rather than a ]. A "rung" in the ladder represents a rule. When implemented with relays and other electromechanical devices, the various rules execute simultaneously and immediately. When implemented in a programmable logic controller, the rules are typically executed sequentially by software in a continuous loop, or "scan". By executing the loop fast enough, typically many times per second, the effect of simultaneous and immediate execution is achieved. Proper use of programmable controllers requires an understanding of the limitations of the execution order of rungs. | |||
] and ]s]] | |||
Ladder logic is widely used to program ]s, 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 ] relay circuits. As programmable logic controllers became more sophisticated it has also been used in very complex automation systems. Often the ladder logic program is used in conjunction with an ] program operating on a computer workstation. | |||
The motivation for representing sequential control logic in a ladder diagram was to allow factory engineers and technicians to develop software without additional training to learn a language such as FORTRAN or other general purpose computer language. Development, and maintenance, was simplified because of the resemblance to familiar relay hardware systems.<ref name="Kamen99">Edward W. Kamen ''Industrial Controls and Manufacturing'', (Academic Press, 1999) ISBN 0123948509, | |||
Chapter 8 ''Ladder Logic Diagrams and PLC Implementations''</ref> Implementations of ladder logic have characteristics, such as sequential execution and support for control flow features, that make the analogy to hardware somewhat inaccurate. This argument has become less relevant given that most ladder logic programmers have a software background in more conventional ]s. | |||
Manufacturers of programmable logic controllers generally also provide associated ladder logic programming systems. Typically the ladder logic languages from two manufacturers will not be completely compatible; ladder logic is better thought of as a set of closely related programming languages rather than one language. (The ] standard has helped to reduce unnecessary differences, but translating programs between systems still requires significant work.) Even different models of programmable controllers within the same family may have different ladder notation such that programs cannot be seamlessly interchanged between models. | |||
Ladder logic can be thought of as a rule-based language rather than a ]. A "rung" in the ladder represents a rule. When implemented with relays and other electromechanical devices, the various rules "execute" simultaneously and immediately. When implemented in a programmable logic controller, the rules are typically executed sequentially by software, in a continuous loop (scan). By executing the loop fast enough, typically many times per second, the effect of simultaneous and immediate execution is achieved, if considering intervals greater than the "scan time" required to execute all the rungs of the program. Proper use of programmable controllers requires understanding the limitations of the execution order of rungs. | |||
==Syntax and examples== | |||
== Example of a simple ladder logic program == | |||
The language itself can be seen as a set of connections between logical checkers (contacts) and actuators (coils). If a path can be traced between the left side of the rung and the output, through asserted (true or "closed") contacts, the rung is true and the output coil storage bit is asserted (1) or true. If no path can be traced, then the output is false (0) and the "coil" by analogy to electromechanical ]s is considered "de-energized". The analogy between logical propositions and relay contact status is due to ]. | The language itself can be seen as a set of connections between logical checkers (contacts) and actuators (coils). If a path can be traced between the left side of the rung and the output, through asserted (true or "closed") contacts, the rung is true and the output coil storage bit is asserted (1) or true. If no path can be traced, then the output is false (0) and the "coil" by analogy to electromechanical ]s is considered "de-energized". The analogy between logical propositions and relay contact status is due to ]. | ||
Line 28: | Line 23: | ||
Each rung of ladder language typically has one coil at the far right. Some manufacturers may allow more than one output coil on a rung. | Each rung of ladder language typically has one coil at the far right. Some manufacturers may allow more than one output coil on a rung. | ||
; Rung input: Checkers (contacts){{bulleted list | |||
* <code>—( )—</code> A regular coil, energized whenever its rung is closed. | |||
| <code>——</code> Normally open contact, closed whenever its corresponding coil or an input which controls it is energized. (Open contact at rest.) | |||
| <code>——</code> Normally closed ("not") contact, closed whenever its corresponding coil or an input which controls it is not energized. (Closed contact at rest.) | |||
}} | |||
* <code>——</code> A "not" contact, closed whenever its corresponding coil or an input which controls it is not energized. | |||
; Rung output: Actuators (coils){{bulleted list | |||
| <code>—( )—</code> Normally inactive coil, energized whenever its rung is closed. (Inactive at rest.) | |||
| <code>—(\)—</code> Normally active ("not") coil, energized whenever its rung is open. (Active at rest.) | |||
}} | |||
The "coil" (output of a rung) may represent a physical output which operates some device connected to the programmable controller, or may represent an internal storage bit for use elsewhere in the program. | The "coil" (output of a rung) may represent a physical output which operates some device connected to the programmable controller, or may represent an internal storage bit for use elsewhere in the program. | ||
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. The presence of a slash within the checkers or actuators would indicate the default state of the device at rest. | |||
===Logical AND=== | ===Logical AND=== | ||
{| | |||
------------------------------------( ) | |||
|<pre> | |||
Key Switch 1 Key Switch 2 Door Motor | |||
------------------------------------( ) | |||
The above realizes the function: Door Motor = Key Switch 1 ] Key Switch 2 | |||
Key switch 1 Key switch 2 Door motor | |||
</pre> | |||
|} | |||
The above realizes the function: Door motor = Key switch 1 ] Key switch 2 | |||
This circuit shows two key switches that security guards might use to activate an electric motor on a bank vault door. When the normally open contacts of both switches close, electricity is able to flow to the motor which opens the door. | This circuit shows two key switches that security guards might use to activate an electric motor on a bank vault door. When the normally open contacts of both switches close, electricity is able to flow to the motor which opens the door. | ||
===Logical AND with NOT=== | ===Logical AND with NOT=== | ||
{| | |||
|<pre> | |||
------------------------------------( ) | ------------------------------------( ) | ||
Close |
Close door Obstruction Door motor | ||
</pre> | |||
The above realizes the function: Door Motor = Close door ] ](Obstruction). | |||
|} | |||
The above realizes the function: Door motor = Close door ] ](Obstruction). | |||
This circuit shows a |
This circuit shows a push button that closes a door and an obstruction detector that senses if something is in the way of the closing door. When the normally open push button contact closes and the normally closed obstruction detector is closed (no obstruction detected), electricity is able to flow to the motor which closes the door. | ||
===Logical OR=== | ===Logical OR=== | ||
{| | |||
|<pre> | |||
--+--------------+-----------------( ) | --+--------------+-----------------( ) | ||
| Exterior unlock | Unlock | |||
| | | | | | ||
|
+--------------+ | ||
Interior unlock | |||
</pre> | |||
The above realizes the function: Unlock = Interior Unlock ] Exterior Unlock | |||
|} | |||
The above realizes the function: Unlock = Interior unlock ] Exterior unlock | |||
This circuit shows the two things that can trigger a car's ]. The remote receiver is always powered. The |
This circuit shows the two things that can trigger a car's ]. The remote receiver is always powered. The unlock ] gets power when either set of contacts is closed. | ||
===Industrial STOP/START=== | ===Industrial STOP/START=== | ||
In common industrial latching start/stop logic we have a " |
In common industrial latching start/stop logic we have a "Start" button to turn on a motor contactor, and a "Stop" button to turn off the contactor. | ||
When the "start" button is pushed the input goes true, via the "stop" button NC contact. When the "run" input becomes true the seal-in "run" NO contact in parallel with the "start" NO contact will close maintaining the input logic true (latched or sealed-in). After the circuit is latched the "stop" button may be pushed causing its NC contact to open and consequently the input to go false. The "run" NO contact then opens and the circuit logic returns to its quiescent state. | |||
<!-- This diagram currently matches the description above. Please do NOT alter it unless you can provide a reliable reference that the diagram (and the description above) is wrong. If you change the NC stop to NO, the arrangement doesn't work. See talk page. ---> | |||
When the "Start" button is pushed the input goes true, via the "Stop" button NC contact. When the "Run" input becomes true the seal-in "Run" NO contact in parallel with the "Start" NO contact will close maintaining the input logic true (latched or sealed-in). After the circuit is latched the "Stop" button may be pushed causing its NC contact to open and consequently the input to go false. The "Run" NO contact then opens and the circuit logic returns to its inactive state. | |||
<!-- This diagram currently matches the description above. Please do NOT alter it unless you can provide a reliable reference that the diagram (and the description above) is wrong. If you change the NC Stop to NO, the arrangement doesn't work. See talk page. ---> | |||
{| | |||
|<pre> | |||
--+------+--------( ) | --+------+--------( ) | ||
| Start | Stop Run | |||
| | | | | | ||
+------+ | +------+ | ||
|
Run | ||
</pre> | |||
<pre> | |||
---------------------( ) | ---------------------( ) | ||
|
Run Motor | ||
</pre> | |||
|} | |||
The above realizes the function: run = ( start ] run ) ] ( ] stop ) | |||
The above realizes the function: Run = (Start ] Run) ] (] Stop) | |||
:Note the use of parenthesis to group the logical OR function before evaluating the logical AND function (which has a higher order of operation priority). Also note the use of '''NOT''' to represent the "stop" NC contact logic. | |||
This ] configuration is a common ] in ladder logic. |
This ] configuration is a common ] in ladder logic. It may also be referred to as ''seal-in logic''. The key to understanding the latch is in recognizing that the "Start" switch is a momentary switch (once the user releases the button, the switch is open again). As soon as the "Run" solenoid engages, it closes the "Run" NO contact, which latches the solenoid on. The "Start" switch opening up then has no effect. | ||
: Note: In this example, "Run" represents the status of a ] in the ], while "Motor" represents the actual output to the real-world ] that closes the motor's real-world ]. | |||
For safety reasons, an |
For safety reasons, an emergency stop ("ES") may be hardwired in series with the "Start" switch, and the relay logic should reflect this. | ||
{| | |||
|<pre> | |||
----------+----+---------( ) | ----------+----+---------( ) | ||
ES Stop | Start | |
ES Stop | Start | Run | ||
| | | | | | ||
+----+ | +----+ | ||
Run | Run | ||
</pre> | |||
<pre> | |||
---------------------( ) | |||
Run Motor | |||
</pre> | |||
The above realizes the function: Run = (] ES) ] (] Stop) ] (Start ] Run) | |||
|} | |||
===Complex logic=== | ===Complex logic=== | ||
Here is an example of what two rungs in a ladder logic program might look like. In real |
Here is an example of what two rungs in a ladder logic program might look like. In real-world applications, there may be hundreds or thousands of rungs. | ||
Typically, complex ladder logic is 'read' left to right and top to bottom. As each of the lines (or rungs) are evaluated the output coil of a rung may feed into the next stage of the ladder as an input. In a complex system there will be many "rungs" on a ladder, which are numbered in order of evaluation. | |||
Typically, complex ladder logic is "read" left to right and top to bottom. As each of the lines (or rungs) are evaluated the output coil of a rung may feed into the next stage of the ladder as an input. In a complex system there will be many "rungs" on a ladder, which are numbered in order of evaluation: | |||
1. -------------+---------+----( ) | |||
{{ordered list | |||
| start = 1 | |||
| 1= Realising the function: A/C = Switch ] (HiTemp ] Humid). | |||
<pre> | |||
-------------+---------+----( ) | |||
Switch | HiTemp | A/C | Switch | HiTemp | A/C | ||
| | | | | | ||
+---------+ | +---------+ | ||
Humid | Humid | ||
</pre> | |||
| 2= Realising the function: Cooling = A/C ] (] Heat). | |||
2. ----------------------------( ) | |||
<pre> | |||
----------------------------( ) | |||
A/C Heat Cooling | A/C Heat Cooling | ||
</pre> | |||
}} | |||
This represents a slightly more complex system for rung 2. After the first line has been evaluated, the output coil "A/C" is fed into rung 2, which is then evaluated and the output coil "Cooling" could be fed into an output device "Compressor" or into rung 3 on the ladder. This system allows very complex logic designs to be broken down and evaluated. | |||
Line 1 realizes the function: A/C = Switch ] ( HiTemp ] Humid ) | |||
Line 2 realizes the function: Cooling = A/C ] ( ] Heat ) | |||
This represents a slightly more complex system for rung 2. After the first line has been evaluated, the output coil "A/C" is fed into rung 2, which is then evaluated and the output coil "Cooling" could be fed into an output device "Compressor" or into rung 3 on the ladder. | |||
This system allows very complex logic designs to be broken down and evaluated. | |||
===Additional functionality=== | ===Additional functionality=== | ||
Additional functionality can be added to a ladder logic implementation by the PLC manufacturer as a special block. When the special block is powered, it executes code on predetermined arguments. These arguments may be displayed within the special block. | Additional functionality can be added to a ladder logic implementation by the PLC manufacturer as a special block. When the special block is powered, it executes code on predetermined arguments. These arguments may be displayed within the special block. | ||
{| | |||
|<pre> | |||
+-------+ | +-------+ | ||
-------------------------+ A +---- | -------------------------+ A +---- | ||
Remote |
Remote unlock +-------+ | ||
Remote |
Remote counter | ||
</pre> | |||
<pre> | |||
+-------+ | |||
+-------+ | |||
-------------------------+ B +---- | -------------------------+ B +---- | ||
Interior |
Interior unlock +-------+ | ||
Interior |
Interior counter | ||
</pre> | |||
<pre> | |||
+--------+ | +--------+ | ||
--------------------+ A + B +----------- | --------------------+ A + B +----------- | ||
Line 126: | Line 155: | ||
+--------+ | +--------+ | ||
Adder | Adder | ||
</pre> | |||
|} | |||
In this example, the system will count the number of times that the interior and remote unlock buttons are pressed. This information will be stored in memory locations A and B. Memory location C will hold the total number of times that the door has been unlocked electronically. | |||
PLCs have many types of special blocks. They include timers, arithmetic operators and comparisons, table lookups, text processing, ] control, and filtering functions. More powerful PLCs can operate on a group of internal memory locations and execute an operation on a range of addresses, for example, to simulate a physical sequential drum controller or a ]. In some cases, users can define their own special blocks, which effectively are subroutines or macros. The large library of special blocks along with high-speed execution has allowed use of PLCs to implement very complex automation systems. | |||
In this example, the system will count the number of times that the interior and remote unlock buttons are pressed. This information will be stored in memory locations A and B. Memory location C will hold the total number of times that the door has been unlocked electronically. | |||
PLCs have many types of special blocks. They include timers, arithmetic operators and comparisons, table lookups, text processing, ] control, and filtering functions. More powerful PLCs can operate on a group of internal memory locations and execute an operation on a range of addresses, for example,to simulate a physical sequential drum controller or a ]. In some cases, users can define their own special blocks, which effectively are subroutines or macros. The large library of special blocks along with high speed execution has allowed use of PLCs to implement very complex automation systems. | |||
==Limitations and successor languages== | ==Limitations and successor languages== | ||
Ladder notation is best suited to control problems where only ] are required and where interlocking and sequencing of binary is the primary control problem. Like all ]s, the sequential order of operations may be undefined or obscure; logic ]s are possible which may produce unexpected results. Complex rungs are best broken into several simpler steps to avoid this problem. Some manufacturers avoid this problem by explicitly and completely defining the execution order of a rung, however, programmers may still have problems fully grasping the resulting complex semantics. | |||
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. | |||
Ladder notation is best suited to control problems where only binary variables are required and where interlocking and sequencing of binary is the primary control problem. Since execution of rungs is sequential within a program and may be undefined or obscure within a rung, some logic ]s are possible which may produce unexpected results; complex rungs are best broken into several simpler steps to avoid this problem. Some manufacturers avoid this problem by explicitly and completely defining the execution order of a rung, however programmers may still have problems fully grasping the resulting complex semantics. | |||
As ] have become more powerful, notations such as ]s and ]s can replace ladder logic for some limited applications. Some newer PLCs may have all or part of the programming carried out in a dialect that resembles ], ], or other ] with bindings appropriate for a real-time application environment. | |||
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 which in other languages would call for use of indexed variables. | |||
==Popularity== | |||
As ] have become more powerful, notations such as ]s and ]s can replace ladder logic for some limited applications. Very large programmable controllers may have all or part of the programming carried out in a dialect that resembles ] or ] or other ] with bindings appropriate for a real-time application environment. | |||
In 2019, IEEE Spectrum ranked ladder logic as number 50 out of 52 in a list of popular programming languages.<ref>{{Cite web |url=https://spectrum.ieee.org/static/interactive-the-top-programming-languages-2019 |archive-url=https://web.archive.org/web/20190918113106/https://spectrum.ieee.org/static/interactive-the-top-programming-languages-2019 |archive-date=2019-09-18 |title=Interactive: The Top Programming Languages |website=IEEE Spectrum}}</ref> | |||
== |
==See also== | ||
* ] | |||
*] | |||
*] | * ] | ||
*] | * ] | ||
* ] | |||
==References== | ==References== | ||
<references/> | <references/> | ||
==Further reading== | |||
== External links == | |||
* {{cite book |title=The Programmable Logic Controller: its prehistory, emergence and application |author-first=Mark John |author-last=Walker |date=2012-09-08 |type=PhD thesis |location=Department of Communication and Systems Faculty of Mathematics, Computing and Technology |publisher=] |url=http://oro.open.ac.uk/54687/1/594090.pdf |access-date=2018-06-20 |url-status=live |archive-url=https://web.archive.org/web/20180620115412/http://oro.open.ac.uk/54687/1/594090.pdf |archive-date=2018-06-20}} | |||
* | |||
* | |||
==External links== | |||
* | |||
* by Tony R. Kuphaldt | * by Tony R. Kuphaldt | ||
* | |||
] | ] | ||
] | |||
] | ] |
Latest revision as of 01:08, 1 July 2024
Programming language for industrial controllers This article is about the programming language. For the FIRST competition game, see Ladder Logic.This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Ladder logic" – news · newspapers · books · scholar · JSTOR (May 2012) (Learn how and when to remove this message) |
Ladder logic was originally a written method to document the design and construction of relay racks as used in manufacturing and process control. Each device in the relay rack would be represented by a symbol on the ladder diagram with connections between those devices shown. In addition, other items external to the relay rack such as pumps, heaters, and so forth would also be shown on the ladder diagram.
Ladder logic has evolved into a programming language that represents a program by a graphical diagram based on the circuit diagrams of relay logic hardware. Ladder logic is used to develop software for programmable logic controllers (PLCs) used in industrial control applications. 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. While ladder diagrams were once the only available notation for recording programmable controller programs, today other forms are standardized in IEC 61131-3 (For example, as an alternative to the graphical ladder logic form, there is also a language more like C called Structured text within the IEC 61131-3 standard).
Overview
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. As programmable logic controllers became more sophisticated it has also been used in very complex automation systems. Often the ladder logic program is used in conjunction with an HMI program operating on a computer workstation.
The motivation for representing sequential control logic in a ladder diagram was to allow factory engineers and technicians to develop software without additional training to learn a language such as FORTRAN or other general-purpose computer language. Development and maintenance were simplified because of the resemblance to familiar relay hardware systems. 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.
Ladder logic can be thought of as a rule-based language rather than a procedural language. A "rung" in the ladder represents a rule. When implemented with relays and other electromechanical devices, the various rules execute simultaneously and immediately. When implemented in a programmable logic controller, the rules are typically executed sequentially by software in a continuous loop, or "scan". By executing the loop fast enough, typically many times per second, the effect of simultaneous and immediate execution is achieved. Proper use of programmable controllers requires an understanding of the limitations of the execution order of rungs.
Syntax and examples
The language itself can be seen as a set of connections between logical checkers (contacts) and actuators (coils). If a path can be traced between the left side of the rung and the output, through asserted (true or "closed") contacts, the rung is true and the output coil storage bit is asserted (1) or true. If no path can be traced, then the output is false (0) and the "coil" by analogy to electromechanical relays is considered "de-energized". The analogy between logical propositions and relay contact status is due to Claude Shannon.
Ladder logic has contacts that make or break circuits to control coils. Each coil or contact corresponds to the status of a single bit in the programmable controller's memory. Unlike electromechanical relays, a ladder program can refer any number of times to the status of a single bit, equivalent to a relay with an indefinitely large number of contacts.
So-called "contacts" may refer to physical ("hard") inputs to the programmable controller from physical devices such as pushbuttons and limit switches via an integrated or external input module, or may represent the status of internal storage bits which may be generated elsewhere in the program.
Each rung of ladder language typically has one coil at the far right. Some manufacturers may allow more than one output coil on a rung.
- Rung input
- Checkers (contacts)
——
Normally open contact, closed whenever its corresponding coil or an input which controls it is energized. (Open contact at rest.)——
Normally closed ("not") contact, closed whenever its corresponding coil or an input which controls it is not energized. (Closed contact at rest.)
- Rung output
- Actuators (coils)
—( )—
Normally inactive coil, energized whenever its rung is closed. (Inactive at rest.)—(\)—
Normally active ("not") coil, energized whenever its rung is open. (Active at rest.)
The "coil" (output of a rung) may represent a physical output which operates some device connected to the programmable controller, or may represent an internal storage bit for use elsewhere in the program.
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. The presence of a slash within the checkers or actuators would indicate the default state of the device at rest.
Logical AND
------------------------------------( ) Key switch 1 Key switch 2 Door motor |
The above realizes the function: Door motor = Key switch 1 AND Key switch 2
This circuit shows two key switches that security guards might use to activate an electric motor on a bank vault door. When the normally open contacts of both switches close, electricity is able to flow to the motor which opens the door.
Logical AND with NOT
------------------------------------( ) Close door Obstruction Door motor |
The above realizes the function: Door motor = Close door AND NOT(Obstruction).
This circuit shows a push button that closes a door and an obstruction detector that senses if something is in the way of the closing door. When the normally open push button contact closes and the normally closed obstruction detector is closed (no obstruction detected), electricity is able to flow to the motor which closes the door.
Logical OR
--+--------------+-----------------( ) | Exterior unlock | Unlock | | +--------------+ Interior unlock |
The above realizes the function: Unlock = Interior unlock OR Exterior unlock
This circuit shows the two things that can trigger a car's power door locks. The remote receiver is always powered. The unlock solenoid gets power when either set of contacts is closed.
Industrial STOP/START
In common industrial latching start/stop logic we have a "Start" button to turn on a motor contactor, and a "Stop" button to turn off the contactor.
When the "Start" button is pushed the input goes true, via the "Stop" button NC contact. When the "Run" input becomes true the seal-in "Run" NO contact in parallel with the "Start" NO contact will close maintaining the input logic true (latched or sealed-in). After the circuit is latched the "Stop" button may be pushed causing its NC contact to open and consequently the input to go false. The "Run" NO contact then opens and the circuit logic returns to its inactive state.
--+------+--------( ) | Start | Stop Run | | +------+ Run ---------------------( ) Run Motor |
The above realizes the function: Run = (Start OR Run) AND (NOT Stop)
This latch configuration is a common idiom in ladder logic. It may also be referred to as seal-in logic. The key to understanding the latch is in recognizing that the "Start" switch is a momentary switch (once the user releases the button, the switch is open again). As soon as the "Run" solenoid engages, it closes the "Run" NO contact, which latches the solenoid on. The "Start" switch opening up then has no effect.
- Note: In this example, "Run" represents the status of a bit in the PLC, while "Motor" represents the actual output to the real-world relay that closes the motor's real-world circuit.
For safety reasons, an emergency stop ("ES") may be hardwired in series with the "Start" switch, and the relay logic should reflect this.
----------+----+---------( ) ES Stop | Start | Run | | +----+ Run ---------------------( ) Run Motor The above realizes the function: Run = (NOT ES) AND (NOT Stop) AND (Start OR Run) |
Complex logic
Here is an example of what two rungs in a ladder logic program might look like. In real-world applications, there may be hundreds or thousands of rungs.
Typically, complex ladder logic is "read" left to right and top to bottom. As each of the lines (or rungs) are evaluated the output coil of a rung may feed into the next stage of the ladder as an input. In a complex system there will be many "rungs" on a ladder, which are numbered in order of evaluation:
- Realising the function: A/C = Switch AND (HiTemp OR Humid).
-------------+---------+----( ) Switch | HiTemp | A/C | | +---------+ Humid
- Realising the function: Cooling = A/C AND (NOT Heat).
----------------------------( ) A/C Heat Cooling
This represents a slightly more complex system for rung 2. After the first line has been evaluated, the output coil "A/C" is fed into rung 2, which is then evaluated and the output coil "Cooling" could be fed into an output device "Compressor" or into rung 3 on the ladder. This system allows very complex logic designs to be broken down and evaluated.
Additional functionality
Additional functionality can be added to a ladder logic implementation by the PLC manufacturer as a special block. When the special block is powered, it executes code on predetermined arguments. These arguments may be displayed within the special block.
+-------+ -------------------------+ A +---- Remote unlock +-------+ Remote counter +-------+ -------------------------+ B +---- Interior unlock +-------+ Interior counter +--------+ --------------------+ A + B +----------- | into C | +--------+ Adder |
In this example, the system will count the number of times that the interior and remote unlock buttons are pressed. This information will be stored in memory locations A and B. Memory location C will hold the total number of times that the door has been unlocked electronically.
PLCs have many types of special blocks. They include timers, arithmetic operators and comparisons, table lookups, text processing, PID control, and filtering functions. More powerful PLCs can operate on a group of internal memory locations and execute an operation on a range of addresses, for example, to simulate a physical sequential drum controller or a finite-state machine. In some cases, users can define their own special blocks, which effectively are subroutines or macros. The large library of special blocks along with high-speed execution has allowed use of PLCs to implement very complex automation systems.
Limitations and successor languages
Ladder notation is best suited to control problems where only binary variables are required and where interlocking and sequencing of binary is the primary control problem. 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. Complex rungs are best broken into several simpler steps to avoid this problem. Some manufacturers avoid this problem by explicitly and completely defining the execution order of a rung, however, programmers may still have problems fully grasping the resulting complex semantics.
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.
As microprocessors have become more powerful, notations such as sequential function charts and function block diagrams can replace ladder logic for some limited applications. Some newer PLCs may have all or part of the programming carried out in a dialect that resembles BASIC, C, or other programming language with bindings appropriate for a real-time application environment.
Popularity
In 2019, IEEE Spectrum ranked ladder logic as number 50 out of 52 in a list of popular programming languages.
See also
References
- "The Basics of Ladder Logic".
Ladder logic uses switch or relay contacts to implement Boolean expressions. In years past, ladder logic was made possible with discrete relays and was sometimes termed relay logic.
- Edward W. Kamen Industrial Controls and Manufacturing, (Academic Press, 1999) ISBN 0123948509, Chapter 8 Ladder Logic Diagrams and PLC Implementations
- "Interactive: The Top Programming Languages". IEEE Spectrum. Archived from the original on 2019-09-18.
Further reading
- Walker, Mark John (2012-09-08). The Programmable Logic Controller: its prehistory, emergence and application (PDF) (PhD thesis). Department of Communication and Systems Faculty of Mathematics, Computing and Technology: The Open University. Archived (PDF) from the original on 2018-06-20. Retrieved 2018-06-20.
External links
- "Chapter 6: ladder logic" by Tony R. Kuphaldt