Meeting real-time requirements within the PLC family

1. Introduction.

Control systems using PLC controllers have been used in industry for many years. The main limitations here are too low computational capabilities of the controller and too low speed of the controller’s central unit to control processes requiring real-time operation. Therefore, from the point of view of working in real-time systems, it is important to develop time-optimal software, i.e. one that is characterized by the maximum reduction of cycle time without loss of functional properties. The length of this time, for both types of controllers, is mainly determined by the complexity of the user program and the speed of handling peripheral devices. When creating a program that meets real-time requirements, you should pay attention to the number and type of instructions used. The work presents procedures for testing the fulfillment of real-time tasks during the implementation of typical control tasks. The experimentally determined cycle times were compared with estimates made on the basis of information provided by the manufacturer of the tested controllers. The SU 1.2 controller and the SU 1.5 controller are equipped with RISC processors. Thanks to the possibility of writing programs in assembly language, it is possible to precisely determine the controller’s response time.

2. Basic issues related to real time in PLC systems.

Cycle time and response time are basic concepts that should be defined before analyzing issues related to meeting the real-time requirements of PLC controllers. Cycle time Tc is the time that elapses during one program cycle (Fig. 1).

Its length is influenced by:

  • system settings and checking the I/O bus, memory, CPU self-test, etc. (constant time for a given controller type);
  • input and output data handling (constant for a given controller type);
  • execution time of the user program (variable value);
  • peripheral device support.

Stages of the controller cycle

Minimum response time Tomin

Response time This is the time between a change in the input state and a change in the output state. Its length depends on the cycle time and input and output delays. Due to the fact that the input signal can be read at the beginning or end of the cycle, it is justified to introduce the concepts of minimum Tomin and maximum Tomax of the response time. The minimum response time (Fig. 2) occurs when the change in the input signal occurs sufficiently early before the inputs and outputs are operated, and if the time between the occurrence of the input signal and the operation of the inputs and outputs is smaller than the delay time (switching on) of the input signal, then The input signal will be cleared only at the beginning of the next cycle, which will extend the response time by one cycle. In this case, the response time will be maximum (Fig. 3).

Maximum response time Tomax

3. Theoretical estimation of cycle time and response.

Cycle and response time estimation can be performed based on data provided by the manufacturer of a specific type of controller. This will, of course, be an estimate for the least favorable situation, i.e. the actual measurements of specific times should be shorter than the calculated value. The response time To varies between the minimum value Tomin and the maximum value Tomax, i.e.:

  • Tomin<To<Tomax
  • Tomin=Tr+Tos+Tu+Tw+Tdi+Tdo+Tt
  • Tomin=2Tr+2Tos+2Tu+2Tw+Tdi+Tdo+Tt+Tdp


  • Tr, Tw – reading and writing time of inputs and outputs, respectively;
  • Here – execution time of the user program;
  • Tos – execution time of the controller operating system;
  • Tdi, Tdo – delay time related to reading/writing inputs/outputs;
  • Tt – execution time of the timers used in the program;
  • Tdp – network communication time.

The cycle time is also not a constant value, but depends, for example, on the number and type of interrupts and the system communication speed. When estimating its value, it should be taken into account


The proposed formulas do not take into account the time spent on diagnostics, as it is negligible in comparison to the remaining times.

4. Procedures for testing the fulfillment of real-time requirements during the implementation of typical control tasks.

The experimental tests were performed on SIEMENS SIMATIC S7-300 PLC controllers with the following central units: 312 IFM and 315. Test procedures were run on each of these units, implementing the following typical control tasks:

  • logical control (procedure P1);
  • continuous control using the PID algorithm (P2 procedure);
  • control in the field of robotics (the issue of simple kinematics)(procedure P3).

Logical control was implemented in a procedure operating a digital setpoint (thumbwheel switch). It allows you to enter a digit into the controller depending on the number of setter segments. To read the values from the setter, it was necessary to write a procedure with a „rolling one”, which allowed reading subsequent outputs.

A typical control system (closed system control) with a PID controller in the main control line was used to test continuous control algorithms.

A simple kinematics problem is a static-geometric task involving the calculation of the position and orientation of the manipulator’s working member. Given all the configuration coordinates, you need to calculate the position of a given point associated with the robot relative to the global coordinate system. From a control point of view, this is a problem that requires repeated use of time-consuming trigonometric functions

5. Results of experimental studies.

The tests carried out were aimed at estimating cycle times in individual control procedures based on data provided by the SIEMENS controller manufacturer, and then verifying them during actual control.

The formula for Tc was used to determine the estimates. After preliminary estimates, it turned out that the complexity (type and number of instructions used) of the control procedure has a decisive influence on the cycle time. The sum of times Tos (execution time of the controller operating system), Tr, Tw (time of reading and writing inputs and outputs, respectively), Tdi, Tdo (delay time associated with reading/writing inputs/outputs) and Tdp (time of communication with the network) in both used drivers was about 2ms. The execution times of individual instructions are so short that in order to make them readable, it was decided to measure the cycle time for performing a given procedure a thousand times in a loop.

Figures 4-6 present histograms of the occurrence of individual cycle times, with cycle times measured with an accuracy of 10 ms, while Table 1 contains estimates of the maximum cycle times for the analyzed procedures based on data on the execution times of individual instructions provided by the equipment manufacturer.

Estimation of maximum cycle times for procedures testing typical control tasks P1, P2, P3

Cycle times determined as a result of experimental tests turned out to be much shorter than theoretical estimates. The results are presented in Figures 4-6.

6. Conclusions.

The conducted research shows that the theoretical estimate of cycle time can be treated as the maximum possible cycle time. In practice, the actual cycle times are usually several or even a dozen times shorter. This is probably due to the fact that the manufacturer provides the longest possible time to perform a given operation. Based on the histograms provided, it can be observed that using the CPU 315 unit can significantly shorten cycle times (compared to the 312 IFM unit) in procedures based on logical control (Fig. 4). Cycle times in procedures implementing continuous control and simple kinematics tasks are similar, both in theoretical estimates and determined experimentally.

Scroll to Top