Ladder Logic Sequence Example

Posted : admin On 17.08.2021

What is Ladder Logic?

Ladder Logic is one of the top 5 most popular types of PLC programming languages used in manufacturing environments. Before Programmable Logic Controllers, manufacturing plants employed relay-based circuitry to energize different loads based on how the relays were wired together. Relays were costly, required constant maintenance, and could not be easily reconfigured. As PLCs took over this process, it was essential to keep a similarity of the old system; thus, ladder logic was created as the first PLC programming language.

Ladder Logic is labeled as such because the software is laid out in the shape of a ladder. On the left side, ladder logic instructions are set as conditions, while the ones on the right side are instructions that are triggered if the conditions are met. Each rung of the ladder spans from left to right and is executed from top to bottom by the PLC.

LADDER LOGIC/ FLOWCHART PROGRAMMING DIFFERENCES AND EXAMPLES English-based commands are then inserted into these constructs to provide the detailed program instructions. As many blocks as needed are assembled into the proper sequence to create a Chart that controls a specific aspect of the process. Build the ladder logic example with Timers to turn ON/OFF the lamp using push buttons with respect to program logic conditions. Start PB and Stop PB are to turn ON and OFF the lamp. After Start PB is pressed, In the following sequence Outputs should turn ON/OFF; Q1 is turn ON for 5 sec; Q2 is turn ON for 5 sec; Q3 is turn ON for.

As mentioned above, ladder logic is extremely popular among PLC programmers. It’s easy to learn, mimics electrical circuits, and is easy to troubleshoot once deployed.

Learning ladder logic is typically the entry point into a career in control systems as a PLC programmer. In this post, we will go over ladder logic components, cover basic principles, and outline what it takes to master this programming language.

Ladder Logic Basics

Just like computers, PLCs operate with binary signals; each one can be set to zero or one. In the programming world, this data type is called a boolean. A boolean takes a single bit in the memory, can be set to 0 or 1, and is used in most basic PLC instructions.

The PLC executes the program loaded into it one rung at a time. As the PLC begins to process the rung, it reads the instructions on the left and determines if the Logic on that side of the rung is set to TRUE. The Logic evaluates to TRUE when a hypothetical current is able to pass through the instructions. Each instruction has a set of conditions that make it TRUE or FALSE.

For the purpose of this tutorial, we’ll start with two of the most basic instructions in ladder logic plc programming: Examine if Closed and Output Energize.

Examine If Closed [XIC] - This input instruction will look at the specified boolean bit and evaluate the condition to TRUE when the bit is set to 1 (or HIGH). While the bit is set to 0 (or LOW), the instruction will evaluate to FALSE.

Output Energize [OTE] - This output instruction will set the specified bit to 1 (or HIGH) if the input instruction conditions are TRUE. If they’re FALSE, the Output Energize instruction will set the bit to 0 (or LOW).

Basic Ladder Logic Rung Analysis

  • Step 1 - The hypothetical current starts moving from left to right.
  • Step 2 - When the hypothetical current encounters and XIC Instruction, it checks if the condition is TRUE or FALSE. If the XIC is False, the PLC aborts this rung.
  • Step 3 - The hypothetical current goes to the next instruction. Repeats Step 2 until the rung is completed.
  • Step 4 - The PLC moves to the rung below.

In the example above, the XIC Instruction is tied to the bit “Condition1”. Since the bit is OFF (or 0), the hypothetical current stops at the instruction.

In the example above, the XIC Instruction is tied to the bit “Condition1”. Since the bit is ON (or 1), the hypothetical current is allowed to pass through and goes to the OTE Instruction. The OTE Instruction sets the “Energize1” bit to HIGH (or 1).

Ladder Logic Sequence Examples

Ladder Logic Structure Circuit Branches

Now that we’ve seen a basic example that illustrates how the execution of a single ladder logic rung is completed, it’s time to discuss circuit branches. Circuit branches create a way for the current to pass through a different path as the rung executes. The instructions are executed in the same way, but we now need to analyze different paths the current may take.

The rung above has the primary rung and a branch that jumps the first two conditions with a 3rd one. Let’s analyze what’s happening with the execution of the Logic.

  • Step 1 - The hypothetical current starts on the main branch of the rung. As it reaches “Condition1”, it evaluates the XIC Instruction. The XIC Instruction is TRUE and allows the current to proceed.
  • Step 2 - The hypothetical current flows to the next XIC Instruction and attempts to evaluate it. Since “Condition2” is set to 0, the XIC Instruction evaluates to FALSE. The current is stopped.
  • Step 3 - The hypothetical current goes back to the first branch. The XIC Instruction tied to bit “Condition3” is executed. Since the “Condition3” bit is HIGH, the XIC evaluates to TRUE. The current proceeds.
  • Step 4 - The current reaches the OTE Instruction and sets the “Energize1” bit to ON (or HIGH).

Here's a much more complex example for you to consider. It's not abnormal to find multiple branched circuits in ladder logic.

Advanced Circuit Branching Ladder Logic Practice

Now that you’re familiar with how circuit branches work in ladder logic, it’s important to practice tracing the logic as you would in the field. Most of your work as a PLC programmer is going to be looking at rungs of logic and figuring out why the output is energized or what’s preventing it from turning on.
Consider the following situation: your supervisor calls you due to a problem on a production line. For some reason, the pump that’s going to deliver raw materials to a specific tank isn’t turning ON. As you show up to the operator station, he shows you that when he pushes the button, the pump won’t do anything.
Resolution: you look at the panel, press the button yourself, and confirm that it doesn’t start. This pump worked in the past, so you decide to see what’s happening in the PLC logic. As you trace the output tied to the pump, you notice a complex rung with multiple circuit branches. The reason is that there are numerous conditions for that pump to start. Since you’re familiar with the approach above, you can quickly figure out that the pump wasn’t able to start because one of the start conditions was that the tank must be empty. As you realized that the tank was, in fact, empty, the conclusion was that the level sensor was broken. You replaced the sensor, and the pump resumed regular operation.

Ladder Logic RSLogix 5000 Components

Now that we have some familiarity with how a basic rung structure is laid out, let’s discuss other components of ladder logic.

1 - Ladder Logic Inputs

As we discussed above, the ladder logic instructions on the left side are called inputs. Their condition is evaluated on a true or false basis. If the evaluation is concluded with a TRUE, the output of the ladder logic rung is executed. If it's evaluated to FALSE, the PLC goes to the following rung.

2 - Ladder Logic Rung Comments

Every programming language allows the user to add documentation to their software. In ladder logic, this opportunity comes with every rung, instruction and data structure. By adding a comment above the rung, you're making it easier for the person after you to understand your train of thought and troubleshoot the logic as needed. Furthermore, the comments may be used to indicate a change or temporary fix of a certain problem that was encountered by a PLC programmer.

3 - Ladder Logic Outputs

There are many instructions that will execute on the output side. In the example we covered above, our focus was on the OTE Instruction. However, the screenshot above also includes TON or Timer On Delay Instructions. As you gain experience as a PLC programmer, you'll encounter and master additional instructions.

4 - Ladder Logic Rails

Each rung of ladder logic lies between the two side rails (just like a regular ladder). These rails are what energizes each rung as they are executed. In the screenshot above, you can see two rails within the RSLogix / Studio 5000 environment. The rails remain grayed out until the main routine calls the program. In the screenshot, the rails are green, which means that this specific logic is being executed.

5 - Tag Names

Each instruction will be tied to one or more tags. Each tag requires a data structure element as well as a name or label. In the examples we looked at above, tags were labeled as 'Condition1', 'Condition2', 'Condition3', etc. In production circumstances, tags would typically reflect the physical element they control or a set of PLC based tags. For example, tags that control motors may have the label of MTR1_Start, MTR2_Stop, MTR2_Status, etc. Furthermore, tags may also have a description that allows the user to give the tag a text-based description.

Ladder Logic Programming in RSLogix 5000 Basics

As you invest yourself in PLC Programming, you'll quickly realize that the list of different instructions available to you is vast. Furthermore, as you become advanced at the craft, you may find yourself creating your instructions through the use of an Add-On-Instruction or AOI. However, assuming that you're here for the basics, let's discuss the most useful instructions you should start working with as you tackle industrial automation.

Examine If Closed [XIC]

We've looked at these instructions at the start of the tutorial. It's the essential input check you can make on your data. In short, if the boolean assigned to the XIC is TRUE, the output will go through. If it's FALSE, it won't. Although it may seem that this would have limited utility, many of the advanced constructs within PLCs have a boolean state. For example, a Variable Frequency Drive may have an array of boolean structures that are tied to different faults. Therefore, you may create the same number of XIC instructions to verify which failure is present on the drive.

Examine If Open [XIO]

The XIO will energize the output if the exact opposite of the XIC is true. In other words, the output will energize if the boolean value is FALSE.

Output Energize [OTE]


The OTE is an output instruction and will set a boolean to TRUE if all the preceding conditions are TRUE leading to it. The OTE would also set the boolean to FALSE should there be no TRUE path of inputs leading to it. The Output Energize instruction is used to set digital outputs on field devices such as valves, motor contactors, relays, solenoids and more.

Timer ON [TON]

Timers are a basic>

  • The stop push button should prevent the motor from getting started.
  • The stop push button should stop the motor when it's running.
  • Based on the two requirements above, it's possible to add an XIO instruction into each branch of the circuit. However, ladder logic is such that the user can utilize a single instruction to cover both of those scenarios after the branch.

    Example of a functionally sound rung based on the above requirements.

    The rung above will operate as expected. However, it's important to create efficient ladder logic and utilize instructions in conjunction to the branch structures we've covered above.

    The rung above operates as follows:

    Stage 1 - The Start_PB is pressed and the MotorContactor is Energized while Stop_PB is not pressed.

    Stage 2 - The MotorContactor bit is used to keep the motor energized while the Start_PB is released.

    Stage 3 - The MotorContactor is de-energized when the Stop_PB is pressed.

    The motor starter ladder logic example is easy to follow. However, as you expand your knowledge of ladder logic principles, you will create complex branches around similar circuits. It's not uncommon to have multiple stop conditions that are set in series with the 'Stop_PB' bit. Similarly, it's common to see other sources of starting the motor. For example, a sequence may be used to start a specific pump through software.


    Ladder Logic is the most common PLC Programming language. It's easy to learn, easy to use and has been adopted since the early days of Programmable Logic Controllers. The iconic resemblance to a ladder was what gave this type of logic its name. Such diagrams were used for specifying electrical drawings that were used in many industrial environments. Since those days, ladder logic has involved significantly, yet retains some of the basic elements: rails, rungs, input conditions, output instructions, comments, etc.

    To learn ladder logic, you'll need to start with understanding current flow from the left rail to the right one. In summary, the current will attempt to flow through one rung at a time. As it encounters an input condition, it evaluates the result to TRUE or FALSE. If the condition is FALSE, the current will atempt to use a secondary path which may be through a circuit branch. If the result is TRUE, the current will proceed through the instruction. When it reaches an output instruction, it will execute the specified logic.

    This podcast was created in Mr. Crowder's 3rd period Tech class. In this podast you will learn what a video card is and what video card a buissness owner, professional gamer, every day person, and a college student should have in there computer. Podcastsmr. mac's room. A scintillating yet profound auditory experience, The Male Room is a poignant insight into the trials and tribulations of manhood in contemporary society. Featuring Nick Rheinberger & William Verity, the podcast is an enduring classic of our time. 80 Percent is a six-part miniseries from The Boston Globe hosted by entertainment reporter Mark Shanahan, who shares a deeply personal, sometimes harrowing, often funny, always true story. With iTunes breaking out into dedicated apps in macOS Catalina, Mac is getting its very own Podcasts app. In this app, you'll subscribe to, search for, and manage your podcast library. If you're familiar with the iOS Podcasts app, you'll likely be pretty familiar with the interface, but if you're completely new to the app, here's a handy step. Mac' Matt Macfarlane CONTACT INFORMATION: Templeton Middle School 1200 South Main Street Templeton, CA 93465 Email: [email protected] Twitter: @mrmacsclasses.

    Applying the five steps of PLC development to a plc shift register example. This PLC programming example will use a shift register to reject a product on a conveyor.
    A lot of times when programming a PLC you need to track what has previously happened. Shift registers allow you to do just that. We will look at a PLC basic tutorial of a conveyor belt and reject station. Following the 5 steps to program development this PLC programming example should fully explain the function of shift registers. Ladder logic will be our PLC programming language.

    We will be using the Do-more Designer software which comes with a simulator. This fully functional program is offered free of charge at automation direct.

    Define the task:
    Shift Register – Conveyor Reject

    What has to happen?

    A start pushbutton (NO) is used to start the conveyor and a stop pushbutton (NC) is used to stop. Sensor B detects a product on the conveyor belt and sensor A will detect if it is too large and needs to be rejected. The product is tracked along the conveyor belt and when under the reject station the Reject Blow Off will expel the bad product. The product is randomly placed on the conveyor belt, so an incremental encoder is used to track the conveyor movement. The reset pushbutton (NO) will signal that all of the product on the conveyor has been removed between the sensors and reject blow-off.

    Define the Inputs and Outputs:
    PLC Connections for the Shift Register Conveyor Example

    Inputs: Start Switch – On/Off (Normally Open) – NO Stop Switch – On/Off (Normally Closed) – NC Reset Switch – On/Off – NO Motor Encoder – On/Off – This will give a discrete signal when the conveyor is moving. It picks up the movement of the freewheel. Sensor A (Part Reject) – On/Off – NO Sensor B (Part Present) – On/Off – NO

    Outputs: Motor – On/Off (Conveyor Run) Air Blow Off – On/Off (Reject)

    Develop a logical sequence of operation:
    PLC Logic for Shift Register Conveyor Reject

    Sequence Table: The following is a sequence table for our conveyor reject application.

    It is a simple sequence table but clarifies the following: When the power goes off and comes on the sequence will continue. This means that the shift sequencer must be memory retentive. Sensor A and B must be on to get tracked with a shift register.

    Shift Registers: The Shift Register (SR) instruction shifts data through a predefined number of BIT locations. These BIT locations can be a range of BITs, a single Word or DWord, or a range of Words or DWords. The instruction has three inputs. Data, Clock and Reset. The data input will load the beginning bit with a ‘1’ if it is on or ‘0’ if it is not. The clock input is used to shift the data through the shift register. In our example, we will be using the encoder on the conveyor to track the reject container. So each pulse of the clock represents a distance on the conveyor. The last input is the reset. It will place ‘0’ in all of the bits within the shift register.

    Develop the PLC program:
    Conveyor Reject

    Start and stop of the conveyor motor.

    Shift register to track the rejected parts. This will move the bits with each pulse of the encoder. Note that the ‘V’ memory is used because it is memory retentive.

    This will look at the bit in front of the reject station. We can measure and count off the length (conveyor) and then find out what the bit location will be at the reject location.

    Test the PLC program:
    Shift Register Conveyor Reject

    Test the program with a simulator or actual machine. Make modifications as necessary. Remember to follow up after a time frame to see if any problems arise that need to be addressed with the program.

    Notes: Sometimes you can use multiple shift registers in your program. This can be helpful if you want to actually track the container as well as the rejects. You could also use a bit shift right (BSR) and bit shift left instructions (BSR) to do the same thing as we did with the shift register instruction. In the Do-more PLC, it is rotate left (ROTL) and rotates right (ROTR) instructions. Always check your instruction set of the controller that you are working with before starting to program.

    Watch on YouTube: PLC Programming Example – Shift Register (Conveyor Reject)

    Additional information on shift registers can be seen at the following URL:
    This PLC programming example will look at sorting coloured tags into three different exits. The 3D simulation will use three different shift registers to trigger when to direct the correct colour tag.
    Watch the sequence of operation video below.
    Watch on YouTube: PLC Programming Example – Sorting Station Testing

    If you have any questions or need further information please contact me.
    Thank you,
    If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

    To get this free article, subscribe to my free email newsletter.
    Use the information to inform other people how numbering systems work. Sign up now.

    The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.

    Ladder Logic Sequence Example