How the PLC executes PLC code ?

It is important to know how the PLC executes the program code when writing the program. A PLC executes the program in real-time, which means that the program modules must be executed within a short time-frame. The program modules are executed at a fixed time interval (the PLC scan time) e.g. 50 [ms]. Some of the fastest PLCs may have a scan time of 1 [μs].
Program modules can have different scan times e.g. 500 [ms] or 1000 [ms]. Some sensor input values do not change quickly (e.g. a temperature sensor). Which means that it is not necessary to have fast scan time for all program modules. A large program with many calculations takes a longer time to execute. This means that different programs will require different lengths of scan time.
The basic mode of operation for a PLC:
The basic mode of operation for a PLC

The flow diagram shows the following points:

1.When power is turned on the PLC will start (boot up) and load the operating system, called firmware in a PLC system. This will ensure that the PLC program knows the connected hardware (HW).
2.After startup, all output modules are set to its initialization values. It is important that all outputs have the correct startup values so there are no unintended actions before the PLC program has started.
3.A data communication link has now been created via a network (fieldbus). Variables are received and sent out to other units (e.g. control panels, other control systems or instruments). There are many types of fieldbus network systems. Some of the most used include Profibus, Profinet and Ethernet/IP. However, most fieldbuses are built with similar functionality, and they all work in similar ways.
4.Values from all sensors, switches, instruments and components on the machine or plant are now received from the connected input modules.
5.Dependent on the scan time all PLC programs will be executed once.
Programs must be split up in order to create a good program structure.
6.Values are written to all output modules. Values could include new settings to motors/engines, valves, lamps and instruments.
7.Step 3 to 6 will be repeated. This is one program scan.
The execution of the program only stops if:
The PLC is set to STOP operation mode
If a run time error in the program occurs
The PLC is powered off or loses power unintentionally

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top