Wednesday, April 25, 2018

IAM Search

How To Teach Yourself PLC Programming

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 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. My own personal favorites are the PLC models manufactured by Koyo and marketed through Automation Direct, both for their low cost and for the outstanding quality of their documentation (User’s Manuals). In the United States, where Allen-Bradley (Rockwell) holds the vast majority of market share in programmable logic controllers, it may be advantageous to learn on a low-end Allen-Bradley product such as the MicroLogix 1000. Beware the price of programming software, though!

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.

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 different 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 do nothing more than display the words Hello World! on the computer screen. It is an entirely useless program to run, but entering it and running it teaches 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”-type programs illustrating each one of those functions. These demonstration programs will not serve any useful purpose (other than to help you learn), and should be kept as simple as possible in order to minimize confusion.

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

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

Send and receive data through network connections with other PLCs (and other types of devices)

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.

After writing each demonstration program, you should add a lot of comments to it, 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

Mistakes you may have made (and thus might make again!) in using the function

Years ago when I was teaching myself how to program using the C language, I wrote a set of “tutorial” programs demonstrating common programming functions and techniques. The following is a partial list of these tutorial programs, which I still keep to this day:

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 “curses” commands for plotting characters at arbitrary locations on the screen

Program illustrating the declaration and use of data structures

Program illustrating how to prototype and then call functions (subroutines)

Program executing an infinite loop

Program illustrating how to return a pointer from a function

Each one of these tutorial programs is heavily commented, to explain to myself in my own words how they work and what they are doing. Not only did they help me learn how to write programs in C, but they also serve as a handy reference for me any time in the future I need to refresh my 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.


Go back reading to Human Machine Interfaces

Go back to the first page, Programmable Logic Controllers

Go Back to Lessons in Instrumentation Table of Contents

Comments (1)Add Comment
written by wale, October 05, 2015
I am happy to have gotten this chanel.

Write comment

security code
Write the displayed characters


Related Articles


  • ...more


Important: All images are copyrighted to their respective owners. All content cited is derived from their respective sources.

Contact us for information and your inquiries. IAMechatronics is open to link exchanges.

IAMechatronics Login