Introduction to PLC Basics: Understanding the Working Principles of PLC Hardware

Introduction to PLC Basics: Understanding the Working Principles of PLC Hardware

Another newcomer is asking what a PLC is, how annoying! It’s already 2023, and there are still people who don’t know what a PLC is? This thing is the brain of the factory, without it, all the machines in the factory would stop working. Alright, since you are so sincere, let me explain it to you.

First of all, the full name of this thing is Programmable Logic Controller, abbreviated as PLC. Remember, a PLC is not an ordinary computer, it is specifically designed to operate in harsh industrial environments. I have seen it in a steel plant in Northeast China, where it was minus 20 degrees and full of dust, yet the old Siemens S7-300 was still running smoothly, while a PC would have crashed long ago.

PLC Internal Structure

By the way, speaking of the internal structure of a PLC, I remember a project at a paper mill two years ago, where a Japanese guy insisted that their PLC was better than Siemens. I just laughed at that… but I digress.

The internal structure of a PLC is actually quite simple: CPU, memory, I/O interfaces, and communication modules, just these few components. The CPU is the brain that runs the programs you write. The memory is divided into program storage and data storage; the program storage holds the ladder diagrams or ST code you write, and it is non-volatile; the data storage holds the data generated during operation, some of which may be lost when power is off.

The I/O modules are the hands and eyes of the PLC, with input modules reading sensor signals and output modules controlling actuators. Newbies often trip up here, as they cannot distinguish between analog and digital signals. Digital signals are binary, either 0 or 1; analog signals are continuously variable, such as temperature and pressure.

The communication module is becoming increasingly important, especially with Industry 4.0 and the Internet of Things, which are all about enhancing this aspect. The most common protocols include RS485, Profibus, Profinet, EtherNet/IP, Modbus TCP, and many more… too many to mention. But let me tell you, 80% of communication issues are due to incorrect wiring or misconfigured parameters, and all that fancy communication protocol analysis is nonsense.

PLC Scan Cycle

Understanding the PLC scan cycle is key to determining whether you truly understand it or are just pretending. A PLC is not blind! It processes in a loop! Each scan cycle consists of several steps:

1. Read input status – Read external input signals into the I area2. Execute program – Execute the program line by line as you wrote it3. Diagnostics and communication – Check its own status and handle communication requests4. Update output – Write the results of the program execution to the Q area to drive external devices

A long scan cycle can lead to sluggish responses, back in 2018, I encountered a production line machine that frequently stopped unexpectedly. After a week of investigation, I found that the PLC’s scan cycle was too long, causing high-speed signals to be missed and discarded. In our industry, we often use terms like “stuck” or “running away” to describe PLC program issues.

By the way, did you know? The instability of the scan cycle in cheap domestic PLCs is much greater than that of Siemens. Once, I encountered a domestic PLC that claimed a 10ms scan cycle, but when measured, it fluctuated between 8-25ms! Can such a thing be used? Pure nonsense. Old AB and Siemens at least provide stability.

Here’s a simple piece of Siemens S7-1200 code:

// Basic framework for temperature PID control
"PID_Temp_1"(
    Setpoint := "Temperature Setpoint",     // Set temperature
    Input := "Actual Temperature",          // PV measured temperature
    Output => "Heater Output",       // Output to heater
    MODE := 3);                  // Automatic mode
// Once stable, do not adjust parameters randomly; a well-tuned PID should not be altered!

PLC’s Three Scan Modes

There are three scan modes for PLCs: cyclic scan mode, interrupt scan mode, and communication scan mode. Most of the time, cyclic mode is used, which is the default.

Interrupt scanning means that when a specific event occurs, the PLC immediately stops its current task to handle the interrupt event. For example, when a high-speed counter reaches a preset value or an emergency signal is triggered. Interrupts have high priority and are executed preemptively, but poorly written interrupt programs can easily crash the entire system.

Communication scanning is specifically used to handle communication requests, such as when a host computer needs to read data or remotely modify a program. Many people do not understand this part, but it significantly impacts communication efficiency.

Speaking of this, I remember last summer at a dyeing factory, where the temperature control system frequently fluctuated. After several days of investigation, I found that the PLC communication load was too high. The operator kept refreshing the screen, and the HMI bombarded the PLC with data requests, which occupied the normal scanning process, causing the temperature control to fail.

What’s the solution? Simple, put important variables into a separate data block and set high priority, then limit the HMI request frequency. The engineer was skeptical, so I demonstrated it on-site, and the problem was immediately resolved, leaving him dumbfounded.

PLC Selection Tips

In my opinion, for small projects, using Siemens S7-1200 or AB’s MicroLogix is sufficient, don’t waste money on obscure brands. How many of those who claim domestic PLCs have a high cost-performance ratio have actually used them in harsh environments for over three years? Don’t wait until the project is completed to discover various issues with the PLC; by then, it will be too late to cry.

When selecting a PLC, focus on these points:

1. Reliability – This is the top priority; you get what you pay for2. Instruction set – The richer, the better for operation3. Communication capability – Nowadays, this is essential4. Programming software – Poor software will make you question your life5. Technical support – Can you find someone when issues arise?

When you encounter a problem, first check the hardware, then the wiring, and only then suspect the program. I see many newbies blindly modify the program when they encounter issues, resulting in even more problems. Remember, 90% of PLC issues are hardware or wiring problems!

Alright, that’s enough for now. If you want to learn about PLCs, don’t just read books; get hands-on, make mistakes, and solve them yourself. There are no shortcuts in this field; you have to step on all the pits to become a master.

Introduction to PLC Basics: Understanding the Working Principles of PLC Hardware

Before you go, remember to click on Looking~

Leave a Comment