How a PLC works

Which programs are running within a PLC?

Within a PLC, more exactly the CPU, two different programs are running simultaneously:

- The operating system
- The user program

The operating system is a part of each CPU and organizes all functions and processes of the CPU that are not associated with a specific control task. Its responsibilities include:
- Unwinding of cold and warm restart
- Updating of the process image of the inputs and the output
- The call of the user program
- The detection of alarms and alarm calls of Ob´s
- How to handle errors
- Managing memory
- The communication of programming devices and other communication partners

The user program - it is your program what you write and load into the CPU. It is a specific application program.

 

How the instructions of a user program are processed by the CPU?

How are the instructions of a user program processed by the CPU? To illustrate the operation of a PLC, please write the following program. With the botton I0.0 "On"  the output is switched on, with the bottom "Off" switched off. You may write the set command first or at the end of the program, i.e. in network 1 or network 2. But how does the output behave when both inputs are active at the same time?

How a PLC works

fig.: How a PLC works

We recognize that obviously the last command is executed, i.e. dominates. The explanation lies in the way the PLC works:

How a PLC works

fig.: How a PLC works

First the signal states of the inputs are read. Then these input signals are processed, i.e. the logical links are created. The instructions of the program are processed one after the other, i.e. serially.
Once the program has been processed, the outputs are activated, i.e. a Bit pattern is sent in parallel to the output modul of the PLC.
Of course, this process must be carried out repeatedly, i.e. a new cylcles begins.

Cycle time - Reaction time of a PLC

Cycle time - Reaction time of a PLC

In this context, two terms describe the speed of the PLC:

The cycle time is the time required by the PLC for a single execution of the program. The cycle time is composed of the processing time of an instruction and the number of instructions

The reaction time of a PLC is generally many times greater than the cycle time. It is composed of delay time of the input and output modules and the cycle time.

Note: The cycle time is an essential feature of a PLC and usually refers to 1 k = 1024 program instructions. Example: Our PLC has the average processing time of 200 ns for one instruction. Which value has the cycle time?