The Underlying Logic of PLC Scanning Cycles

Hello everyone, I am Awei from Mako Control. Some fans have asked me to talk about the scanning cycle of PLCs. The scanning cycle is not as simple as most people think, which involves writing outputs, reading inputs, and executing programs. Most people overlook the core logic hidden behind this, which often leads to writing programs with logical issues or not knowing how to troubleshoot when problems arise.

Today, I will discuss the underlying logic of the scanning cycle, hoping to help everyone, especially newcomers, to avoid detours and write good programs.

When talking about the scanning cycle, besides writing outputs, reading inputs, and executing programs, what is more important is the hidden concept of “timing“.

The PLC program scanning is essentially a continuous, cyclic execution of the PLC program, which is relatively easy to understand, while the underlying “timing” is much more complex.

Why do I say this? Because PLC programs can be somewhat counterintuitive. For example, in daily life, when we take food out of the refrigerator and put it in the microwave, we set it up and start the microwave, waiting until the food is heated before taking it out. Everything seems very natural, right?

However, in the world of PLCs, some things cannot be done; it cannot stop. For instance, after starting the microwave, it cannot just wait until the food is heated; it can only check after a while to see if the food is hot, and if it is, then take it out.

So you will find that writing PLC programs is also somewhat counterintuitive because it requires you to create a mechanism to control the execution of each step, and this is fundamentally about timing. If newcomers do not have a concept of timing, they can easily write a program with bugs.

The Underlying Logic of PLC Scanning Cycles

So what is timing? As the name suggests, it refers to the sequence of events over time, meaning that as the program progresses over time, what changes occur based on what inputs and in what order. This statement is something you should read several times and think deeply about. Only by understanding it and having a clear idea can you write a program that meets your intentions, or when your program has issues, you can quickly locate them.

Why do I say this? First, only by understanding timing can you correctly use many instructions, as many instructions have timing diagrams, such as the TONR instruction and the SEND instruction.

The Underlying Logic of PLC Scanning Cycles

The Underlying Logic of PLC Scanning Cycles

Secondly, only by deeply understanding timing can you know, for example, what the program will do sequentially when the user presses the start button, what actions the external devices will take, and which sensor signals will affect which parts of the program under what conditions.

As in this program, what will the timing look like when the button is pressed?

First round: The motor control latch normally closed contact is activated, and the motor control is set.

Second round: The motor control latch normally open contact is activated, and the motor control is reset.

Third round: The motor control latch normally closed contact is activated, and the motor control is set.

Fourth round: The motor control latch normally open contact is activated, and the motor control is reset.

This continues until the button is released.

So you will find that sometimes when the button is released, the motor is running, and sometimes when the button is released, the motor stops.

And solving this problem is quite simple; just change the previous button to a rising edge. This way, the timing after the button is pressed becomes deterministic and will not change.

The Underlying Logic of PLC Scanning Cycles

Therefore, while the scanning cycle seems simple in terms of writing outputs, reading inputs, and executing programs, the timing hidden behind it is not simple at all.

This concludes this session. If you found it helpful, please like and follow.

If you have any questions or want to submit an article, please let me know in the comments or via private message.

Leave a Comment