Learn PLC Programming Online Now

5/5 (2)

Learn PLC Programming
Have you been wanting to learn PLC (Programmable Logic Controller) programming but are not sure where or how to get started? Well rest assured you’ve come to the right place! Here at PLCGurus.NET this is precisely what we’re all about! Whether you’re an experienced programmer or completely new to the fascinating world of PLC programming, we’ve got something for everybody.

To get you started, it is recommended that you read this introductory article on what exactly a PLC is and how it fits into modern industrial control systems today. Then move into some of our more advanced topics right here on PLCGurus.NET and on our Learn PLC’s channel!

What is a PLC?

A PLC (Programmable Logic Controller) is a real-time industrial computer control system that monitors the state of various input devices and makes decisions based on user-defined code (logic) to control the state of output devices. It was developed by Dick Morely back in 1964 and it has forever changed the face of manufacturing and industrial automation.

Initially the PLC was used to replace relay logic, but its every-increasing range of functions includes timing, counting, calculating, comparing, and the processing of analog signals.

PC Components

The structure of a PLC is based on the same principles as those employed in computer architectures. You can think of a PLC as a highly “ruggedized” industrial computer that is designed to withstand harsh environments (i.e., high temperatures, dirty or dusty environments) and is highly modular. This means that you can add various Input/Output modules and module types in an almost unlimited ordering – the only constraint being the number of Input/Output slots you have a available in your physical rack (chassis).

PLC’s come in all shapes in sizes, however, they all will contain some basic hardware and software features:

  • Power Supply
  • Rack or Chassis
  • Processor (CPU)
  • Communication Module (if not embedded)
  • Input Module(s)
  • Output Module(s)
  • PLC Programming Software (via a PC or programming unit)

PLC Programming
Fundamental Differences Between A PLC and a PC

As we mentioned the architecture of a PLC is basically the same as that of a personal computer. However, unlike PC’s, the PLC is designed to operate in the harshest of industrial environments that have a wide range of ambient temperatures and humidity. Additionally, properly designed PLC installations can mitigate EMI (electro-magnetic interferance – NOISE) present in almost all industrial establishments.

PC’s are highly complex computing machines capable of executing several programs and tasks concurrently whereas a PLC is a dedicated real-time system that executes a single (can have multiple programs in ControlLogix system, however, they still executed one at a time in a prioritized ordering) program in an orderly and sequential fashion from first to last instruction.

Unlike PC’s, the PLC is programmed in relay ladder logic or other “easily” learned languages. It comes with its programming language built into its memory and has no permanently attached keyboard, monitor, CD drive, printer etc.

PLC control systems have been designed with maintainability and ease of installation as a key factor. Troubleshooting is simplified by the use of fault indicators on the processor and I/O modules. Furthermore, in traditional PLC chassis I/O is modularized to allow easy replacement and configuration.

Differences Between Discrete And Analog I/O

Discrete I/O interface modules connects field input devices of the ON/OFF nature. This classification of I/O is related to bit oriented inputs and outputs – simply put – they can be described in the controllers memory using a 1 or 0. Examples of discrete I/O are:

Discrete IO

Each discrete I/O module is powered by a field supplied voltage source. Common voltage sources are 120 VAC and more commonly 24 VDC. Discrete PLC modules will specify whether it will accept AC, DC or both AC and DC, therefore, careful selection is required when sourcing these modules.

Analog input and output devices have an infinite number of values and can take on any value between 0..1. Typical analog input and output devices vary from 0..20 mA, 4..20 mA, -10..10 VDC, and 0..10 VDC.

An analog input module will receive an analog signal and convert the signal to a digital one through various Quantization Methods.

Likewise, an analog output module will receive a digital signal and convert it to an analog signal that operates the output.

Understanding a PLC’s Scan Cycle

During each program scan cycle, the processor reads all the inputs, takes these value, and energizes or de-energizes the outputs according to the user program.

PLC Programming

  1. Check the status of all the inputs – is the input ON (1) or OFF (0).
  2. Execute the user-program – this accomplished by executing each instruction and solving the rung logic.
  3. Update the output status – write a logic 1 (ON) or 0 (OFF) to the output.

Granted this is a bit of a simplification and with more modern PLC’s or PAC’s (Programmable Automation Controllers) as they’re commonly referred, more elaborate scan patterns can be configured. But I say let’s not muddy the waters too much here, however, if you’d be interested in a sneak peak at one of our videos in our Studio 5000 Essentials video series that talks about these more advanced scan patterns, go ahead and view it now!

Not to oversimplify the importance of processor scan and its impacts on overall response time, however, since this is an introductory welcome to PLC Programming article, I will reserve those more advanced discussions for other articles. In fact, we’ve done an article on this very topic at System Overhead Time Slice.

PLC Processor Memory Organization

The memory structure of a PLC processor consists of several areas, some of these having specific roles.

With “rack-based” memory structures addresses are derived using the rack number, the I/O module slot number and the screw terminal number where the I/O device is wired into. A typical “rack-based” PLC is the SLC 500 platform of programmable logic controllers and their memory space into two broad categories, namely, Program Files and Data Files.

PLC Programming
SLC Memory

With “tag-based” memory structures all data are assigned a variable name called a “tag”. A program can be developed using only tag names but you must assign input and output tags before the program can be executed.

PLC Modes Of Operation

A PLC has basically two modes of operation: the Program Mode and some variation of the Run Mode. A three-position keyswitch may be used to select different processor modes of operation.

PLC Programming

The Program Mode is used to enter a new program, edit or update an existing program, upload files and download files. It is important to note that in this mode of operation all outputs are de-energized.

The Run Mode is used to execute the user program. Remote PLC programming or mode selection is disabled when the key is in the Run Mode position.

Network Switches

Test Mode is a software mode by which the PLC programmer and test or monitor the user program without energizing any outputs.

Remote Run Mode (REM) allows the PLC to be remotely changed between program and run mode by a personal computer connect either directly or via a communication protocol to the PLC processor. Typically most processors are place into REM mode to allow the the engineering or maintenance staff the greatest flexibility when perform PLC programming tasks.

Most Common PLC Programming Languages

PLC programming involves “downloading” a compiled sequence of binary coded numbers into the PLC system. There are various ways we can perform PLC programming tasks, however, we will focus on 3 of the most common ways indicated by a red box in the image below.

PLC Programming Methods
PLC Programming Methods

We will focus on three in particular:Ladder Logic, Function Block, Structured Text or Statement Logic

PLC Programming Using Ladder Logic

The most common PLC Programming “language” is something referred to as Ladder Logic. Ladder Logic has evolved from the days of controlling machines or processes using electro-mechanical relay devices or “relay logic” as it is referred. It is a graphical representation of the “relay contacts” that would have been used in a relay controlled system. Each rung of ladder typically has one coil at the far right and then logical “input contacts” to the left.

-[    ]- Normally open (Examine if Closed) contact.

-[ \ ]- Normally closed (Examine if Opened) contact.

-(    )- Output Coil.

The input contacts are then arranged in a logical AND, OR type configuration to turn on an output. We provide a complete PLC programming instruction set list below so keep reading!

PLC Programming Using Function Block

Another common way to program a PLC is using Function Block. A Function Block Diagram (FBD) is a graphical depiction of process flow using simple and complex interconnecting blocks. FBD’s are typically organized into multiple “sheets” allowing one to organize the instruction sets – typically one sheet per device. See below a sample function block routines for 4 different motor controllers.

PLC Programming
Image Source: http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm009_-en-p.pdf

It’s important to note that once the routine is executed all sheets in the list are executed as well. Below is a Function Block program created using Studio 5000 software, making use of a PIDE (Proportional Integral Derivative Enhanced) instruction to control a closed loop process. You can see that the instruction effectively get “wired up” using the various input and output tags.

PLC Programming
Function Block Program Using Studio 5000 IDE

PLC Programming Using Structured Text

Structured text is a textual programming language that uses statements to define what to execute. It follows more traditional programming conventions that you would find with procedural type languages, however, typically it is not case sensitive.
A series of statements (logic) is composed by formulating assignments and relationships using various operators as depicted.
PLC Programming
Structured Text Operators


In most cases where I’ve seen this type of PLC programming language used is when the programmer needs to handle those types of functions or operations that can’t be defined clearly or efficiently using the other two methods.

One word of caution – as a PLC programmer we always have to be cognoscente of who will be maintaining our programs after the project is complete. In my experience, this often will be left to maintenance staff, namely, electrical maintenance. This is why ladder logic is by far the most common language used in industry today, because as we mentioned early it evolves from the relay logic circuits of old that electricians in most facilities are familiar with.

PLC Programming Ladder Logic Instruction Sets

This is largely dependent on the PLC programming platform you are using, however, most PLC’s today will include the following instruction sets or groups and this is not an exhaustive list by any means:

  • Bit – Binary type ON/OFF instructions XIC, XIO, OTL, OTU, OTE, ONS
  • Timer/Counter – TON, TOF, RTO, CTU, CTD, RES
  • Message/System – message and system instructions
  • Compare – standard compare type instructions CMP, LIM, MEQ, EQU, LES, GRT, LEQ, GEQ
  • Math – these are your standard mathematical instructions CPT, ADD, SUB, MUL, DIV, MOD, SQR, NEG, ABS
  • Move/Logical – these are your move type and relational instructions MOV, MVM, AND, OR, XOR, NOT, SWPF, CLR, BTD
  • File/Misc. – file manipulation type instructions FAL, FSC, COP, FLL, AVE, SRT, STD, SIZE, CPS
  • File/Shift – continuation of file instructions BSL, BSR, FFL, FFU, LFL, LFU
  • Sequencer – SQI, SQO, SQL
  • Program Control – JMP, LBL, JSR, JXR, RET, SBR, TND, MCR, FOR, BRK
  • Motion Instructions – for PLC’s that support servo motion
  • Advanced Math/Trig – for PLC’s that support advanced mathematical operations

Enough Talk – Let’s Get Started!

Okay, okay we’ve rambled on enough, let’s do the deep dive and get started into the first video in our Studio 5000 Essentials series now!

Or if networking is more your thing check out this first video in our Networking Essentials series now!

If you enjoyed these videos and this article and want to become a member of one the Internet’s fastest growing communities of professional engineers, technicians and technologists, Register Here! Also, check out our YouTube Channel to see me more great videos…and don’t forget to subscribe to our channel!

Thanks for reading (and watching!) and feel free to leave a comment and rate this post. Also, if you run  into any problems at all be sure to check out our Live and Interactive PLC Forum!

If you would, please consider supporting us by shopping at one of our great affiliates!


The PLCGurus.NET Team!

Fred Graham

Author: PLC Guru

Hi, Fred here, I am the founding member and site moderator here at PLCGurus.NET. With over 20 years experience in the Industrial Automation and Control Systems Engineering field I hope this site will become your GOTO resource for all things Industrial Automation and Design. Enjoy the site and visit often!