PLCs accept exploded in the controls market and are used throughout the world. Over time they have avant-garde to become more user friendly, efficient, smaller and less expensive. Unlike types of programming languages have also been developed for PLCs but the most frequently used is notwithstanding Ladder Logic.

The Origins of Ladder Logic – Relay Logic

Imagine for a 2nd information technology's 1980. Y'all're cruising in your brand new Ford Pinto on the way to your task at the local Rubik's Cube plant. You lot have a busy mean solar day ahead since the plant is being redesigned for the new Rubik's Revenge model due out next year. The relay panels you work on need to be rewired to accommodate the modify in production size, from the original 3x3x3 size to the new 4x4x4 model.

These relay panels consist of numerous electromechanical relays that are wired together to perform a certain function in the plant. The unproblematic opening and closing of relay contacts on the panel gives the organization the ON/OFF control it needs in the manufacturing procedure. For instance, when the cube'due south mold is in position a switch will shut. This switch energizes a relay coil, which in turn closes the normally open contact for the injection pump. The pump fills the mold with melted plastic and the cube begins to have shape.

Using this combination of switches, relays, coils and contacts is referred to equally Relay Logic. Relay logic is a dependable controls method still in limited use today. But the price associated with information technology in terms of time-consuming logic changes, mechanical failures over time and extensive wiring and space requirements has forced many industries to reconsider their control needs. What they discovered was the PLC.

The Construction of Ladder Logic/How to Read Ladder Logic

The structure behind ladder logic is based on the electrical ladder diagrams that were used with relay logic. These diagrams documented how connections between devices were fabricated on relay panels; they are called "ladder" diagrams because they are constructed in a way that resembles a ladder with ii vertical rails and rungs between them. The positive power track (on the left) flows to the negative power rail (on the right) through the concrete devices connected on the rung.  The example beneath shows a ladder diagram with pushbuttons (Atomic number 82), command relays (CR), a motor (M) and a light (L).

ladder logic relay logic diagram symbols

Similarities with Ladder Diagrams

Ladder logic was designed to have the same look and feel as electrical ladder diagrams, but with ladder logic, the concrete contacts and coils are replaced with memory bits. Let's have a look.

ladder logic tutorial

For this program, the relay logic'southward ladder diagram is duplicated with ladder logic; no more difficult-wired logic, simply retentivity locations instead. Some of these memory locations are used internally and others are used with external inputs and outputs. To monitor and command real globe devices, they volition need to be wired to I/O modules.

For this particular PLC, these inputs and outputs are assigned to X and Y memory addresses like the X001 seen with PB1. This normally open contact's state is read from the input on the I/O module where the physical pushbutton is connected. On the other paw, each Y bit will have an output device wired to it as seen with the light controlled by Y001. All of the other locations are assigned to internal bits that we can apply as needed.

One side notation, today's PLC CPUs offer many types of functions, non just simple contacts and coils. Math, Shift Registers, Drum Sequencers, etc., are available to aid in programming.

Execution of Ladder Logic

Typically before starting to execute the logic, the CPU reads the concrete inputs tied to the I/O modules to update their status in the CPU'southward memory table. Then, starting at the peak left of the program, the CPU works its way downward the rail executing each rung or sub rung from left to correct. So if PB1 is pressed, the CPU volition turn ON CR1. Since CR1 has changed states, in rung 3 the CPU will activate CR3. CR3's normally-closed land is used in rung 4, and so the CPU volition so plough OFF L1.

Even though we still refer to coils and contacts in ladder logic, remember that they are retention representations, not actual devices. Once the CPU reaches the last rung information technology will update the real world outputs, then loop back and run it all again. This process will proceed as long as the CPU is powered and in the RUN fashion.

The time it takes the CPU to execute ane laissez passer and loop back to the beginning is known every bit scan fourth dimension. Scan time can exist important to applications where timing is critical. Subroutines and special purpose I/O modules can be used to help reduce the scan fourth dimension if needed.

The Logic Backside The Ladder

So what logic can ladder logic really perform? With the increasing demand for functionality and ease of utilise, many of today'southward PLCs comprise function blocks with ladder logic. The structure of the program is withal ladder with the more than complex instructions being role blocks. So to respond the question, let'south look at a few examples:

  1. Boolean Logic: The ON/OFF, True/Faux algebra of binary systems, the basics of which are AND, OR and NOT operators. To put it simply, rung five in our code needs CR1(C1) AND CR2(C2) to turn ON motor M1 (Y002).
  2. Timing: Timer instructions are available to allow for on-delayed or off-delayed events. In one case triggered, the timer will turn its associated output ON (on-delay) or OFF (off-delay) after the set fourth dimension has elapsed.
  3. Counting: Count-up and count-downwards functions increase or decrease the counter value on every transition of the input.
  4. Comparisons: Compare instructions are available to determine if values are less than, equal to or greater than each other.
  5. Math: These instructions not only allow for the simple addition and subtraction but too for more complex operations similar tangents, foursquare roots, etc.
  6. Special functions: These include PID loops, communication instructions, shift registers, drum sequencers, ramp generators, etc.

Effort an Exercise

If you would like to effort an exercise in ladder logic, AutomationDirect has created a beginner's programming exercise. This exercise was actually created for the Boy Scouts of America to assistance teach ladder logic to future PLC programmers. It uses the simulator included with the Do-more than Designer programming software for our Do-more PLC serial.

The software is free and you lot do not need any hardware, and so try it. Download the software hither.

Learn More than nigh Ladder Logic

There is a lot more to acquire; we've only begun to scratch the surface. Encounter how we can help you Learn More than most PLCs and get PLC Preparation!