MU-Directed Graphs For PLC Programming-Sydney2022

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Proceedings of the First Australian International Conference on Industrial Engineering and Operations

Management, Sydney, Australia, December 20-21, 2022

Dependency Graphs for PLC Programming


Muhammad Usama
Senior Lecturer
Electrical Engineering Department
Gift University
Gujranwala, Pakistan
m.usama@gift.edu.pk

Asnan Farooq
Robotics and Industrial Automation Engineer
Abdullah Engineering Services (AES)
Gujranwala, Pakistan
asnanfarooq24@gmail.com

Ubid Ullah
Electrical Engineer
Gift University
Gujranwala, Pakistan
17139029@gift.edu.pk

Abstract
Programmable Logic Controllers (PLCs) form the backbone of industrial automation and control. In this paper, we
propose to add a dependency graphs feature in PLC programming environments, and we discuss some key
advantages it would have for PLC programming and debugging. Examples are provided for dependency graphs
constructed for Fatek PLC programs using WinProladder and MATLAB.

Keywords
PLC Programming, PLC Debugging, Industrial Automation, WinProladder, and Ladder Language.

1. Introduction
Since their inception in 1969, PLCs have transformed industrial process control, (Segovia et al. 2012). Today
industrial automation is ubiquitous with PLCs. IEC61131-3 standard outlines five possible programming languages
for PLC programming, namely Ladder Logic (LD), Sequential Function Charts (SFC), Function Block Diagrams
(FBD), Structured Text (ST), and Instruction Lists (IL). PLC manufacturers around the globe use one or more of
these programming languages for their PLCs. For example, Fatek PLC programming software WinProladder allows
programming in Ladder logic and Structured Text. Each PLC programming software has built-in debugging tools to
facilitate debugging while programming. Many debugging techniques for PLCs have been proposed over the years.
Here we propose a debugging tool based on directed graphs.
A graph is a mathematical representation of a set of vertices or nodes connected with a set of edges. A directed
graph is a graph where each edge has a specified direction. An example directed graph is shown in figure 1. A
directed graph can be called a dependency graph the arrows in the graph represent the dependency of a specific node
on another.
Here we present a PLC program debugging approach based on dependency graphs. We also discuss particular
examples where this approach might be useful. Additional features are also suggested to improve the efficacy of
these graphs.

© IEOM Society International


Proceedings of the First Australian International Conference on Industrial Engineering and Operations
Management, Sydney, Australia, December 20-21, 2022

Figure 1. Example of a directed graph

2. Literature Review
Automation Companies and researchers have developed many debugging and troubleshooting techniques for PLC
programs. These techniques have been utilized by PLC companies to aid programmers and troubleshooters alike.
Many PLC debugging techniques have been developed over the years. Berger et al. developed a deterministic replay
debugging for PLC programs in 2012. Similarly more PLC debugging tools were developed and existing debugging
tools were tested by Berger et al. in 2012 and Wu et al. in 2015. More recently Kamel et al. reviewed different
troubleshooting techniques for Allen Bradley SLC 500 PLC in 2019. In the same year Baniyounis et al. used
program slicing and algorithmic debugging for PLC programs.
Directed graphs where applied in computer programming by Karp in 1960. Furthermore directed graphs for
computer programs have been used to gauge the complexity and entanglement in a computer program (Berwanger et
al. 2005), to study design patterns in Parallel programming (Siu et al. 1996).

3. Methods
This section outlines the proposed method to create a dependency graph for a PLC program. We would use
Winproladder to demonstrate our method, but the technique is generic and can be adapted for any PLC program.

3.1 Objectives
The PLC memory is divided into a fixed number of Boolean memory (known as bits or auxiliary relays) and a fixed
number of 16-bit or 32-bit memory (known as registers). Every part of the PLC program can be considered as
changing or setting one part of the memory based on certain manipulations made on different (or the same) parts of
the memory. This is true for all formats of PLC programming. Each instruction in a PLC program can then be
translated into a directed graph showing the instruction's dependencies. For example, a Ladder Diagram given in
figure 2 would translate into a directed graph given in figure 3.

© IEOM Society International


Proceedings of the First Australian International Conference on Industrial Engineering and Operations
Management, Sydney, Australia, December 20-21, 2022

Figure 2: Example 1 Ladder Diagram for Basic Logic

Figure 3: Example 1 Directed Graph for PLC program in Figure 2.

4. Results and Discussion


Making a dependency graph for a PLC program can have the following advantages.

4.1 Identification of Distinct Code Blocks


Most PLCs are used to control multiple processes or multiple distinct parts of a single process. For example, a PLC-
based injection molding machine control would, on the one hand, be controlling the temperature of the barrel while
also controlling charging and injection processes (amongst other things). The heating process control would be
independent of the rest of the control. Making a directed graph for the whole program can
● identify the memory used in each of the independent program blocks,
● identify the memory used between the program block, and
● help in debugging when unintended dependencies are spotted.

© IEOM Society International


Proceedings of the First Australian International Conference on Industrial Engineering and Operations
Management, Sydney, Australia, December 20-21, 2022

4.2 Trouble Shooting and Programming


The majority of the automated machinery in Pakistan is secondhand, with very little or no support provided by the
manufacturer. In such scenarios, troubleshooting or reprogramming the PLC is especially challenging due to a lack
of support. Having a directed chart of all the used memory of the PLC can identify trends that would be difficult to
identify in the traditional LD or FBD environment. If the inputs and outputs of the PLC are segregated, then directed
graphs can be used to identify the internal memory associated with each of the Inputs and Outputs.

4.3 Debugging
Dependency graphs can also be useful in debugging a PLC program. Any unintended dependencies can be easily
identified and rectified.

5. Additional Features
The following features can be added to dependency graphs to improve functionality.
1. A tag can be added to each edge of the graph, indicating the type of dependence between the two
memories. Similarly, the comments given to any memory unit can also be displayed next to the node for
that memory unit.
2. A feature can be added to re-arrange the graph in different formats. For example, the dependency graph can
be arranged in a manner where all the inputs are placed in line on the top, all the outputs are placed at the
bottom, and all the other memory is placed in the middle. Such arrangements would make it easier for the
user to spot patterns in the graph.
3. Sometimes, more than one register is used as a single memory. For example, one floating point number in
Fatek PLC uses 32-bit memory while each register is only 16-bit. So if the dependency is between a set of
two registers, our directed graph should also represent the set of registers as a single node.
An example of features 1 and 3 is shown in figure 4 and figure 5. Since the adder block in N0002 is implemented for
32-bit memory, we know that R4-R5 are dependent on R0-R1 and R2-R3. The labels in black are the tags attributed
to the edges, while those in red are the comments for each node.

Figure 4: Ladder diagram with comments and double memory

© IEOM Society International


Proceedings of the First Australian International Conference on Industrial Engineering and Operations
Management, Sydney, Australia, December 20-21, 2022

Figure 5: Dependency graph for PLC program in figure 4.

References
Abdelhameed, Magdy M., and Houshang Darabi., Diagnosis and debugging of programmable logic controller
control programs by neural networks, IEEE International Conference on Automation Science and Engineering,
pp. 313-318, 2005.
Baniyounis, Mohammed, and AlMutazbellah Mesmar, Combining Program Slicing and Algorithmic Debugging
to Diagnose a PLC program, IEEE International Multi-Conference on Systems, Signals & Devices (SSD), vol.
16, pp. 246-249, 2019.
Berger R, Prähofer H, Wirth C, Schatz R., A tool for trace visualization and offline debugging of PLC
applications., Proceedings of 2012 IEEE 17th International Conference on Emerging Technologies & Factory
Automation, (ETFA 2012) 2012 Sep 17, pp. 1-8, 2012.
Berwanger, Dietmar, and Erich Grädel, Entanglement–a measure for the complexity of directed graphs with
applications to logic and games, International Conference on Logic for Programming Artificial Intelligence and
Reasoning, Springer, Berlin, Heidelberg, pp. 209-223, 2005.
Kamel, Khaled, and Eman Kamel, Process control ladder logic troubleshooting techniques fundamentals, IRO
Journal on Sustainable Wireless Systems, vol. 1, no. 4, pp. 206-241, 2019.
Karp, Richard M., A note on the application of graph theory to digital computer programming, Information and
Control 3, no. 2, pp. 179-190, 1960.
Segovia, Vanessa Romero, and Alfred Theorin, History of Control History of PLC and DCS, University of Lund
2012.
Siu, Stephen, Mauricio De Simone, Dhrubajyoti Goswami, and Ajit Singh. "Design Patterns for Parallel
Programming." PDPTA, vol. 96, pp. 230-240, 1996.
Wu, T. and Nurse, J.R., Exploring the use of PLC debugging tools for digital forensic investigations on SCADA
systems, Journal of Digital Forensics, Security and Law, vol. 10, no.4, pp.7, 2015.

© IEOM Society International


Proceedings of the First Australian International Conference on Industrial Engineering and Operations
Management, Sydney, Australia, December 20-21, 2022

Biography
Muhammad Usama is currently a Professor of Practive at the Department of Electrical Engineering, School of
Engineering and Applied Sciences, GIFT University, Gujranwala, Pakistan. He is also the C.E.O of Abdullah
Engineering Services which is a private firm working in industrial automation and control. He is also the co-founder
of Curiosity Club which a startup aimed at inclusion of STEM education in primary and secondary schools in
Gujranwala. He received his Masters in Physics from the University of Southern California where he worked in
quantum computing using open systems. He received a B.Sc. in electrical engineering from Lahore University of
Management Sciences, Lahore, Pakistan. His research interests include industrial automation, STEM education for
primary and secondary schools, induction and BLDC motor design and testing.

Asnan Farooq is a industrial automation expert with a 4 year experience in this field. He earned B.S. in
mechatronics engineering from University of Engineering and Technology, Lahore, Pakistan. He has done
automation projects related to industrial boilers, CNC machines, special purpose machines, plant automation,
injection moulding machines, water supply monitoring system, testing lab for washing machines and room air
coolers.

Ubid Ullah is an electrical engineer who completed his B.S. Electrical Engineering in 2021. He worked on the
development of autonomous lawn mower during his final year project. His interests include industrial automation
and embedded systems.

© IEOM Society International

You might also like