PLC stands for Programmable Logic Controller which is a specialized computer designed for industrial automation and control. Programmable logic controller’s are used extensively in industrial processes around the world today. So what exactly is PLC Programming and Ladder Logic?
PLC programming uses one or more programming languages to develop software to control industrial processes. This software is then compiled and downloaded into a programmable logic controller. One way to accomplish this is to use a programming language known as Ladder Logic.
It’s important to note that Ladder Logic Programming is just one way to program a PLC. There are other programming languages commonly used to accomplish this task as well. However, Ladder Logic Programming is without question the most common.
In this article we are going to perform an in-depth analysis of the following:
As mentioned at the beginning, PLC is an abbreviation for Programmable Logic Controller (PLC) and in a nutshell, is a small industrial-grade computer with two core functionalities: monitor various inputs and outputs in an industrial system, and to make logic-based decisions to automatically controls processes and components in machines or automated systems.
PLCs have been around for quite some time and were introduced back in the late 1960’s by the inventor Richard Morley. They were originally designed to replace relay logic systems since relay systems back then tend to create delays and were rigged with various issues.
The PLC was then introduced to eliminate these issues, such as high power consumption of the relay systems (with more relays, more power is required). Since PLCs feature a modular design (that is, they can be plugged into various setups), they don’t use relay switching and so will use less power.
Also, relay systems can cause undesired arcing between contacts, which can generate high temperatures that can lead to mechanical failure. PLCs help prevents these overheating issues.
PLC’s are robust and durable and can perform well in harsh conditions like severe heat/cold, cold, and extreme moisture, making them ideal for industrial applications. The PLC is arguably the single-most important invention used in industrial manufacturing even until today, six decades after its invention.
You can learn further about the definition and concept of the PLC, the differences to relay systems, the hardware, and how a PLC operates in programmable logic controllers article here and also in our PLC basics article here.
Simply put, PLC programming is the effort of developing the internal programming logic for a PLC. Without any program, the PLC is just a computer with a processor, an empty shell.
So, we program the logic we want the PLC to understand and base its operation in a programming language that is known by the PLC. If, for example, we want to tell the PLC to “if condition 1 is true, then turn the output of device A”, we use a language proprietary to the PLC, something like “If I1.0=1 then OA.0=1”.
PLC programming essentially makes the decision based on input from the real world, and tell the PLC how it should interact with the real world through the outputs. This is what allows the automation performed by the PLC.
You can check this article: different PLC programming languages for a more in-depth discussion about the topic. However, there are 5 PLC programming languages defined by the IEC 61131-3 standard, and below we will discuss them briefly:
Ladder Diagram (LD)
Ladder Diagram is the most common language used to program PLC and is also commonly known as Relay Ladder Logic (RLL). The Ladder Diagram is a graphical language (rather than text-based language) that visualizes the relationships between the inputs and outputs of the system.
Every Ladder Diagram is arranged similarly to an electrical diagram, and so we can say that the resulting ladder diagrams are virtual circuits. They are called “ladder” because the diagram literally resembles a ladder with two vertical rails (the supply power/contact) and horizontal lines (the rungs) to represent the control circuits/relay coils.
None of these supply power and control circuits seen in a Ladder Diagram program are real, but they are virtual bits in the PLC memory.
Function Block Diagram (FBD)
Function Block Diagram (FBD) is based on—as the name suggests—, the function blocks. It is also a graphical, visual language, and for those who are familiar with Boolean systems, FBD would feel more intuitive than the Ladder Diagram language.
The FBD, like the LD, also resembles electrical wiring diagrams. However, if in LD the diagram is more akin to relay logic systems, in FBD it’s more like we are wiring the function blocks together. In FBD, inputs are placed on the left of the function blocks and outputs on the right.
We can say that FBD is a simpler, more intuitive version of the LD language. However, to start programming in FBD language, we need to understand what the function blocks do, and so might have a steeper learning curve than LD.
Due to its similarities with LD, both the FBD and LD have a similar weakness: when the program becomes long or complex, it can be very difficult to trace every step and troubleshooting.
Structured Text (ST)
Unlike LD and FBD, Structured Text is—as the name suggests— is a text-based language.
While it’s more intuitive to use graphical programming languages for PLC programming, like the LD or FBD, they have their weakness, as we have briefly discussed above. A text-based PLC program will take up a much smaller file size, and when the program gets very long/complex, it will be easier to read and understand than a graphical language.
Another advantage of the ST language is that we can easily combine it with different programming languages. For example, we can have FBD function blocks containing functions written in ST.
Instruction List (IL)
Similar to ST, the Instruction List (IL) is not a graphical programming language, but it’s a low-level programming language more similar to assembly language. As the name suggests, the IL is a set of instructions. There are common mathematical operators listed, like addition, subtraction, multiplication, and divisive functions. There are also functions to call and return from different functions.
The main benefit of the IL compared to other PLC programming languages is speed. Like any other low-level programming languages, IL is low in overhead and so will execute much faster than a graphical language. It also takes up less memory, which can be a huge benefit in a PLC with limited memory space.
However, there is also a major drawback in using IL: assembly language is simply not that common, and so learning to use it can be a challenge since the available resources are also relatively limited.
Sequential Function Charts (SFC)
The Sequential Function Charts language is also a graphical PLC programming language (not text-based) and is ideal for breaking down a large and complex process into smaller bits.
There are two core elements of a sequence in the SFCs: steps and transitions. A ‘step’ is any function within the industrial system and a transition is a condition between one step and another. An SFC program can also include various standard logical programmings like parallel/alternative branching and feedback loops.
If the PLC manufacturer offers SFC programming, typically they will provide additional documentation to allow users to implement and customize the SFC programs.
As mentioned, Ladder Diagram (LD) or Relay Ladder Logic (RLL) is the most popular programming language in PLC programming, and so here we will delve further into it.
Ladder Logic is essentially a rule-based language that approximates an electrical wiring/circuit diagram as a graphical programming language. Ladder Logic is most commonly applied for designing logical switching units (i.e. on/off, start/stop button). However, it is versatile enough and can be implemented to create networks like the FBD (Function Block Diagram), so you can use Ladder Logic to control other program blocks.
The Ladder Logic program consists of networks: on the left side, these networks are bound by a vertical line (the bus bar), and a network contains a circuit diagram of POUs, contacts, coils, and connecting lines. On the left side, there is a series of contacts that relays the ‘1’ (on) or ‘0’ (off) state, which corresponds to the true or false boolean values.
A boolean variable is associated with each of these contacts, and if the variable is true, the status is then relayed from the left to right via the line, and the coil in the right side of the network will receive either the ‘0’ or ‘1’ value coming from the left. The value true or false is then written accordingly.
We will further discuss this by discussing the basic ladder logic instructions below.
Below, we will discuss five basic instructions that are common in Lader Logic (Ladder Diagram):
Symbol:
Examine if Closed, or XIC, examines a bit status of data to see if it is ‘true’. It is active/true when the bit status is in a ‘1’ state, and it is not active/false if the bit status is in a ‘0’ state. XIC instruction is applied in your ladder logic to determine if a bit is ‘true’ or ON. This instruction is always found on the left side of a ladder rung.
To summarize:
Common applications of XIC instruction are:
Symbol:
Examine of Open or XIO is essentially an instruction that performs the opposite to the XIC (Examine if Closed). So, it evaluates a bit status for an ‘off’ or 0 state, and only then it will evaluate to true. When that’s the case, the XIO instruction will execute the rest of the rung.
The XIO instruction is commonly used to evaluate the status of inputs on the PLC, but can be used on any boolean to examine whether the program’s boolean is energized. This instruction is always found on the left side of a ladder rung.
To summarize:
Common applications of XIO instruction are mostly similar to XIC:
Symbol:
The OTE (Output Energize) instruction will either set (energize) or clear a data bit depending whether the input leading to it is true or false. This instruction is always found on the right side of a ladder rung.
It will turn a bit into a high state (energized) if the preceding input evaluates to be true. On the other hand, it will turn a bit into a low state (cleared) if the preceding input evaluates to be false.
To summarize:
Common applications of OTE instruction are:
Symbol:
The OTL or Output Latch will force a bit into a ‘1’ state if all the preceding inputs leading to it are true. This instruction is always found on the right side of a ladder rung, and will switch a bit status to a high state. OTL will maintain this condition and unlike OTE instruction, will never turn the bit low. OTL is commonly paired with OTU (which we will discuss below).
OTL and OTU can be used to energize any boolean within the program, so they are quite versatile. At first glance, it might seem like a good idea to introduce OTU and OTL for all bits, but there might be scenarios where the logic will depend on the rung’s position. So, avoid using OTL and OTU unless they are absolutely needed.
To summarize:
Symbol:
OTU, or Output Unlatch will set the bit status to ‘0’ when all the preceding conditions leading to it evaluate to true. As with OTL, this instruction is always found on the right side of a ladder rung and will turn the bit to a ‘0’ (low) state when all preceding conditions are true. So, it’s the exact opposite of the OTL instruction, and it will retain the ‘0’ state and never turn a bit to ‘1’.
Again, it might seem like a good idea to introduce OTU and OTL for all bits, but there might be scenarios where the logic will depend on the rung’s position. So, avoid using OTL and OTU unless they are absolutely required.
To summarize:
Before we get going with PLC programming and using ladder logic. It is highly recommended that you familiarize yourself with PLC hardware and the basics of PLC programming and boolean logic. These articles will teach you a lot.
As mentioned ladder logic programming is graphical be design. This makes it very easy to program boolean expressions and logic. We’ve discussed basic ladder logic instructions above. You’d be surprised how many processes you can program with just these instructions alone.
Let’s take a look at an example. In this example we will make use of all the instructions we discussed, namely, the XIC (eXamine If Closed), the XIO (eXamine If Open), and the OTE (OuTput Energize) to control a simple motor start/stop circuit (with seal-in) using ladder logic programming.
Below is an image of this circuit built using ladder logic on Rockwell’s ControlLogix platform of programmable automation controllers. The instructions that are illuminated green indicate that the instruction is in its TRUE state.
Let’s analyze this circuit starting with the Starting with the Start_Motor_PB.
This is just a brief example of how to perform PLC programming using Ladder Logic. I encourage you to work through our playlist of videos on our YouTube channel. Here is a few videos from that playlist. You can also view them on our Learn PLC Programming page.
Being a PLC programmer requires a specialized skill set that combines electrical, mechanical and software engineering. A PLC programmer must possess strong analytical thinking and problem-solving skills.
In general, here are the required skills of a PLC programmer:
The current changes in software development and increasing complexity have allowed most employers to prefer candidates with at least a bachelor’s degree. PLC programmers typically hold at least a college degree in the fields of computer science, electrical engineering, or mechanical engineering. There is currently no degree or direct vocational training that trains you as a PLC programmer specialist.
PLC programmers are expected to:
There are many paths to becoming a PLC programmer. We did a comprehensive article on the different paths to PLC programming here.
According to the U.S. Bureau of Labor Statistics (BLS), the median annual wage of a PLC programmer is $56,749. The top 10 percentile earns more than $87.970, and the lowest 10 percentile earns less than $36,550.
For more information on how much a PLC programmer makes, I encourage you to check out our article here.
If you haven’t already done so yet, I do encourage you to become a member of the site.
PLCGurus.NET is quickly becoming one of the largest and fastest growing communities of professional engineers, technicians and technologists who all share a passion for industrial automation and control systems.
Registration is and will always remain completely free. Register Here!
Also, be sure to check out the PLCGurus.NET YouTube Channel to see some great videos…and don’t forget to like and subscribe to our channel! If you enjoyed this article be sure to check out some of these good reads too:
Lastly, if you run into any problems in your day-to-day engineering activities please be sure to check out our Live and Interactive PLC Forum! And if you so desire, assist other community members by replying or offering helpful information to the questions or challenges they may be facing right now! Thanks for reading.
Every electrician, mechanic, and even DIY enthusiast needs a good tap and die set in…
A distributed control system, or DCS, is essentially a control system where the control elements…
A precision screwdriver, is a screwdriver that is designed with more emphasis on precision and…
What does SCADA stand for? SCADA stands for Supervisory Control And Data Acquisition. What Is…
Electrical enclosures have different NEMA ratings and specifications. The primary objective of NEMA enclosure ratings…
Before the invention of the steam boiler, humans relied on coal fires and the burning…
This website uses cookies.