All About PLCs: The CPU
Learn all about the central processing unit (CPU): the built-in module inside the PLC responsible for executing the program and communicating with external devices.
Although all of the components inside a PLC are critical to its function, none is more important than the module responsible for executing the logical instructions that make up the "programmable" part of a PLC: the CPU.
The central processing unit acts much like the CPU inside any computer, but we don't often find specs that remotely match the performance in even a low-end modern laptop. The reason for this is that, while they both execute instructions that are core to the function of the computer, the difference in installation context calls for extremely different execution strategies.
What Does a PLC CPU Actually Do?
To perform the job of "running a process," a CPU must accomplish a few distinct tasks, all of which are closely related to all of the others:
- Communicate with the host programming machine and load the program
- Transmit I/O data across the backplane
- Read and update the input register
- Calculate the result of each line of code
- Update the output register
Loading and executing a program sets this CPU apart from a traditional computer in a very important way. For most laptops, we refer to the "operating system," like Windows, MacOS, or Linux, as the background system that loads and runs programs and provides the user interface. A PLC, on the other hand, does not install and run programs, nor does it provide a user interface in which you can connect with a mouse and keyboard.
Instead, a microprocessor like those found in a PLC is what is known as a "runtime" or a runtime environment, which means it only executes lines of machine code; it does not provide an environment in which you can design the code.
Figure 1. A CPU module (in the center) is designed to interface with a power supply, communication modules (left), and I/O modules (right). Image used courtesy of the author
For the task of code design, each manufacturer creates their own "integrated development environment," like Rockwell's Studio 5000, Siemens's TIA Portal, or Beckhoff's TwinCAT. Each of these IDEs would be installed on a laptop or desktop, the project is created, and then it is downloaded to the runtime environment on the PLC through either an Ethernet (or PROFINET, EtherCAT, etc.) or serial (usually USB) interface.
These days, there is an evolved version of the PLC that incorporates both the runtime and the OS onto the same device, side-by-side. Examples include Beckhoff's embedded PCs or the PLCnext from Phoenix Contact. These allow the familiar programming in typical IEC 61131 languages but allow the IDE and other OS-based apps to be installed on the PLC itself.
How Does the PLC Communicate with I/O Devices?
The backplane communication ensures that all I/O information is transmitted between the CPU and the I/O modules. It can also handle data transmission to communication modules for connection to remote I/O blocks.
Backplane connections in a chassis or rack-based PLC take the form of a multi-pin header that supplies functional power to the modules (not field device power, but that's another topic) and enough data Tx and Rx lines to rapidly scan many modules in a very short time. Depending on the manufacturer, these data lines may use a form of serial communication or a high-speed EtherCAT connection.
Some PLCs have a fixed number of built-in I/O (the smaller "brick" style PLCs), with some of these even allowing additional add-on modules, but these models still require the data connection between the CPU and the I/O points.
Figure 2. Some fixed I/O PLCs also include add-on module slots. Image used courtesy of the author
The CPU polls the input and output modules for current I/O status as rapidly as possible and places those values in dedicated address registers in the CPU's memory.
The lines of code, with each tag or variable referring to a location in the memory bank, are calculated one at a time while a temporary output register is formed. As soon as the last line is scanned, that output register is sent to each output module. Therefore, the output terminals do not update the instant a line changes from false to true - it only looks that way because the PLC scan cycle is very short.
The Most Important PLC CPU Specs
Unlike normal computers, no PLC manufacturer touts the GHz speed or the GB of RAM of their latest processor. Why is that?
For speed, the clock speed of a PLC is irrelevant. Instead, we are interested in the execution time of various instructions. Bits, integers, floats, functions–each of these calculations demands a certain amount of time dedicated from the processor. The datasheets give this information freely, allowing a programmer to estimate the amount of time it will take for a full scan between the reading of inputs and the implementation of outputs.
Figure 3. Some PLCs will have typical PLC features right alongside the performance specs for a Linux-based OS. Image used courtesy of the author
So we are interested in speed, but rather than clock speed in GHz, it's the cycle speed in μs or ms. Since each program is different, there is no way to provide a spec on each user's cycle time.
As for program storage, we do not need to be burdened with a 500 GB external solid-state drive. Unlike a computer which stores images, videos, and programs by the dozens, we are storing a few lines of text code, like a notepad file. Imagine the largest .txt file you have ever seen. A few MB, perhaps? Likewise, the emphasis is not on storage size but on bullet-proof reliability.
A common spec for program storage space is less than 1 GB; only the most massive industrial processes will even come close to this size. Some PLCs allow expansion memory or list an upfront cost for CPU models with larger flash memory, but spending the money to buy more than you need is pointless.
What's the Best CPU for my PLC?
Here are the main things you need to look for,
- A communication protocol compatible with your programming laptop. If you buy an older CPU with an RS-232 programming interface, be sure you have the cable and software to match it.
- Enough memory to hold your program. How much do you need? A quick chat with the manufacturer will likely clarify this question, but if you have a small process, anything below 100 MB is likely more than you will ever need.
- I/O capability. Each CPU is rated by the number of I/O points that can be connected to the system. Ensure you have enough.
- Low rough cycle time for system reliability. Again, chat with the manufacturer to get an idea of how many I/O points and how many instructions you are likely to need in order to ensure a low delay between input data and output commands.
Figure 4. Be sure to choose wisely: Even the most powerful CPU is useless if you cannot connect with the proper port and protocol. Image used courtesy of the author
With this information, you should be equipped to tackle your next PLC install or upgrade to be sure you are ready for the future but aren't wasting company money. It's a delicate balance, but plenty of resources are available to help make the best decision.