Call or Text us: 1 (470) 231-7659
✈ Free Domestic Shipping on all Engineering Bundles!
PLC Programming Basics Ladder Logic

PLC Programming Basics using Ladder Logic

We sometimes use affiliate links in our content. This won't cost you anything, but it helps us to offset the costs of paying our writing team. You can support us directly on BuyMeACoffee. Thank you!

Free Robotics Course Robotics 101 by Learn Robotics
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn
You probably landed on this page because you’re interested in programming a PLC (programmable logic controller), but have no clue where to begin. Welcome! This article is designed to give you a primer in PLC Programming Basics for Industrial applications.

At the end of this article, you will have familiarity with reading Ladder Logic (also known as Ladder Diagrams) so that you can work on projects using PLCs. In future tutorials, I will show you how to practice writing Ladder Logic for common Industrial Control Systems.

One thing to note, is there are four additional industrial programming languages you can learn. In my experience, Ladder Logic is the most popular followed by Structured Text and Function Block. You can read more about the IEC61131-3 languages here.

So, without further ado, here’s my spin on PLC Programming Basics using Ladder Logic.

How PLC Programs are Executed

Before we can dive into the programming aspect of PLCs, it’s important to understand how the PLC works. When a PLC executes a program, it must know, in real-time, when external devices controlling a process are changing. During the Program Scan Cycle, the PLC reads the inputs, solves the Ladder Logic, and energizes (or de-energizes) outputs. Because inputs can change at any time, this process repeats over and over again while the PLC is in RUN mode. The diagram below shows a model of the PLC Program Scan Cycle.

PLC Program Basics
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn

Scan times can vary from 1 millisecond to 20 milliseconds. This is important because if the controller has to react to an input event faster than the scan time, it may never detect the change. Scan time is influenced by a few factors including the processor module speed, length of the ladder program, type of instructions executed, and the actual true/false conditions.

I also want to point out that the ladder programs we’ll be looking at are very simplistic. Therefore, we don’t have to worry so much about scan times. It’s just something to be aware of if you’re working with larger-scale systems.

Now that we have a general overview of how the PLC executes the program scan cycle, we can talk about ladder logic fundamentals.

Ladder Logic Fundamentals (How to read and write Ladder Diagrams)

Programs in Ladder Logic are written differently than embedded or flow-chart programming. Ladder Logic is a rule-based language, meaning the conditions must be met for the output to be energized. When I was first learning ladder logic, I had a hard time wrapping my brain around the symbology. Ladder Logic is very easy to understand once you get the hang of a few basic principles.

1. Rungs are Read Left to Right and Top to Bottom

There are two rails (left and right) and they are connected by rungs. This builds out a program that looks like a ladder. Ladder rungs are read starting from the left to the right and then sequentially, top to bottom.

PLC Ladder Logic example
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn

2. Inputs or CONTACTS are on the left. Outputs or COILS are on the right.

You’ll notice a few basic symbols in the ladder program, above. Common symbols are called “Normally Open”, “Normally Closed” and “Output.” Check out the chart below. I learned on Allen Bradley PLCs, so I’ll refer to the XIC / XIO / OTE combination. Just know that these names are interchangeable and synonymous.

PLC Symbol Chart
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn

3. Combine symbols to create a logical flow.

Ladder logic is based on principles from digital logic gates. There are three basic types of digital logic gates: the AND Gate, the OR Gate, and the NOT Gate. View the Truth Tables, below.

digital logic gates chart PLC
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn

Logical AND condition

When you combine inputs and a bit of digital logic, you can create the status for your output. Here’s an example of the AND condition written in Ladder Logic.

Example Rung Ladder Logic
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn

There are two inputs: XIC, XIO, and an OTE. This rung is read: If XIC and XIO then OTE. Both the XIC and the XIO must be active for the OTE to be energized. You can substitute “if-statements” into the rung to understand the condition. Most PLCs make it easy to figure out what is ON by highlighting the active elements.

Demonstrating the OR condition

We can create the OR condition by using a branch. You’ll see in the video below, the Start Button and the Motor are on separate branches. This is a common pattern for motor starters.

First, the program will check to see if the Start button or the motor is ON and the stop button is OFF, energize the motor. Here’s a demonstration.

This configuration is called “latching the motor.” Once the motor is on, there’s always a path for it to stay on, so long as the stop button isn’t pressed.

Now that you’ve seen the most common symbols and configurations in ladder logic, it’s time to practice your skills. In my opinion, the best way to practice is to “do.” So, here are some resources to get you programming PLCs.

PLC Programming Simulation Software

There are a couple of routes you can go with practicing your PLC programming: program in simulation, program real hardware, or read controls engineering books. I’ll cover all three of these options in this section.

I think learning on simulators is one of the better approaches to PLC programming. Real hardware can be expensive and dangerous to test, so working in simulation allows you to practice your skills while eliminating the hazard and cost barriers.

Also, these options only run on Windows Computers (as most Industrial Controls programs do). You can run some of the simulators in a Windows VM, but be mindful of RAM, 3D graphics, and acceleration. Programs like FactoryIO can be graphic-intensive and laggy on some VMs.

Here are a couple of simulators I’ve used that can help you learn PLC programming for free or low-cost.

CoDeSys

The first simulator option is CoDeSys (pronounced CO-da-SYS). CoDeSys is a pretty popular freemium control software that many international folks use. The IDE has a bit of a learning curve, but it includes an HMI program and Simulator, so you can create, model, and test projects as you desire. It also interfaces with Raspberry Pi, so if you wanted to incorporate some hardware and sensors, you can do that pretty easily. Here’s a project I wrote in Structured Text to model traffic lights.

RSLogix 500 Emulate

Learn Allen Bradley hardware using RSLogix 500 and the emulator. To get this working, follow the instructions listed here.

If you’re interested in becoming more versed in Allen Bradley, I recommend checking out this Udemy Course by Paul Lynn (aff. link – save $5). I took this course, and it’s a very comprehensive walk-through if you’re looking to go the A-B route.

As an aside, I will say, that nobody (I know) uses RSLogix 500. Usually, plants have upgraded to RSLogix 5000 or Studio 5000. This is especially true if they’re programming ControlLogix or CompactLogix controllers. With that said, the programming IDE is a bit different, but the fundamentals translate over pretty well.

FactoryIO with or without Add-ons

Lastly, there’s another simulator called FactoryIO, that can simulate an entire automated work cell. I think this is the coolest of all the options. The software ranges in price from $40 to $800, depending on which option you pick.

If you own a PLC, you can interface it with the software to build a working prototype. There’s also a Udemy course you can enroll in to get you started with Factory automation using FactoryIO.

Rather than use a simulator, you can also opt to use real hardware to practice your PLC programming skills.

Learn PLCs by Working with Real Hardware

There’s nothing like gaining experience working on real hardware. You can grow your skills tremendously by working in an automation lab on real PLCs. If you have a choice of which PLC to learn, I recommend staying with industry standards: Allen Bradley Logix, Siemens S7, Mitsubishi Electric, and OMRON.

Allen Bradley PLC Logix Controller
  • Facebook
  • Twitter
  • Pinterest
  • Buffer
  • reddit
  • LinkedIn

If you’re just looking to build some projects in a Hobby (or economic) capacity, I recommend checking out CLICK PLCs or Allen Bradley’s Micro820 series. The Micro820’s are nice because the software, Connected Components Workbench (CCW), is free and supports both logic and HMI development. Plus, A-B is a recognized brand, so you’d still learn some transferrable skills. Once you choose which PLC platform you want to work with, it’s time to wire up some sensors, and get your automation projects rolling!

Read Controls & PLC Books

Lastly, you can read some controls and PLC books to gain basic PLC programming skills. A lot of PLC programming is “seeing” and “repeating” examples that work. There’s no reason to reinvent the wheel if someone else has already figured out a way of doing something. This is especially true with controls engineering.

Here’s a list of some of my favorite Controls and PLC books.

Recap of PLC Programming Basics

All and all, PLC programming is pretty simplistic compared to more embedded control languages. If you have a background in digital logic gates and understand the “if-statement,” you can learn Ladder Logic in a matter of a couple of hours.

As with anything, it’s important to practice programming ladder logic if you want to get better at it. This article was designed as a primer for more complex industrial automation controls. If you enjoyed this type of content, please drop a comment below, and let me know your thoughts. You can also follow Learn Robotics on Facebook and Instagram to see what we’re up to behind-the-scenes.

Related Articles:

You May Also Like

8 comments

  1. Diovani Lauron

    I want to know more about robotics.

    1. Liz Miller

      Awesome! You’ve come to the right place. Be sure to check out some of our other robotics articles

  2. JIM SMITH

    i would like to know how to write ladder logic (safety first) rule of sum
    we have S7-200 and S7-300 in factory
    dont have labtop in factory to use
    yet i would like to learn at my own home.
    maintenance elec changing inputs / outputs with fault finding on a multimeter

    1. Liz Miller

      Hey Jim, Thanks for stopping by.

      It will be very difficult for you to work on Ladder Logic programs without a laptop. Siemens offers a free 30-day trial of TIA portal. I believe the actual license will run you around $3-5K per seat depending on which version you buy.

      I recommend downloading the trial version and using a simulator or picking up an S7 controller to practice with. If you’re interested in online courses, I recommend this S7-1200 & TIA portal course on Udemy.

      I’m in the process of creating more content around PLCs & HMIs on the blog. Stay tuned & Good Luck!

  3. Marcos Antonio

    Olá Liz gostei dos conteudos sobre plcs.
    Agradeceria mais informação sobre os meios de poder adquerir os teus curso de plc e robotica.

    1. Liz Miller

      Hello Marcos! Thanks for stopping by! I don’t currently have a PLC course, but I recommend a bunch in this article. The courses I teach use Arduino. You can read more about them here.

  4. Hi Liz, love your brain, really fantastic article. I am building an entire Micro Factory in the Shanghai area involving HMI / PLC’s (control Pasteurisers and Fermenter with their integrated sensors / vs motors) and some smart external devices (Glycol Chillers…) that will need to be ‘tweaked’, (danger Wil Robinson!). Anyways, it’s my bro’ and me so I get to learn the PLC bit. Your article helped SO much. Huge thanks.

    1. Liz Miller

      Thanks for the kind words, Nigel! Good luck with all of the controls work! It’s a lot of fun once you get the swing of things! ~Liz from Learn Robotics

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free Learn Robotics Swag

Patch/Sticker with every LR Kit

Work with an Engineer

Live Chat with an Instructor

365 Day Course Access

1 year access to every course

100% Secure Checkout

PayPal / MasterCard / Visa

Become a Learn Robotics Insider

Sign up and receive product announcements and discounts!

 

Success! Check your email for a surprise!

Pin It on Pinterest