You are on page 1of 4

General Sequential Function Charts editor

Miroslav Kocánek Pavel Balda


Faculty of Applied Sciences, Department of Faculty of Applied Sciences, Department of
Cybernetics, University of West Bohemia Cybernetics, University of West Bohemia
Plzeň, Czech Republic Plzeň, Czech Republic
mkocanek@kky.zcu.cz pbalda@kky.zcu.cz

Abstract— Sequential function chart formalism is one of the 5 schemes and store them to XML files but also to check their
languages for PLC (programmable logic controller) syntax (validate them), compile them for the selected target
programming described in the IEC 61161-3 standard. Many and to visualize (monitor) the state development of the
PLC vendors integrate their own SFC editor implementation particular scheme in real-time. The editor is written in C#
as a part of their development environment. Absence of a using Microsoft .NET framework.
universal SFC editor lead to the authors own development.
This paper describes some of the features of the developed II. EDITOR ARCHITECTURE
universal SFC graphical editor, which includes: 1. editor
architecture; 2. graphical user interface; 3. SFC schema Almost overall logic of the SFC Editor can be divided to
validation and compilation to various targets; 4. editor the three basic categories. The first category contains classes
customization and integration to development tools of various related to the objects which are visible in the graphical user
control systems. REX uses the SFC editor in two ways: 1. a interface (GUI) and should be painted to the canvas. The
design tool for the ATMT, EATMT and REXLANG function second category contains classes responsible for handling a
blocks; 2. as an online visualization and debugging tool. chart validation and compilation processes. The last category
contains classes implementing a monitoring algorithm state
Keywords- Sequential Function Charts; SFC; IEC 61131-3; evolution of the particular chart. All these class categories
Grafcet; PLCopen; REX control system; object oriented are described in the next subsections in a more detail.
programming; OOP.
A. Graphics entites
I. INTRODUCTION Fig. 1 shows dependencies of the GUI classes. Every
shape drawn on the editor’s work canvas is inherited from
Sequential logic is usually a significant part of control the basic abstract class Shape. This class defines properties
algorithms. Even control algorithms of the regulatory type and functions common to all shapes, like shape size,
are very often equipped with a sequential logic e.g. for location, active bounds, etc. and also it defines abstract
switching of control modes and strategies, error handling, methods determining shapes appearance and behavior.
etc. Sequential logic in general can be inserted into control SFC formalism blocks are special cases of the drawn
algorithms by several ways. Very simple logic can be shapes. These blocks have typical properties like name,
programmed in some textual programming language (C, description, etc. Moreover, they have an extra functionality –
C++, structured text, etc.) directly. As the size of the logic handling blocks validation and compilation. The best way
increases, the code maintenance becomes more and more how to handle this functionality is to define another abstract
complicated and this approach is a very error prone. Hence, class Item inherited from the Shape class (Fig. 1). Note that
several graphical techniques for sequential logic design have object oriented programming (OOP) feature called
been developed. The sequential function chart (SFC) polymorphism has been extensively used.
technique (formerly also called Grafcet) is one of them. This
formalism is widely accepted by the automation community B. Validation and compilation logic
(vendors, users). Moreover, it is standardized by the IEC Polymorphism has been used also in classes responsible
61163-3 standard [1], which describes five languages for for validation and compilation of SFC charts, see Fig. 2. One
programmable logic controllers (PLC) algorithm abstract base class Build defines two abstract methods
development. Validate and Build. Those methods are overridden in
The authors needed a sequential function chart editor, particular classes which implements compilation and
which could be integrated to the REX control system [2] validation logic for the specific target device.
development environment RexDraw. Their effort to find
some open source standalone and smart SFC editor failed. Of C. Monitoring logic
course, there are many implementations of SFC editor SFC Editor cannot monitor the state development of the
integrated in commercial PLC development tools but they particular scheme itself. It must acquire the scheme state
could not be used for this purpose. This fact initiated the from some cooperating application e.g. using some
authors’ own work described in this paper. The developed communication protocol.
editor allows the user not only to create various SFC
Again, one abstract base class Monitor is used, which application and abstract methods responsible for handling
defines methods for reading states from a cooperating received data. Class diagram is shown in Fig. 3.

Figure 1. Class diagram of the graphics entities architecture.

Figure 2. Class diagram of the build logic. Figure 3. Class diagram of the monitoring logic.

block to chart by a simple dragging of the selected block to


III. GRAPHICAL USER INTERFACE the designated place in the chart.
As mentioned above, the editor is based on Microsoft A SFC block properties can be editted in the Property
.NET technology a coded in C# language. That is why the panel, located by default in the right bottom side of the editor
user interface consists of familiar windows controls. window. The property panel uses smart PropertyGrid
Graphical user interface (GUI) of the SFC editor depends component for viewing and editing all public block’s
on command line arguments passed to the SFC editor. If the properties.
editor is called with a parameter determining one of the All detected mistakes in the SFC chart and their
target devices then it acts as a single document interface descriptions are shown in the error list. Similarly, results of
(SDI) application shown in Figure 4. If it is lunched as a the successfully built chart are displayed in an output panel
standalone application (without command line parameters) it located by default in the left side of the SFC editor.
acts like multiple document interface (MDI) application. In addition to such a standard fuctionality as the printing
The standard menus and toolbars provide options for command of the current chart, which uses a special printing
creating new SFC charts, closing, opening, exporting, and dialog, the SFC editor offers exporting of the chart to the
printing existing SFC charts. Zooming command (zoom in, scalable vector graphics (SVG) format.
zoom out) of the chart view are located in the toolbar at the GUI of the SFC editor is mostly inspired by the
bottom of the application window. environment of the Microsoft Visual Studio. The MDI mode
SFC Editor employs a drag and drop method for creating allows the user to construct, edit, validate and compile
and editing SFC charts in graphical user interface (inspirited multiple charts simultaneously (Fig. 5). In the MDI mode,
by Microsoft Visio or Matlab Simulink editors). Thus, a user the compilation results are not passed to the external calling
can place and order the blocks in the chart arbitrarily. application because the SFC editor do not know about it.
All the SFC graphical formalism blocks (and some The last running mode of the SFC editor, in which the
special blocks) are located in the dock panel named ToolBox GUI is modified, is the monitoring mode (SFC editor runs as
on the right edge of the editor. A user can easily insert SFC
a diagnostic tool). In this case, the additional toolbar with
special monitoring controls (Start, Stop, etc.) appears.

Figure 4. SFC editor in single document interface mode.

Figure 5. SFC editor in multiple document interface mode.


mechanism is internally implemented in the SFC editor and
IV. VALIDATION AND COMPILATION OF SFC CHARTS also a caller application must comply with it. The caller
The SFC editor is not only a pure drawing tool, it can application has to create the memory mapped file for data
also check (validate) the drawn chart syntax and to generate exchange and two synchronization object represented by
compiled data for the chosen target. windows events (IN_EVENT, OUT_EVENT) and feed the
The SFC chart validation algorithms differ only slightly SFC Editor with the SFC chart state evolution data.
for different targets (only by disabling some SFC blocks or
different name format). It follows from the fact that the SFC
formalism is independent on the target device for which the
chart is constructed. On the other hand, compilation is
strongly dependent on the target device and the compilation
results output format. Hence, a special class corresponding to
each target device has been designed. Such a class
implements the particular compilation algorithm and specific
details of the validation process.
The SFC chart build process consists of two steps –
validation and compilation. During the validation a special
method of every SFC block (inherited from Item class) is
called. The results of validation are warnings, errors or
success messages which are displayed in the error list
window mentioned above. The compilation step is
Figure 6. Communication schema between SFC editor and external
performed only if the validation finishes without errors. In application.
principle, all SFC blocks are walked trough during the Further customization of the SFC editor can be obtained
compilation and usually some transition table or pseudo code by adding a new builder and/or monitor logic for the
is generated. particular target device. Various types of target devices can
Current version of the SFC editor completely supports be supported by a little “coding” effort.
two target funcion blocks of the REX control system [3].
These are simple automaton block ATMT and its extended VI. CONCLUSION
version EATMT. Support of the REXLANG block
General SFC editor has been developed. The current
(arbitrarily programmable block in the language similar to C
version of the editor has been intensively tested as a
language) is in the experimental phase.
configuration tool of the ATMT and EATMT blocks. The
Some target devices do not fully support all SFC
editor has been also adapted for the use in the development
language features described in IEC 61131-3 standard. These
environment of the ZAT a.s. company.
limitations are taken into account in the validation and
Future development of the SFC editor will improve the
compilation processes for such a target. For example, the
builder implementation for the REXLANG block and fix the
chart, which is built for ATMT target device, cannot contain
potential bugs.
simultaneous divergences and convergences, because this
target device does not support parallel run of the ACKNOWLEDGMENT
corresponding algorithm.
This work has been partially supported by the Czech
V. INTEGRATION AND CUSTOMIZATION OF THE EDITOR Ministry of Industry and Trade, project No. FI IM5/030. This
support is very gratefully acknowledged.
Almost all of the described functions of the SFC editor
are functions commonly known in similar editors. However, REFERENCES
easy customization and a simple way how to integrate the
SFC editor with an external application (or incorporate it to
[1] “Final draft – IEC 61131-3, 2nd Ed. Programmable Controllers –
the third party design tools) are unique features. Programming Languages,” April 2001.
Data exchange between the SFC editor and an external
[2] P. Balda, M. Schlegel, M. Štětina “Advanced Control Algorithms +
application is based on so called memory mapped files and Simulink Compatibility + Real-time OS = REX,” IFAC 16th
call of the SFC editor with special command line parameters Triennial World Congress, Prague, Czech Republic.
which are described in a more detail in the user manual [4]. [3] REX Controls, “REX system function blocks – Reference manual,”
Using the SFC editor in monitoring mode (as a diagnosic Revision 8, Pilsen, January 2010.
tool) is a little bit more complicated and uses [4] M. Kocánek „SFC Editor – User’s Manual,” Technical report,
synchronization mechanism depicted in Fig. 6. This University of West Bohemia, Pilsen, 2010. (in Czech).

You might also like