In this article we are going in-depth into what a programmable logic controller (PLC) is, and we’ll also provide useful resources to get you started into this fascinating world. So what is a programmable logic controller?
A programmable logic controller is probably the single-most important invention used in industrial manufacturing today. It was first introduced in the early 1960’s primarily for the automotive manufacturing industry by a mechanical engineer named Richard Morley.
Prior to the inception of the programmable logic controller, manufacturing processes were largely implemented using hundreds and sometimes even thousands of control relays housed in large metal enclosures. This made implementing control systems difficult and expensive.
With the advent of the PLC and computerized control, this task became much easier and less error prone. For these reasons, the programmable logic controller is the primary control mechanism used in industrial manufacturing today.
Programmable Logic Control vs. Relay Control
In this section we list some of the advantages programmable logic control has over traditional relay logic control.
- Programmable logic controllers are extremely flexible. Due to the fact they are programmable via software, it is very easy to make changes to processes or sequences without the need to change any wiring at all. With relay control, this was not the case. Any time a sequence or process change was needed, in almost all cases this meant wiring and relay configurations needed to be changed as well. This cost time, money, and was error prone.
- It is very easy to re-purpose a control system utilizing programmable logic control once the life-span of the process or machine has expired. This was not the case with relay control logic and relay racks. It was very common practice replace, rewire, or completely scrap relay control cabinets after they have served their purpose.
- Smaller electrical enclosures can be leveraged due to the compact size of programmable logic controllers. This means that valuable production floor space can be used more efficiently. Compare that to the metal enclosures needed to house the relay control systems of old. It was not uncommon for these enclosures to be 4, 5 or even 6 doors wide spanning 10 to 20 feet in length.
- Programmable logic controllers more reliable. This is due to the absence of moving parts due to solid-state transistor type switching. With control relays, contacts wear out after so many switches and have to be replaced. It was an extremely difficult and time consuming task to try to troubleshoot an intermittent contact that was not fully closing due to pitting caused by electrical arcing or welded shut.
- Relays take more time to fully open and fully close than do transistors and solid state devices. The switching time of relays is not consistent across manufacturers and deteriorates with time as the mechanical properties begin to fatigue. These variations inevitably introduce control errors that are very difficult to troubleshoot. These concerns are almost completely eliminated with programmable logic controllers.
Main Parts of a Programmable Logic Controller
The programmable logic controller can be described by examining five main parts:
- Power Supply and Chassis
- Central Processing Unit (CPU)
- Input Modules
- Output Modules
- Communication Modules
For the purpose of this article, we are going to use an Allen Bradley ControlLogix as our primary PLC model. Allen Bradley controllers make up a large percentage of the market share in North America and for this reason we will base our discussion on this platform.
You will often hear of modern programmable logic controllers, including the ControlLogix platform, being referred to as Programmable Automation Controllers or PACs due to their enhanced capabilities. For the purpose of this introductory discussion of PLCs we’ll assume that the concept of a PLC and PAC can be used interchangeably – with a couple of exceptions discussed below.
It also should be noted that this article is not intended to teach you how to program any specific programmable logic controller in any specific language. If you’re interested in getting started into the programming end of things, then it is recommended that you check out some of other other resources here on the site.
Below is a short-list of some of those resources:
The Power Supply and Chassis
One of the primary advantages of a programmable logic controller is its modular construction. This allows the designer to apply any combination of I/O (Input/Output) to solve a given problem. This makes PLCs extremely flexible for virtually any industrial application.
The most fundamental components of a PLC are the power supply and chassis that house the various CPU, I/O and Communication modules.
The power supply typically will accept a single phase 120/240Vac input that will be rectified into various DC voltages to furnish power to the CPU and various I/O and communication modules. This rectified voltage is transferred across the back-plane of the chassis.
Therefore, careful selection of a suitably sized power supply is important to ensure it has the capacity to provide the necessary “bus power” to supply all Input and Output modules (I/O modules).
As you can see from the image above, this is a 10-slot chassis, and each slot is capable of housing CPU and any combination of I/O modules that may be required. Input and Output modules are addressed based on their slot location in the chassis. Also note that the slot identifiers start at Slot 0 and not Slot 1.
Typically, in traditional programmable logic controllers, Slot 0 is reserved for the Processor or CPU. In modern PACs this is no longer the case, however, it is still common practice to place the CPU here.
The Central Processing Unit (CPU)
You can think of the Central Processing Unit as the main brain of a programmable logic controller. The CPU is constructed using one or more microprocessors and furnishes all the memory for the control system.
While the complexities of the CPU itself is outside the scope of this article, sufficient to say, modern programmable logic controllers can come in single core, dual core and even quad core architectures. Additionally, modern PLCs can come in a standard controller variety or a safety controller variety.
Below is an example of a standard controller CPU. In this illustration the CPU can only be programmed to handle standard I/O information and is not rated to perform any safety critical tasks directly.
However, a safety controller will allow your to program systems that are required to perform safety critical tasks, such as, protecting human life from injury. These types of controllers have special safety tasks and routines that guarantee repeatable scan times and I/O transfer rates.
CPU Controller Memory
Getting back to programmable logic controller memory, let’s examine the two broad types:
- Volatile Memory
- Non-volatile Memory
In modern programmable logic controller’s volatile memory makes it possible to enter or change user programs and store it in memory. This is commonly referred to as RAM (Random Access Memory). User programs can be modified and/or changed by way of a programming terminal or personal computer.
Due to this memory being volatile it means that it must have uninterrupted power supplied to its integrated circuits, otherwise, the information will be lost.
Programmable logic controllers would be of little use if the user program controlling a piece of automation equipment had to be re-downloaded every time there was a power disruption. Power disruptions happen frequently in industry for various reasons. Here are some of the reasons a power loss could occur:
- The system is powered down to perform routine maintenance.
- There is a disruption from the utility supplying the plant.
- A blown fuse or circuit breaker causes a loss of power.
This is not an exhaustive list, however, to work around this issue, modern PLCs make use of lithium batteries or capacitors to ensure that if the primary power to the power supply is lost the integrated circuits that comprise the RAM will still have power for some finite amount of time until power is restored.
Non-volatile memory is an option for some programmable logic controllers. Typically this is going to come by way of a compact flash card (in more modern controllers) or a ROM (Read Only Memory) chip. These types of devices can permanently store data without the need for power.
The disadvantage of ROM is that the data is physically encoded in the integrated circuit and therefore there is no option for writing to it if the control program needs to change. In this scenario a new chip will need to be “burnt-in”. This is where flash memory offers a big advantage.
The major advantage of non-volatile memory is that is the user program is automatically loaded on startup. Typically this is a version of the user logic that is known to work as expected and is well tried.
This means that if a program is inadvertently changed, or there is an error detected in the volatile (running) memory, it can automatically be restored to its original state simply by cycling the power to the controller.
CPU Controller Modes
Modern programmable logic controllers typically have two primary modes of operation, Program Mode, and some variation of Run Mode that is selected by a combination of the controller’s keyswitch or via the software used to program it. Below is a table of the different modes and a description of their operation.
How the CPU Scan Works in Traditional PLCs
The scan cycle of a traditional programmable logic controller can be described in 4 distinct steps.
- Read the status of the inputs. The CPU performs a check on all the inputs to see if their current state is either ON or OFF. This needs to be done in real-time as the inputs in a running process are subject to change at any given moment. Therefore, this read time needs to be milliseconds at most.
- Execute the user program. In this phase of the scan the CPU interprets the use logic to evaluate the state the outputs should be in (ON or OFF). While this evaluation is happening the results are stored in a reserved location in memory.
- Write to the outputs. The CPU then updates the outputs base on the decisions stored in step 2. During this phase electrical voltage and current is sent to the corresponding output terminals connected to the external output devices.
- Diagnostics and System Housekeeping. During this phase of the scanning process the CPU systematically check the hardware for correct operation by performing diagnostic analysis.
How the CPU Scan Works in Modern PACs
The scan cycle of a modern programmable automation controller (PAC) is very different in contrast to the traditional PLC scan. A ControlLogix CPU has two separate non-synchronized processes that are running simultaneously – this is commonly referred to as asynchronous scan.
One process is dedicated to handling the I/O updating asynchronously from the communication scan process. This provides for greater efficiency, speed and control over the I/O. The programmer can then specify when the input and output data can be transferred by specifying a parameter known as the Request Packet Interval time or RPI for short. An RPI time is configured for each I/O module added to the chassis.
Since programmable automation controllers can have multiple tasks scheduled to run on the CPU (i.e., Continuous, Periodic and Event Tasks) the scan is much more complex. Each task can have one or more programs, and for each program have one or more sub-routines.
As a result, a programmable automation controller does not have a status file like a traditional PLC, nor does it have a single watchdog timer as does a traditional PLC.
For more information on how programmable automation controllers allocate CPU resources during a scan, I encourage you to check out our article on system overhead time slices. I should mention, this article is for more advanced readers.
Programmable Logic Controller Input Modules
Input modules serve as the primary interface between the actual control devices and the CPU. Real-world inputs can come in various forms and voltages. Input modules come in discrete (On/Off) or Analog (-10 to10 Vdc or 0 to 20 mA) varieties.
There are many variables or inputs that we desire to capture in a given control system. Here are some examples:
Digital Input Modules
To connect the input field devices to the module, a wiring arm is provided with a set of screw or clamp connection points. This is the primary mechanism for interfacing your real-world inputs to the CPU.
Input modules are designed to accept different field voltages, typically, 120 Vac or 24 Vdc for discrete digital input modules. Input modules are protected from potentially harmful voltages and currents through opto-isolation.
Analog Input Modules
When continuous signal measurement is needed, Analog Input Modules will convert a -10 to 10 Vdc (voltage sensing) or 0 to 20 mA (current sensing) signal to it’s digital counterpart so it can be interpreted by the CPU. An example analog input module is show below.
It is the input module’s job to convert these voltage into a low voltage DC signal that the CPU can handle and interpret (typically 0 to 5 Vdc).
The CPU is extremely sensitive to high voltages, therefore it is very important that it is not exposed to any voltages outside of this 0 to 5 Vdc range. The signal is then transmitted across the back-plane of the chassis so it can be interpreted by the controller.
Programmable Logic Controller Output Modules
Output modules serve as the primary interface between the CPU and the real-world outputs or Final Control Elements (FCEs). Similar to their input module counterparts, output modules come in both discrete and analog versions.
Let’s identify some example real-world outputs or Final Control Elements:
- Control Relays
To connect the output field devices to the module, a wiring arm is provided with a set of screw or clamp connection points just like on the input modules. These connection points serve as the primary mechanism for connecting the CPU to the real-world outputs of the control system.
It is the output module’s job to convert the low voltage signal coming from the CPU to a higher voltage usable by the external output field device. Again, this is typically 24 Vdc or 120 Vac depending on the control system and is opto-isolated to protect the module from harmful voltages and currents.
Digital Output Modules
Discrete output modules are either transistor based (often TRIACs) or relay contacts. For transistor based outputs, power is delivered from the output module itself to the external output control device. This power is then delivered by the power supply, via the backplane, to the output point that is ON.
An external relay is often used in conjunction with transistor based output modules because the current (load) requirements of the external output device is often too large for the output module to handle directly.
For relay type output modules, the CPU switches ON or OFF a mechanical relay soldered to the printed circuit board of the output module. The field power of the external output device is then switched through the relay contact of the energized output.
The wiring diagram below illustrates an example of how to wire a relay output module. On the left-side of the wiring arm is where the field (external) power is connected. Notice on this module there are two groups (Group 0 and 1), meaning, two different voltage sources can be used to supply the output devices connected on the right side of the wiring arm (if needed).
So as an example, Group 0 can be supplied with 24 Vdc to power outputs 0 thru 3 (OUT-0 thru OUT-3) and Group 1 can be supplied with 120 Vac to power outputs 4 thru 7 (OUT-4 thru OUT-7). When an output turns on, the relay contact closes and switches the power from the left side to the right side.
Analog Output Modules
Analog output modules are used when continuous control of the external output device is needed. An example would be a servo motor, or a positional valve that needs to operate in some range between fully open and fully closed in order to regulate a process.
Analog output modules will output either a -10 to 10 Vdc signal or a 0 to 20 mA signal depending on the requirements of the external output field device.
Communication Modules and Industrial Protocols
It is common for programmable logic controllers to communicate via a communication bridge, or communication module, to other controllers, networks, human machine interfaces (HMI), distributed I/O, and a whole host of other devices over a network.
Before we get into the different communication modules and protocols, let’s examine some common network terminology you’re likely to encounter when discussing network communications.
- Network – a network is a grouping or collection of devices that share a similar data link or addressing assignment. Depending on the protocol used, each network has its own connection types and cabling.
- Node or Station – this is used to describe a physical device on a network.
- Node Address – a node address is a generic term for the address of a physical device on a network.
- Baud Rate – the baud rate describes the speed at which data can be transferred. Typically expressed in bits per second (bps).
Just like the I/O modules described above, communication modules also come in the form a module that will occupy a slot in the chassis. However, the modules themselves typically accept a single connection point or cable depending on the protocol used.
For example, an Ethernet/IP module uses a standard RJ45 type connector with Cat5e or Cat6a cabling. ControlNet uses an RG6 coaxial cable with BNC type connectors. I encourage you to check out our article on Ethernet Network Cabling after you’re done here.
The illustration above shows some of the most commonly used Network Protocols and module types used in Industry today. This is by know means exhaustive as there are many adaptations and variations on these communication types, such as, Modbus TCP, Profinet, and others depending on the manufacturer.
Let’s perform a high-level overview of these different network protocols so you have an idea of what they are and how they work.
Ethernet/IP has taken the industrial automation world by storm and is now the most commonly used protocol due to high throughput and ease of installation.
It’s important to draw a distinction from standard Ethernet IP and industrial Ethernet/IP. The IP in the traditional sense stands for Internet Protocol and the /IP in Ethernet/IP stand for Industrial Protocol. While Ethernet/IP is built to leverage traditional TCP protocols, it does so at the Application Layer.
Here are five things you should know about Industrial Ethernet/IP:
- Ethernet/IP is an Application Layer open protocol that supports real-time I/O control and communications.
- The data transfer rate of Ethernet/IP supports up to a 100-million bits per second (100Mbps) full duplex.
- Ethernet/IP data is organized in a collection of Objects (or a collection of common data), some of which are required and some are application specific. Examples of required objects are:
- Collection Object
- Router Object
- TCP Object
- Ethernet/IP Object
- Identity Object
- The object structure is contained in something known as the Common Industrial Protocol or CIP, which is managed by the ODVA (Open DeviceNet Vendor Association).
- CIP defines the two types of messages used in Ethernet/IP communication:
- Explicit Messaging
- Implicit Messaging
Here is some additional information on Ethernet/IP.
Before the explosion of Ethernet/IP, ControlNet was a widely used protocol due to it’s reliability, speed and robustness. It was used extensively for real-time, deterministic, data transfer of time-critical and non-time critical data.
Some important aspects of ControlNet are as follows:
- It will accommodate up to 99 nodes on a network.
- It has a maximum fixed baud rate of 5 million bit per second (Mbps).
- Is deterministic, meaning, it will meet or exceed configured data transmission rates, loss and latency.
Here is some additional information on ControlNet.
DeviceNet was developed to be a low-cost method to connecting various field devices such as drives, sensors, scanners, HMIs to a network. The DeviceNet standard is based on the CAN chip, which is an intelligent communication chip with powerful diagnostic capabilities.
Let’s review the basic DeviceNet specification below:
- Uses a single cable with four conductors – two power conductors and two signal conductors
- Can accommodate a maximum of 64 nodes on a network, decimal addresses 0 to 63.
- Supports baud rates of 125 Kbps, 250 Kbps, or 500 Kbps depending on length of network cable runs.
- 125 Kbps @ maximum cumulative network cable run of 512 feet.
- 250 Kbps @ maximum cumulative network cable run of 256 feet.
- 500 Kbps @ maximum cumulative network cable run of 128 feet.
Arguably, the most important device on a DeviceNet network is the scanner module. The scanner is the primary interface between the CPU and the devices on the DeviceNet network. The scanner reads inputs and writes to outputs in the scan list.
Here is some additional information on DeviceNet.
Data Highway Plus Communication
Data Highway Plus (DH+) is a proprietary protocol designed by Rockwell Automation. DH+ was developed in the late 1970’s and was used extensively throughout the 1980’s and 1990’s with their PLC-5 and SLC-500 (5/04) family of controllers.
A DH+ network can support a maximum of 64 nodes, decimal 0 to 63. Devices on a DH+ network are connected by a 3-wire “blue hose” by daisy chaining the devices together. Below is an example of a ControlLogix 1756-DHRIO module connecting remote racks via a blue hose.
Notice the end-of-line resistors required to terminate the network. Also important is to ensure the middle shield wire is connected to ground at only one end. This greatly attenuates noise that leads to data corruption and other network type errors.
Serial Communication (Legacy Communication)
In this section we’ll look at some of the older communication protocols and standards that were used extensively in industry through the 1980’s, 90’s, 2000’s, right up to today. While these communication types are slowly being replaced by those described above (Ethernet/IP, ControlNet, DeviceNet) there are still many devices in manufacturing facilities that still leverage these technologies.
Therefore, it is still important to look at them and know how they work. I don’t know how many times I’ve had to revert to my old RS-232 serial cable to get online with a controller. For this reason, I still always carry one in my bag.
Curious what else to keep in your bag? Check out our article essential tools every PLC programmer needs after you’re done here.
Serial communication implies that the transmission of data takes place in a linear fashion. Data messages are broken down into their single bit counterparts and transmitted one bit at a time
This makes serial communication somewhat slow in comparison to the other communication methods described above. For example, RS-232 communication described below has a baud of only 9600 kbps half-duplex.
RS-232 is arguably the most common serial communication mode. The RS in RS-232 stands for recommended standard. It was originally designed to use a 25-pin plug, but variations on the connector and pins used was permitted. A 9-pin D-Sub connector is a very common connector type for RS-232 communication.
The major drawback to RS-232 communication is that it only operates a maximum baud rate of 9600 at a maximum distance of 50 feet.
RS-422 and RS-423
RS-422 and RS-423 was developed to improve on the short-coming of RS-232 in both speed and distance. Because RS-232 used the same wire to transmit and receive data, it was prone to noise problems. RS-422 has separate wires for the transmit and receive lines making it more noise immune.
Due to this noise immunity, RS-422 can reach speeds of 10 Mbps for distances greater than 4000 feet. A significant improvement over RS-232.
RS-485 is another derivation on RS-422 that leverages a multi-drop architecture. This means that it allows for multiple devices to be connected to the network. Not a big deal by today’s standards, however, for the time this was novel.
RS-485 also supported full-duplex communication. This means that it can both send and receive data at the same time. Something that is now expected in modern industrial networks.
Modus is one of the oldest communication protocols. It was developed in 1978 and is still widely supported and used in instrumentation and process automation control. It is based on a serial master-slave configuration (RS-232/RS-485).
A Modbus Master will send messages to connected devices (slaves) on the network by passing data packets called frames that contain the following information:
- The device address field
- A function code field
- A data bytes field
- An error-check field
A Modbus Slave will respond by transmitting the requested data or by carrying out the requested operation. Here is some additional information on Modbus.
Programming a Programmable Logic Controller
I think at this point you have a solid overview of what a programmable logic controller is from a hardware and functional standpoint. The only thing left to do now is to actually program it.
While the complexities of how to go about programming a given PLC is outside the scope of this article, let’s take a look at three common formats to do this. See here, for a more comprehensive article on the different PLC programming languages.
Ladder Logic Programming (Graphical)
Ladder logic programming involves using ladder diagrams to build boolean logic expressions. It is referred to as Ladder Logic because it resembles the rungs on a ladder. Boolean expressions are built using these rungs.
Ladder Logic programming is by far the most common and simplest way to program a PLC. In addition to rungs it uses Normally Open (N.O.)/Normally Closed (N.C.) and Coil type symbols derived from relay control schematics to monitor the ON or OFF state of input and output devices.
Outputs are represented by coils that will either be ON or OFF depending on the state of the inputs and the corresponding boolean logic.
The illustration below shows three sensor inputs represented by eXamine If Closed (XIC) instructions and two OuTput Enable (OTE) instructions. One of the outputs (Output_1) could represent a Pump Running Light and the other output (Pump_2) likely energizes the coil of a contactor controlling a pump motor.
The outputs above will turn ON when all three inputs are in their ON or TRUE state. Having the inputs on the same line in this manner, indicates a logical AND condition. Meaning, Sensor_7 AND Sensor_2 AND Level_Sensor must be on for the output rung to be TRUE.
Function Block Programming (Graphical)
Function block programming is another graphical style of programming that leverages instruction blocks that can accept multiple inputs to control an output or outputs. It is a very common programming technique in the process automation world where data flow is important.
The different line types (solid or dashed) represent different data being transmitted between blocks. A solid line represents a Real type, meaning a type that can represent any real number. The dashed line indicates that the connection is representing Binary or Boolean data. In other words, a bit that is either ON or OFF.
Typically, function block routines are organized on Sheets that represent separate pages in a routine. When the function routine executes, all sheets in the routine execute. Often times one sheet is used per device to keep things organized and easy to follow.
Structured Text Programming (Textual)
Structured Text (ST) programming looks more like traditional text-based programming languages such as C and C++. It makes use of variables, assignment statements, conditional expressions such as If/Else statements, and relational operators such as greater than (>), less than (<) and equal to (=).
Below is a simple IF statement code block written in structured text on a ControlLogix controller. See if you can interpret what it’s doing?
Structured text is very powerful and easy to follow. It is a preferred way to program those tasks that ladder or function block don’t lend themselves easily to. For example, iterating over a large data-set or array. It can be done in ladder, however, it is much more easily handled in structured text programming.
Like I said at the beginning of this section, this is by no means an exhaustive list of ways to program a programmable logic controller.
Programmable Logic Controllers – Final Words…
Well I hope you found this article informative. Please feel free to bookmark and share it as one of your go-to resources for all things PLC and controls. The world of programmable logic controllers is a vast one and can take years to truly master.
While you’re hear, I do encourage you to become a PLCGuru yourself and register with the site. Registration is and will always remain completely free. Register Here!
Also, be sure to check out our YouTube Channel to see some great videos…and don’t forget to like and subscribe! If you enjoyed this article be sure to check out some of these good reads too:
- Top 10 Best Multimeters for Electricians
- Best 3D Printers Under $500: Ultimate Buyer’s Guide
- What is Industrial Automation? Industry 4.0?
- Best Oscilloscopes Under $500: Expert Reviews
- What is a Thermocouple? Cold Junction Compensation?
- Best Desktops for Programming (PLC, CAD, OOP)
- How To Become A PLC Programmer
- Best Laptops For PLC Programming