Introduction to Programmable Logic Controllers (PLCs)

Technology
Introduction to Programmable Logic Controllers (PLCs)
1200px-FANUC_PLC - public domain
This large black box with wires attached to it is a PLC, handling digital IO like a giant Arduino.

What is a Programmable Logic Controller, or PLC?

If you’ve used a computer, and you’ve used an Arduino, Raspberry Pi, or any number of other microcontrollers, you might think that a computer based on the physical world is a relatively new concept. A digital input causes some sort of conditional logic to make something blink, your robot to move, a signal to be transmitted, or any number of other things.

This type of logic has, in fact, been going on for quite some time in industry. In 1968, a man named Richard E. Morley proposed the Modular Digital Controller (MODICON) to a car manufacturer. This MODICON, or programmable logic controller (PLC), was used to replace complicated relays with virtual programmable relays, making machinery changes in industry much, much faster.

This later became the commercial MODICON 084, which led to many more manufacturers making their own version. Here’s an article on the history of the PLC if you’d like more background.

How do You Program One?

Computers and microcontrollers that you may be familiar with use a typed programming language to let them perform their tasks. You might assume, as I did when I first learned to program in this fashion, that a PLC uses something similar, like C, BASIC, or Python. It doesn’t (at least not in its most basic form); instead, it uses something called “ladder logic.”

This ladder logic looks exactly like it sounds, with a ladder-like screen with characters like “X1” with a normally open contact connected to an output labeled as, say “Y0” at the end of it. These ladder “rungs” are suspended between two rails which represent electrical power. Thus an electrician with a background in setting up relay logic circuits could, in theory, read this code without additional training.

To illustrate this further, if you were to set up a very simple program where if input “X1” is on, then output “Y0” turns on, it would be drawn like this:

"Hello world" in ladder logic
“Hello world” in ladder logic

 There are several other ways to program a PLC, like structured text or sequential function charts (and there are many more functions than what I’ve listed above), but ladder logic is the most commonly used from my experience.

What are the Advantages?

In industry, the big advantage of a PLC using ladder logic is that, as mentioned earlier, a technician can, in theory, read the code like an electrical diagram. Sometimes they may have access to make changes, but when they don’t, there is at least some semblance of logic to what’s going on to non-programmers.

The other huge advantage is that they are extremely robust. Most have input/output cards that can be changed separately from the processor itself, and I have never seen the processor itself fail that I’ve been in charge of. OK, fail on its own is more accurate; I did shock one to death, but that was certainly no fault of its own.

If you’re making something for your use or some sort of prototype (like most Makers are), you expect to have to fiddle with your electronics to some degree. If you’re designing a machine that makes the company you work for millions of dollars each year, you absolutely don’t want any electrical issues getting in the way. Multiply this by all of the machinery in your plant (dozens or hundreds of PLCs) and you really don’t want to have to look at them every day.

A beautiful panel, but would this really fit on your robot?
A beautiful panel, but would this really fit on your robot?

Why don’t Makers Use Them More?

The reason, in my opinion, that PLCs aren’t used in home projects more is cost. A full PLC with input, output, and any number of other cards (Ethernet for example) can easily cost thousands of dollars. Add another couple thousand for an HMI (human machine interface touch screen) and, in many cases, more money for the programming software, and you have something that is well out of most Maker budgets.

Additionally, size can be a hindrance to implementing this type of control. Even most small PLCs are much larger than an Arduino board. This is not generally a problem in industry, but it doesn’t work well for a robot that measures a few inches in each dimension.

How Can I learn about Them?

I’m a mechanical engineer and have a good amount of experience with PLC programming. I’ve programmed a dozen or so machines from scratch and troubleshot many more. Although I had some limited programming experience when I started, ladder logic was absolutely foreign to me to begin with. From talking to electrical engineers in industry, they generally have no education on this particular programming style in the beginning either.

That being said, if you one day want to program production machinery in an engineering role, most likely you will learn it on the job. For this, a good internship is an excellent thing to have. I learned an incredible amount during my “co-op” semesters about electronics as well as mechanical stuff that helps me make interesting things to this day.

On the other hand, if I’m doing a project at home, most likely I’m still going to be using some sort of “Maker-class” board. For something like Battlebots, however, where durability is king, I might go for a PLC if my budget was large enough.

Bonus question, what type of PLC was I thinking of when I diagrammed the ladder with X1 and Y1?

13 thoughts on “Introduction to Programmable Logic Controllers (PLCs)

  1. Brian Bloom says:

    Ah, nice flashbacks of Allen Bradley programming! Ladder logic FTW!

  2. floppystick6 says:

    If only there was a good/easy way to program your arduino using ladder logic. That would make it a good way to learn how to program ladder logic and then one could be a step ahead during their internship or co-op. hint hint wink wink

    1. Jeremy Cook says:

      Hmm, that is a good idea!

    2. NZL72 says:

      Like this?
      http://soapboxautomation.com/products/soapbox-snap/

      SoapBox Snap is a free and open source PC-based automation platform. It includes a ladder logic editor and a “soft” runtime right out of the box. The ladder editor includes standard instructions like contacts, coils, timers, counters, rising edge and falling edge, and set/reset instructions. The soft runtime comes with drivers for Phidgets I/O devices that plug right into your USB port. SoapBox Snap also comes with an Arduino Runtime, which means you can download your ladder logic programs to an Arduino (UNO or Nano board) and even do online debugging and forcing.

  3. Douglas Crowder says:

    Bonus question, what type of PLC was I thinking of when I diagrammed the ladder with X1 and Y1?…

    TI-505?

    1. Jeremy Cook says:

      I was thinking of any Automation Direct PLC, but maybe others use X and Y as IO. Thx for the guess!

      1. Douglas Crowder says:

        TI uses X and Y as well. Nice article!

        1. Jeremy Cook says:

          Thanks!

  4. tina says:

    Fundamentals of PLC programming and Ladder logic programming ..learn it from automation forum

    https://automationforum.in

  5. Defakto says:

    I use unitronics plcs at work a lot. Free software, Hmi all for a decent price.

    I do like some of the offerings at automation direct as well.

  6. edgarschmidt says:

    Nice basic article about PLCs! I agree with your point about their resilience and stability.

    Now, although I have a fair amount of experience with them and have programmed many brands including AB and Siemens, I find that the programming language (I’m including structured text and function blocks here as well) very antiquated and error prone.

    At the beginning I thought it was a great idea to basically draw the line diagram of the circuit and bam, the machine was alive! However after learning other “higher level” programming languages and spending countless hours debugging ladder logic, I ended up reevaluating my position.

    In my opinion, the lack of expressiveness in ladder logic is a leading factor to the creation of bugs in production while also making troubleshooting harder than it should be as only the equivalent to a couple lines of code can be read at a time. Furthermore, is not uncommon to have to keep many of the potential lines related to the issue at hand in a “mental cache” while backtracking several steps to solve a problem.

    The original concept of mimicking a physical circuit definitely had its merits but I think is time to find a better solution. We shouldn’t need to formulate with primitive glyphs the solution to a problem. I would much rather lean on the past 30 years of programming language development to find a better way to express my thoughts.

  7. Atul Wadhai says:

    I really liked your article , your article is very
    petrified me in the learning process and provide
    additional knowledge to me , maybe I can learn
    more from you, you can also use a electrical engineering courses to help you get started in writing yours.

Comments are closed.

Discuss this article with the rest of the community on our Discord server!
Tagged

Jeremy is an engineer with 10 years experience at his full-time profession, and has a BSME from Clemson University. Outside of work he’s an avid maker and experimenter, building anything that comes into his mind!

View more articles by Jeremy S Cook

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK