Ladder Logic Sequence Example

admin 1/26/2022
53 Comments

Document the ladder logic by identifying all inputs and outputs and by labeling the. Make a numbered list of every step in the production sequence. Identify and list all outputs for the system and the action produced by the output. For example, only one of the SFC logic outputs (i.e; CR1 or B3/1) can be on at any one time.

  1. Ladder Logic Diagram Example 1 Computer Aided Manufacturing TECH 4/53350 27 Task: Draw a ladder diagram that will cause the output, pilot light PL2, to be.
  2. While ladder diagrams were once the only available notation for recording programmable controller programs, today other forms are standardized in IEC 61131-3 (For example, as an alternative to the graphical ladder logic form, there is also a more assembly language like format called Instruction list within the IEC 61131-3 standard.).

PLC sequencer logic is an essential component to have in your quiver of ladder logic sample code.It forms the backbone to the majority of processes for industrial automation. Applications that require sequencer logic include conveyor systems, palletizing machines, batching plants, packaging machines, storage and retrieval systems and the list goes on and on.

A sequence in industrial automation is merely a series of actions required to be taken to achieve a specific outcome arranged in an orderly fashion.

The basis to develop a sequence in ladder logic is to use sequence steps.

It’s a good idea to declare the sequence steps as internal variables, which in turn can be used multiple times in the program if required.

PLC Sequence Steps

To illustrate how sequence steps are derived for PLC Sequencer Logic let’s look at the sequence of events required for a common household task, brushing your teeth….

  1. Grab your toothbrush.
  2. Grab your toothpaste.
  3. Put some toothpaste on the toothbrush.
  4. Put the toothbrush in your mouth.
  5. Brush your teeth with the toothbrush for two minutes.
  6. Remove the toothbrush from your mouth.
  7. Rinse your mouth out with water.
  8. Rinse your toothbrush with water.
  9. Put your toothbrush away.

To automate an industrial process with a sequence we use the same concept. The complexity of the sequence ladder logic program will depend on the specific process outcomes required.

Even with the tooth brushing example above some of the steps can be broken down even further.

For example step 3 can be broken down into three steps with significantly more detail….

3a) Position the toothpaste nozzle at the far end of the toothbrush head.

3b) Squeeze the toothpaste while moving it lengthwise along the toothbrush head until it reaches the end of the toothbrush head.

3c) Stop squeezing the toothpaste and place it in the toothpaste holder.

Types of PLC Sequencer Logic

A sequence can either be cyclic or linear.

A cyclic sequence moves through the sequence steps and when the final step is completed the sequence automatically restarts from the beginning and keeps repeating the sequence until a stop command is initiated.

A linear sequence moves through the sequence steps and when the final step is completed stops and sits idle until a start command is re-issued manually by the operator.

The 4 Essential Elements of PLC Sequencer Logic

There are various ways to structure the sequence ladder logic but as a minimum it must contain four essential items of code…..

  1. Sequence start and stop.
  2. The Sequence steps.
  3. Sequence step transition conditions.
  4. The outputs that initiate actions.

Once we know the basic sequence ladder logic structure we can modify it to suit the process requirements. We can create multiple sequences, parallel sequence branches and add logical expressions and timers to help control it.

The sequence start, stop and steps require latching logic using either hold in logic or Set (latch) Reset (Unlatch) symbols.

If you don’t know what hold in logic and Set/Reset symbols are then click here.

PLC Sequencer Logic Example

Let’s follow on from our motor control example used earlier and define a sequence utilizing a motorized trolley.

The trolley runs forward to a certain position. Accepts a pallet of produce from an automated crane. Then reverses back to it’s starting position ready to be unloaded by a forklift operator and put into the back of a truck for transportation.

The motorized trolley has a limit switch for the unloading and loading positions so it can stop in the correct place.

It has a sensor to detect if there is a pallet on the trolley.

It also has a sensor to detect if the loading area is clear and is safe for the motorized trolley to start moving.

To activate the sequence the operator decides if the trolley is unloaded and safe to run, then pushes the start push button.

Ladder Logic Sequence Example

When the sequence completes a cycle it stops and waits for the operator to push the start button again. This is a linear sequence with a start and end point.

After the sequence is complete it must be re-initiated manually by an operator in order for the sequence to restart.

Having said that, we just as well could have chosen to do an automatic cyclic sequence. This is easily done at the last step by re-activating the first sequence step instead of ending the sequence. We will also need to add some extra conditional logic to replace the operators manual start operation.

Ladder Logic Sequence Example

Below is the list of required inputs that need to be declared …..

Next let’s declare the outputs…..

We also need to declare the following internal variables…..

The sequence logic diagram below is a basic linear sequence with three steps that ends after the third step transition conditions are met….

The transition conditions that enable the steps to progress to the next step and the actual sequence steps are all declared as internal variables.

Ladder Logic Sequence Example

In this way we can take the conditional logic out of the sequence logic rungs to de-clutter it and make it easily readable.

We should place the transition conditional logic before the sequence logic to allow for the PLC scan going from top to bottom….

Lastly we need some logic to trigger the PLC outputs to make the trolley move.

There’s no need to use additional latching logic for the motor start because we are utilizing the sequence step latching logic.

We should place logic that triggers the outputs after the sequence logic to allow for the PLC scan going from top to bottom.

Advanced Sequence Ladder Logic Programming

Even though this example is a simple control sequence it provides the backbone for more complex additions.

Some examples of additional features include….

  • Auto and manual modes so that individual components can be operated in case of failures and maintenance.
  • Sequence status and indication lights and sirens.
  • A stopping sequence and/or emergency stop function can also be added if required.
  • Conditional logic that needs to be met before the sequence can be started.
  • Sequence pause logic to remember the last step before the sequence was stopped, so that the sequence can resume from where it left off.
  • Conditional start logic that decides the step that must be triggered to resume operation.
  • Alarm and fault logic to capture failure of equipment.

It’s great using hold in logic to latch the sequence steps because all the transition and stopping conditional logic is located in the same area.

When we encounter more complex processes then using hold in logic for our sequence steps can become difficult because we are limited to using only one output.

Using multiple output symbols with the same variable declaration is a recipe for disaster.

We don’t want to do this because the output symbol may be overwritten inadvertently during the PLC scan causing haphazard like behavior.

If the ladder diagram complexity is high then we can latch and unlatch sequence steps using the Set (Latch) and Reset (Unlatch) symbols.

These symbols provide a lot more flexibility with the sequence programming, but require extra caution and expertise.

In the next section we’ll provide you with a comprehensive guide to programming ladder logic flip flop’s and toggle logic.

To go to the next section click here.

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.

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

Ladder Logic Sequence Example Problems

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.

LogicLadder Logic Sequence Example

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.

    Conclusion

    Ladder Logic Sample Programs

    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.

    Ladder Logic Sequence Example Pdf

    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.

    How To Read Ladder Logic Pdf