Vol. Control Systems
Chapter Basics of Programmable Logic Controllers (PLCs)

How to Teach Yourself PLC Programming

Learning PLC programming at home, school, or work is a goal of many control engineers. While equipment may be expensive, there are many cost-saving techniques to help you learn faster.

Learning PLC programming is a very important skill.

If your job involves programming, then you will likely learn what you need through hand-on experience. But before that happens, it can be very important to understand how to learn on your own.

Many educational programs are available - mostly oriented around 2-year community colleges with technical trades programs in advanced manufacturing. These can be cost-effective for many people due to low tuition rates, but in many cases, the schedule is the tough part. Taking formal classes while balancing a work and family schedule is difficult, if not impossible. For many of those in that profile, learning at home is an absolute necessity.

How to Learn PLC Programming at Home

First and foremost, you need to get your very own PLC to work with. Computer programming of any kind is not a spectator sport, and can only be learned by a significant investment of time and effort at the keyboard. In many ways, learning to program is like learning a new spoken or written language: there is new vocabulary and new grammatical rules to master, and many ways to make mistakes.

Fortunately, many low-cost PLCs exist on the market for individuals to purchase. Over the years, many models of PLC have come and gone. In past eras, two of the favorited PLCs were the “CLICK” PLC models manufactured by Koyo and marketed through Automation Direct, and also the Allen-Bradley MicroLogix series of PLC (especially the 1000 and 1100 models). However, the latter model has been discontinued and is more difficult to obtain. 

To design an effective learning system, understand that the more budget you have available, the closer you will come to building a realistic control system. This should come as no surprise to any engineer.

Learn PLC Programming - Without a PLC!

The programming environment and I/O connections are the two main areas in which a PLC stands alone compared to all other microporocessor-based platforms. If these two obstacles could be solved, there would be no shortage of low-cost PLC trainers for homes and small classrooms around the world. It turns out, there are a few cases of some excellent PLC 'simulators' installed onto these low-cost microcontroller platforms.

OpenPLC is one such example of a tag-based ladder logic programming environment, which can be installed onto a personal computer. Programs are written just like they would appear in a PLC, but then are downloaded into a microcontroller. The compatible platforms are numerous, but they include the popular Arduino and Raspberry Pi, which can both be purchased for a very reasonable cost.

Many tutorials exist for getting a start with the Arduino platform using OpenPLC, making this an excellent starting point before investing in a more 'official' training setup with industri-standard PLC hardware and software. Two such tutorials include Control.com's own 'Getting Started with Ladder Logic using OpenPLC for the Arduino' and 'Building a Start/Stop Ladder Logic Program with an Arduino'.

High-Cost PLCs

The version of PLC for small applications considered an upgrade to the MicroLogix was the CompactLogix with built-in I/O points. The Rockwell L16 processors have 16 digital inputs and outputs, and the L24 contains an additional set of built-in analog I/O points. These PLCs are excellent for learning modern PLC programming, but both the hardware and software licenses can be quite expensive. Even used models can cost well over $2,000, and the licenses can cost up to $1,000 per year. If a company intends to establish an in-house test and training room, this model may be an excellent consideration, but it’s probably outside the budget for most users.

Medium-Cost PLCs

Mid-level PLCs that are appropriate for learning can come from a variety of sources. Rockwell’s replacement to the MicroLogix is the Micro800 series of PLC, which is programmed using the Connected Components Workbench (CCW). A major benefit of this series over the older MicroLogix 1000 is the Micro800’s ability to network with external equipment, as long as a model with Ethernet is selected. The software is free from Rockwell, and the hardware is lower cost than more advanced PLC lineups. It may still cost several hundreds of dollars. Siemens also offers a cost effective S7-1200 PLC in a range of starter kits which include not only the PLC, but an HMI and a software license. These can be obtained for fairly reasonable costs, but are still likely to cost several hundred dollars. The benefit of these two options comes from learning programming on an industry-standard platform, which may lead to more lucrative job opportunities.

Automation Direct Productivity series of modular PLCs falls into this price range, also with free software. Although not as common in mainstream industry, they are flexible, adaptable, and reliable–and the programming is quite easy to learn. An example of a home-built trainer using a Productivity 1000 PLC is shown in the image below, along wit ha varieyt of sensors, wire connection points, and troubleshooting tools on an aluminum A-frame design.

 

 

Low-Cost PLCs

For those on a tight budget (which likely includes most of us), there are still a few options available. Automation Direct offers a few choices, including the CLICK series with built-in I/O. These PLCs cost less than $100 (although are often out of stock due to demand) and include free software. An interesting alternative PLC includes an Arduino Uno inside a plastic DIN rail-mounted case, although it is only compatible with languages designed for an Arduino microcontroller. There are a few PLC ladder diagram options available, but if your intent is to learn ladder logic programming, you must be prepared to seek out appropriate software if you plan to use a microprocessor.

Most of these PLCs are excellent choices for nearly any learner, but be careful about installation instructions. These PLCs will likely require AT MINIMUM, a DC power supply, line power cable for that supply, and a PC programming cable. You should also highly consider a breaker or fuse with a rating sufficient for the PLC, and a disconnect to turn it on/off. These would all usually be mounted on a short length of DIN rail to keep it all tidy. 

Don’t just order the PLC and assume it will arrive with everything required to run the system.

Getting Started with PLC Learning

The first document you should read once you get your PLC is something called a Getting Started guide. Every PLC manufacturer publishes a document with this name (or something similar such as Quick Start or Getting Results). This manual will step you through all the basic procedures for entering a simple program into your PLC and getting it to run. It is generally far easier to learn programming by copying and adapting a worked example than it is to start from a “blank page” on your own, just as it is easiest to learn a spoken or written language by practicing sentences spoken in that language by other people before constructing your own sentences from scratch, even though that is the eventual end goal.

In order to work with your PLC, you will need a convenient way to simulate different input conditions coming from discrete (switch) devices. Any set of hand-operated switches will do, my recommendation being household light switches (very inexpensive and rugged). Attaching an array of these switches to a wooden board along with the PLC and interconnecting terminal blocks forms what is often called a PLC trainer. The following photograph shows one such trainer, using an Allen-Bradley MicroLogix 1000 PLC:

 

 

Input devices are simple to obtain because they can be any simple switch or metal contact from the 24 volt supply to the input terminal. The light switches in the previous diagrams are great examples, but a quick search of any electronics aisle at a thrift store will yield an amazing variety of power tools and broken appliances. Every one of them contains switches which can be repurposed with a little elbow grease. In a pinch, I’ve simply taped paper clips to the table, bent the ends slightly, and relied on the spring constant of the metal to fashion my own switches.

Outputs are simpler. PLCs contain built-in LEDs for all input and output terminals. Although you must install an input device to provide inputs, you don’t even need an output at all. It can be more exciting and real-world to install an output relay, or perhaps an indicator light, but it is sufficient to simply monitor the LEDs on the PLC to identify whether your logic is functional or not.

The educational value of building your own PLC trainer is difficult to overstate when learning about PLCs. Learning how to build properly-functioning I/O circuits is every bit as important to a working technician as learning how to develop PLC programs. Additionally, the experience gained in general wiring layout and fabrication are valuable skills for any instrumentation practitioner.

Another example of a PLC trainer with a bit more elegance is the following unit, housed inside of an attaché case. Not only does this trainer contain an Allen-Bradley MicroLogix 1100 PLC along with input switches and output indicator lights, but it also includes an HMI touch-screen panel on a fold-down bracket:

 

 

Learning PLC Software Commands

Once you have learned the basic steps for entering, running, and saving a PLC program, you are ready to begin building your knowledge of the language’s vocabulary and grammar. In computer programming of all types, there are many different built-in functions of the language one must become familiar with in order to do useful tasks. A great way to learn how to use these functions is to create your own “demonstration” programs illustrating the use of each function.

For example, if you open up the pages of almost any computer programming book, somewhere near the beginning, you will find a demonstration program called “Hello World!” The purpose of a “Hello World!” program is to accomplish nothing more than to display the words Hello World! on the computer screen. It is an entirely useless program to run, but it is highly useful for teaching the programmer the basics of program construction and text message functionality.

By the same token, you may learn the basics of each programming function by writing simple “Hello World” types of programs illustrating each one of those functions. These demonstration programs might not serve any useful purpose (other than to help you learn), and therefore should be kept as simple as possible in order to minimize confusion.

For example, every PLC provides instructions to perform the following tasks:

  • Read and monitor discrete events
  • Turn discrete outputs on and off
  • Count discrete events
  • Time events
  • Control events in a specific sequence
  • Compare numerical values (greater than, less than, equal, not equal)
  • Perform arithmetic functions

Just as every spoken or written language has verbs, nouns, adjectives, and adverbs to describe actions and things, every PLC programming language has specific functions to perform useful tasks. The details of how to perform each function will vary somewhat between PLC manufacturers and models, but the overall functions are quite similar. The reference manuals provided for your PLC will describe in detail how to use each function. Your task is to write simple demonstration programs for each function, allowing you to directly explore how each function works, and to gain an understanding of each function by observing its behavior and also by making (inevitable) mistakes.

The following image shows a trainer built into a small plastic case using a Rockwell Micro830 PLC, along with a simple DC power supply and terminal block distribution strip. The simplicity of this learning design allows you to learn even the most advanced programming functions without spending unnecessary time in the wiring and construction phases. A common mistake is assuming that a trainer must be complex enough to replicate any facility experience in order to learn, and this example proves this is simply not the case.

 

 

Documenting Your Successes (and Failures)

After writing each demonstration program, you should add a lot of comments to the commands, the ladder rungs, and the tags, so you will be able to understand what you did later when you go back to your demonstration program for reference. These comments should cover the following points:

  • Proper use of the function
  • A verbal description of what the function does
  • A list of possible (practical) uses for the function
  • Idiosyncrasies of the function (i.e. odd or unexpected behavior, tricky points to watch out for)
  • Mistakes you may have made (and thus might make again!) in using the function

This would be a similar recommendation for a new programmer learning a C language, for example. She or he might write a set of “tutorial” programs demonstrating common programming functions and techniques. The following is a partial example list of these tutorial programs, and what they might include:

  • Program that accepts and then prints alphanumeric characters (including their equivalent numerical values)
  • Program demonstrating how to use command-line arguments to the main() function
  • Program demonstrating basic “curser” commands for typing characters at arbitrary locations on the screen
  • Program illustrating the declaration and use of data structures (ints, bools, etc)
  • Program illustrating how to prototype and then call functions (subroutines)
  • Program executing an infinite and a conditional loop
  • Program illustrating how to return a pointer or variable from a function

Each one of these tutorial programs is heavily commented, to explain in your own words how they work and what they are doing. Not only do they help to learn how to write programs, but they also serve as a handy reference any time in the future when you may need to refresh your knowledge. The act of writing tutorial programs is akin to journaling as a way to work through complex problems in life–in a way, it is like having a conversation with yourself.

No Right (or Wrong) Training Bench Setup

As with programming itself, there is no right or wrong way to construct a trainer or teach yourself PLC programming. Even if your benchtop setup is constructed from leftover parts and contains obsolete equipment, it is far superior to a system which was never built for fear of building it wrong. 

In a future job, you will still need to learn the proper operating procedures and policies for that company, but the value you bring with hands-on programming and wiring skills will immediately put you ahead of any competition.

Indeed, it’s possible that like many control engineers, you will come to see it as a new addiction and find a lot of enjoyment in building your own creative solutions to routine problems using recycled control equipment, teaching not only yourself but friends, family, and even future generations of engineers to think and create with both their minds and hands. There’s no price tag on that kind of impact.

REVIEW:

  • First, secure a low-cost PLC with free programming software
  • Input devices are critical, and standard light switches are less than $1 each
  • Outputs are optional since the PLC has built-in LED indicators for each output terminal.
  • Remember to document everything. If it works, explain what you did. If it doesn’t work, list the symptoms as a note to watch out for next time.

 

Interested in more PLC content?

Related Videos:

 

Textbook Pages:

 

Tutorials and Technical Articles: