Examples of PLC Programming

Programmable Logic Controller And RelaysIf you are thinking of working in the automation industry, then you have to get familiar with PLCs and how to program them. Industrial automation plays a very important role in manufacturing and processing industries and Programmable Logic Controller (PLC) is extensively used for automation and process control systems. To have a head start on learning about PLCs, browsing through the course PLC Automation Training may be a good idea.

What is PLC – Is it a Computer?

A PLC is similar to a computer as it has a central processing unit and generates outputs on the basis of some inputs. The logic or sequence of operation for a process is executed as per a control logic program or software. A PLC is a microprocessor based programming unit used to perform several functions in industrial processes. But it differs in some ways from a computer. Unlike desktop computers, PLCs have multiple inputs and outputs, and are designed for the rugged operation under extreme industrial conditions. They operate under extended temperature ranges, have immunity to electrical noise, and have resistance to vibration and impact.

A PLC may be seen as a digital industrial computer control system mainly used for automation of industrial processes, like controlling machinery or factory assembly lines. It continuously monitors the state of input devices, such as sensors, pressure switch, level switch, on/off switch, and makes decisions based upon a custom program or logic to control the state of the output devices like actuators, motors, relays or solenoids, and analog devices. It can also measure analog process variables, such as temperature and pressure and values from positioning and vision systems. The programs that are required to control the operation are usually stored in battery-backed or non-volatile memory.

The main units of a PLC are:

  • CPU (Central processing unit)
  • Input modules
  • Output modules
  • Power supply unit or module
  • Programming device

The Central Processing Unit (CPU) is the heart of the PLC system. The CPU reads input data from various sensing devices, executes the user program from memory and sends appropriate output commands to control devices. It communicates with the Input, Output devices through the Input, Output modules and also performs diagnostics tasks.

Applications of PLCs in Industrial Automation

PLCs are indispensable parts of industrial automation. PLCs were invented as replacements for automated systems that would use hundreds or thousands of relays, cam timers, and drum sequencers. Often, a single PLC can be programmed to replace thousands of relays. The biggest advantage of of using programmable controllers is that they can replace the complications of rewiring the hard-wired control panels with simple software revisions when there is change in process, product model or sequence of operation. Expanding and contracting a process becomes much easier with a PLC based automation system.

Complicated wiring and need of hardware like timers, and relays can be reduced by using a PLC and writing software program to execute the control logic. This results in smaller and simpler control panels which occupy lesser space. Another advantage of a PLC system is that it is modular. That is, you can mix and match the types of Input and Output devices to suit your application.

What Language Is Used To Program PLCs?

The earlier PLCs used simple ladder logic, similar to electrical schematic diagrams, for setting up the logic and sequence. The electricians were able to trace out circuit problems with schematic diagrams using ladder logic. This program notation was chosen to reduce training demands for the existing technicians. While Ladder Logic is the most commonly used PLC programming language, it is not the only one. The following are some of the commonly used languages used to program a PLC:

  • Ladder Diagram (LD): The traditional ladder logic is a graphical programming language. Though initially it used simple contacts that simulated the opening and closing of relays, later it expanded to include counters, timers, shift registers, and math operations.
  • Statement List (STL): A high level text language that uses structured programming. It follows a structured syntax and supports a wide range of standard functions and operators.

The course PLC Programming From Scratch is a great course to delve further into PLC programming and learn about the basic tools and syntax.

Examples in STL

PLCs use the bit logic instructions of a binary system, which interpret signal states of 1 and 0 and combine them according to Boolean logic. These combinations produce a result of 1 or 0 called the ”result of logic operation” (RLO).
Boolean bit logic applies to the following basic instructions:

In STL, the following instructions are used to perform Boolean bit logic operations:
• A And
• AN And Not
• O Or
• ON Or Not
• X Exclusive Or
• XN Exclusive Or Not
• O And before Or

Inserting a ‘(‘ after each instruction can be used for performing nesting expressions.
You can terminate a Boolean bit logic string by using one of the following instructions:
• = Assign
• R Reset
• S Set

Example 1

If the circuit for energizing  the output (Q 4.0) which is the coil of a contactor, has one NO (Normally Open, I 1.0) ‘ON’ switch in series with a NC (Normally Close, I 1.1) ‘OFF’ switch then the statement for the same in STL can be written as:

A I 1.0
AN I 1.1
= Q 4.0

Example 2

If the circuit for energizing  the output (Q 4.0) which is the coil of a contactor, has one NO (Normally Open, I 1.0) ‘ON’ switch in parallel with a NO (Normally Open, I 1.1) ‘TEST’ switch, then the statement for the same in STL can be written as:

O I 1.0
O I 1.1
= Q 4.0

Timers and counters can be also programmed and instructions can be written to set and reset their values.


Several companies like Allen Bradley, Delta, Siemens, and Schneider have their own set of PLC products and also their own proprietary  software programming language. Once you understand the basic concepts about PLC programming, it will easy for you to learn the programming methods of any of the companies. Along with the programming knowledge it is also important to understand the wiring and installation processes involved with PLCs.