Ladder logic

Ladder logic

Ladder logic is a philosophy of drawing electrical logic schematics. It is now a graphical language very popular for programming Programmable Logic Controllers (PLCs). It was originally invented to describe logic made from relays. 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.

Overview

A program in ladder logic, also called a ladder diagram, is similar to a schematic for a set of relay circuits. 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.

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 IEC 61131-3 standard has helped to reduce unnecessary differences, but translating programs between systems still requires significant work). Even different models of programmable controller 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 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 (scan). By executing the loop fast enough, typically many times per second, the effect of simultaneous and immediate execution is relatively achieved to within the tolerance of the time required to execute every rung in the "loop" (the "scan time"). It is somewhat similar to other rule-based languages, like spreadsheets or SQL. However, proper use of programmable controllers requires understanding the limitations of the execution order of rungs.

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 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.

--( )-- a regular coil, true when its rung is true

--()-- a "not" coil, false when its rung is true

-- [ ] --A regular contact, true when its coil is true (normally false)

-- [] --A "not" contact, false when its coil is true (normally true)

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.

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:

1. ---- [ ] ---------|-- [ ] --|------( ) X | Y | S

-- [ ] --
Z

The above realises the function: S = X AND ( Y OR Z )

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. ---- [ ] -----------|--- [ ] ---|----( ) X | Y | S

--- [ ] ---
Z 2. ---- [ ] ---- [ ] -------------------( ) S X T

2. T = S AND X where S is equivalent to #1. above

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.

For more practical examples see below: ------ [ ] -------------- [ ] ----------------( ) Key Switch 1 Key Switch 2 Door Motor

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. Note the inverted logic of the stop function. The stop button is wired as a normaly closed switch to the PLC input, which turns off when pressed the stop button is pressed.

--+---- [ ] --+---- [] ----( )
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.

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. 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 avoids 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.

As microprocessors have become more powerful, notations such as sequential function charts and function block diagrams 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 BASIC or C or other programming language with bindings appropriate for a real-time application environment.

See also

*programmable logic controller
*digital circuit
*IEC 61131

External links

* [http://www.electronicspal.com/plc/ PLC Complete Tutorial]
* [http://www.plcs.net/contents.shtml Beginners Ladder Logic Primer]
* [http://www.plctutor.com/index.php?page=relay-ladder-logic Basic Ladder Logic]
* [http://www.ibiblio.org/obp/electricCircuits/Digital/DIGI_6.html "Chapter 6: ladder logic"] by Tony R. Kuphaldt (Design Science License); also see [http://www.faqs.org/docs/electric/Digital/DIGI_10.html "Chapter 10: Multivibrators"] (mirror site)
* [http://www.allaboutcircuits.com/vol_4/chpt_10/2.html multivibrators]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Ladder Logic — Infobox FRC Game game title = Ladder Logic year = 1998 number teams = 199 [ [http://www.usfirst.org/uploadedFiles/Who/Annual Report Financials/FirstAnnual06(1).pdf first inside spreads ] ] number regionals = 5… …   Wikipedia

  • ladder logic — noun A technique for describing and drawing electrical logic schematics …   Wiktionary

  • Ladder diagram — may refer to: * Message Sequence Chart, in Unified Modeling Language (UML) * Ladder logic, a method of drawing electrical logic schematics. A ladder diagram represents a program in ladder logic …   Wikipedia

  • Ladder scheme — may refer to:* Relay Ladder Logic, a ladder logic flow chart * Matrix scheme, a controversial (and in some places illegal) business model …   Wikipedia

  • Programmable logic controller — A programmable logic controller (PLC) or programmable controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. PLCs are used in many different industries and machines… …   Wikipedia

  • Relay logic — is a method of controlling industrial electronic circuits by using relays and contacts. ladder logic The schematic diagrams for relay logic circuits are often called line diagrams, because the inputs and outputs are essentially drawn in a series… …   Wikipedia

  • Emulation for Logic Validation — also referred to as Virtual Commissioning. This process involves replicating the behavior of one or more pieces of hardware with a software environment (typically for a system under design). The goal of the emulation engineer is to create an… …   Wikipedia

  • Resistor Ladder — Two Resistor Ladder configurations are known, a string resistor ladder and a R 2R ladder.A R 2R Ladder is the most simple and inexpensive way to perform digital to analog conversion, using repetitive arrangements of precision resistor networks in …   Wikipedia

  • Programmable logic controller — Automate programmable industriel Pour les articles homonymes, voir API. Deux automates programmables Industriels leurs périphériques, m …   Wikipédia en Français

  • Programmable Logic Controller — Rack mit einer Speicherprogrammierbaren Steuerung Eine Speicherprogrammierbare Steuerung (SPS, engl. Programmable Logic Controller, PLC) ist eine Baugruppe, die zur Steuerung oder Regelung einer Maschine oder Anlage eingesetzt wird. In der Regel… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”