PLC working method
As is well known, the working principle of a PLC is as follows:
Loop scanning: This means scanning line by line from the beginning to the end of the program, from left to right, and repeating continuously!
A single line of text seems simple and easy to understand, but in actual programming, many errors still occur because the fundamentals are not solid enough. So how exactly does the cyclic scanning of a PLC work? We can use a frequency divider circuit as an example to explain.
Frequency divider circuit
What is a frequency divider circuit? Here's a simple example:
A single button turns a light bulb on and off: pressing the button once turns the bulb on, and pressing it a second time turns the bulb off. This is a frequency divider circuit!
There are many ways to implement a frequency divider circuit. To better reflect the theme of this issue (the working mode of PLC), we will use basic logic instructions to write it, as shown in the figure below; where: button - X0, light - Y0.
PLC cyclic scanning process
A picture is worth a thousand words:
Don't worry if you don't understand, there are step-by-step instructions below.
The following four diagrams illustrate the process from the first press of the button to its release.
—The lights are on.
Figure 1. Program state before button is pressed.
Figure 2. The first scan cycle of the PLC when the button is pressed.
Figure 3. With the button pressed all the way down (and not yet released), the PLC begins the second scan cycle (assuming it's the second one, the scan cycle is very fast).
Figure 4. Program state after releasing the button.
The following four diagrams illustrate the process of pressing and releasing the button a second time.
—The lights went out.
Figure 1. Program state before the button is pressed a second time.
Figure 2. The first scan cycle of the PLC when the button is pressed a second time.
Figure 3. When the button is pressed all the way down for the second time (without being released), the PLC begins the second scan cycle.
Figure 4. Program state after releasing the button.