Ladder Logic: From Wikipedia, The Free Encyclopedia
Ladder Logic: From Wikipedia, The Free Encyclopedia
Part of a ladder diagram, including contacts and coils, compares, timers and monostable
multivibrators
Contents
[hide]
• 1 Overview
• 2 Example of a simple ladder logic program
• 3 Examples
• 4 Additional functionality
• 5 Limitations and successor languages
• 6 See also
• 7 External links
[edit] Overview
An argument that aided the initial adoption of ladder logic was that a wide variety of
engineers and technicians would be able to understand and use it without much additional
training, because of the resemblance to familiar hardware systems. This argument has
become less relevant given that most ladder logic programmers have a software
background in more conventional programming languages, and in practice
implementations of ladder logic have characteristics—such as sequential execution and
support for control flow features—that make the analogy to hardware somewhat
imprecise.
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.
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.
--[ ]-- A regular contact, closed whenever its corresponding coil is energized
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.
[edit] Examples
Here is an example of what one rung in a ladder logic program might look like. In real
life, there may be hundreds or thousands of rungs.
For example:
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.
This represents a slightly more complex system for rung 2. After the first line has been
evaluated, the output coil (S) is fed into rung 2, which is then evaluated and the output
coil T could be fed into an output device (buzzer, light etc..) or into rung 3 on the ladder.
(Note that the contact X on the second rung serves no useful purpose, as X is already
defined in the 'AND' function of S from the 1st rung.)
This system allows very complex logic designs to be broken down and evaluated.
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 is a logical AND.
+-------+
----------------------------+ +----
+-------+
Remote Receiver
--|-------[ ]-------+-----------------( )
| Remote Unlock | Lock Solenoid
| |
|-------[ ]-------|
Interior Unlock
This circuit shows the two things that can trigger a car's power door locks. The remote
receiver is always powered. The lock solenoid gets power when either set of contacts is
closed. This is a logical OR.
Often we have a little green "start" button to turn on a motor, and we want to turn it off
with a big red "Stop" button. The stop button itself is wired as a normally closed switch,
the PLC input is read as normally open. When the stop button is pushed, the input will go
false. Making the rung false, stopping the "run" output.
--+----[ ]--+----[\]----( )
| start | stop run
| |
+----[ ]--+
run
-------[ ]--------------( )
run motor
This latch configuration is a common idiom in ladder logic. In ladder logic it is referred
to as seal-in logic.
+-------+
-----[ ]--------------------+ 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.
[edit] 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.
Since execution of rungs is sequential within a program and may be undefined or obscure
within a rung, some 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, e.g. Omron, 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 which in other languages would call for use of indexed variables.