You are on page 1of 14

Int J Adv Manuf Technol (2007) 35:527–540

DOI 10.1007/s00170-007-1127-4

ORIGINAL ARTICLE

Automatic generation of PLC automation projects


from component-based models
Elisabet Estévez & Marga Marcos & Darío Orive

Received: 9 January 2007 / Accepted: 12 June 2007 / Published online: 18 July 2007
# Springer-Verlag London Limited 2007

Abstract Industrial process measurement and control sys- 1 Introduction


tems (IPMCS) are used in most of the industrial sectors
to achieve production improvement, process optimization Industrial control systems are a special type of computer
and time and cost reduction. Integration, reuse, flexibility and system that control physical devices by means of control logic
optimization are demanded to adapt to a rapidly changing and and sequences. Besides, they usually have to respond to
competitive market. In order to achieve these goals, the use of external events coming from the environment they control.
standards in the application field, methodologies for defining They use programmable logic controllers (PLCs), industrial
the application design and tools for supporting the develop- communication systems (fieldbus), and dedicated I/O devices
ment cycle are needed. This paper proposes a component- to meet the operational requirements. As a computer system,
based model of the implementation of the control system its design deals with the definition of the software architecture,
under design (the hardware and software architectures). The which implements the control strategies. Traditionally, each
software architecture is defined to follow the software model control equipment vendor offered a development system
of the IEC 61131-3 standard for programming programmable based on proprietary software architecture and programming
logic controllers and the hardware architecture is composed languages. To promote the use of standards for this application
by equipment characterised by vendor and range of product. field, international organisations are making a huge effort.
The proposed modelling is implemented as a markup PLCOpen [1] was founded in 1992 and it is a vendor- and
language that allows to describe models of industrial control product-independent worldwide association whose mission
systems (icsML). From the application model, described in is to be the leading association resolving topics related to
the markup language, the automation project for every control programming to support the use of international
programmable logic controller (PLC) present in the applica- standards in this field. The International Electrotechnical
tion is automatically generated. Commission (IEC) promotes open systems to be used in the
industrial control field. The IEC 61131-3 standard [2, 3]
Keywords Industrial control systems . Component-based proposes a software model and programming languages for
modelling . Model-driven development . IEC 61131-3 . industrial process measurement and control systems
XML technologies (IPMCS). Most of the PLC manufacturers are aiming to
become IEC 61131-3 standard compliant. PLCopen has
defined different compliance levels (base and conformity)
E. Estévez (*) : M. Marcos : D. Orive and many companies are certified. For instance, Schneider
Department of Automatic Control and Systems Engineering, Electric, Rockwell Automation ICS Triplex ISaGRAF,
University of the Basque Country,
Infoteam, KW Software, Mitsubishi Electric, Panasonic,
Alda Urquijo S/N,
48013 Bilbao, Spain and Smart Software Solutions, among others. The Automa-
e-mail: elisabet.estevez@ehu.es tion Alliance [4] is constituted by companies of the
M. Marcos automation industry such as ABB or WAGO, whose
e-mail: marga.marcos@ehu.es hardware devices are all programmed with the same IEC
D. Orive 61131-3 programming system [5]. Most of them, among
e-mail: dario.orive@ehu.es other manufacturers, belong to the PLCopen organisation.
528 Int J Adv Manuf Technol (2007) 35:527–540

As the industry reaches a greater maturity level and requirements by building systems with existing components
applications increase in complexity, a consolidation of and connectors. Some attempts have been done by different
methodologies, which allow system description and definition authors towards the use of well-known modelling lan-
before its construction, becomes necessary. In [6], an guages for designing industrial process measurement
interesting review of the information systems and production control systems (IPMCS). [13, 14] propose the use of the
system environments is presented. It also shows how the unified modelling language (UML) [15, 16] for specifying
information system methodologies have been transferred to components of control systems following the IEC 61131-3
production systems. The application of consolidated infor- standard. Both approaches apply Object-Oriented technol-
mation systems technologies and methodologies to produc- ogy to model industrial automation applications. However,
tion systems is still a current practice. In this sense, it is not clear if the resulting models are analysed in terms
component-based software engineering (CBSE) is a relative- of consistency of POUs (program organization units)
ly new software engineering approach that has been proven functionality modelled in UML. Furthermore, the papers
to be very powerful in the design of software intensive do not explain if these models could be imported from a
systems [7, 8]. In [9] a component technology specifically for PLC programming tool in order to download the automa-
field devices is proposed. Other interesting work is described tion project onto the target. In [17] a model-based approach
in [10], where a model for prediction and consistency is proposed that uses two views to describe the design of
checking of extra-functional properties relevant to distributed manufacturing systems: the conceptual view and the control
real-time control-systems is developed and implemented. engineer view. They also use UML to guide the design of
This paper deals with applying the CBSE concepts to the system. In particular, they analyse the system behaviour
define a component-based approach as applied to industrial before its implementation using the potentiality of UML
control systems. Components and connectors for defining diagrams. But, they do not support automatic code
the hardware and software architectures are identified, as generation.
well as the composition rules they must fulfilled in order to There are other works that focus on the design of
describe industrial control applications. The component- applications using the IEC 61131 standard. [18] proposes a
based approach is implemented as a markup language. methodology for the analysis and modelling of discrete
XML technologies [11, 12] have been used not only for event systems applied to the development of the control
defining the elements of the language but also for logic based on the IEC 61131-3 standard. This methodol-
implementing the check rules that assure the fulfilment of ogy is offered jointly with a tool that provides an IEC
the constraints imposed by the architectural style. Finally, 61131-3 program expressing the execution control of the
related XML technologies are used for filtering, processing application.
and formatting the complete application model in order to Related to distributed industrial control systems, the
generate the automation project for the target commercial evolving IEC 61499 standard [19, 20] is being discussed as
tool. Different cases arise depending on the target tool a successor of the IEC 61131 standard. Currently, there is a
storage format. The steps to follow and the different XML great interest in analyzing the influence of the new standard
technologies for every case are presented. in industry, as well as its convergence with the IEC 61131-3
Section 2 is devoted to related work aiming at modelling standard. Several groups are focussed their research in this
industrial control applications. In Sect. 3, a novel approach topic. [21] discusses the role of the IEC 61499 in the
for modelling industrial control application is proposed, in factory automation and analyses the current on going
terms of hardware and software components and connec- research by several groups. [22–24] describe a framework
tors. In Sect. 4 a markup language for describing such type called CORFU (common object-oriented real-time frame-
of applications is proposed. Section 5 details the automatic work for the unified development of industrial control
generation of the automation project from the application systems application) that defines an industrial process-
model. Finally, the conclusions section points out future control protocol for the development, distribution, and
extensions of this work. In particular, the use of other XML operation of such type of applications based on IEC 61499
technologies that could be used for developing a model Function Blocks. The design is object oriented and uses
based framework aiming at integrating the tools involved in UML to define a 4-layered architecture for designing such
the design of industrial control applications. type of systems [25].
There are very few commercial-off-the-shelf-tools that
are IEC 61499 compliant. In fact, only ISaGRAF® PLC
2 Related work programming tool [26] announces it is.
However, nowadays most of the PLC manufacturers
The component based strategy aims at managing complex- offer programming tools that follow the IEC 61131-3
ity, shortening time to-market, and reducing maintenance standard, and in most cases, they provide a proprietary
Int J Adv Manuf Technol (2007) 35:527–540 529

NODE

Node_1

Bus
Bus
16 bits


Node_2 Node_3
16 bits

1 0..∞ 0..∞ 0..∞ 0..∞ Segment - Connector:


Communication Boards
Power Memory I/O
Processor … Data - Connector:
Supply Card Card …
Connector in I/O Boards
Fig. 1 Hardware components and connectors

solution and protocol for distributed applications involving imposing the constraints that define a valid IEC 61131-3
their own PLCs. automation project. Besides that, the markup language not
What the IEC 61131-3 standard does not solve is the only defines the software architecture but also the hardware
interoperability among PLC programming tools that would architecture, which is based on common elements and vendor
allow true software reuse. In this context, the PLCOpen specific characteristics. Thus, the definition of this language in
technical committee 6 [27] has selected the XML [28, 29] XML not only allows description of industrial control
to define a common language for transferring POUs written applications but also analysis for consistency in terms of the
in any of the five supported languages among IEC 61131-3 fulfilment of the composition rules. These later are performed
compliant tools. It has defined a global XML schema [11] for by means of XML schematron rules [12]. These checks are
defining automation projects with the elements defined in the necessary because a model could be generated from other
IEC 61131-3 software model. As the aim is to communicate tools than PLC programming tools, such us modelling tools
programming tools, it is not necessary to check for [30–32], as well as frameworks like CORFU and the other
consistency (the transferred code is supposed to be tested tools commented above. Thus, it is necessary checking the
in the source tool). correctness of the model before the generation of the
The goal of this paper is more general, as it proposes a automation project. Other interesting work is presented in
generic markup language specifying not only the elements but [33–35]. It deals with the use of XML for obtaining a formal
also the composition rules. Thus, it uses the same elements but description of the code using finite state machines for the

Fig. 2 Relationships among


Func.
software components 0..∞
Block.
Configuration Resource Program 0..∞ Func
1..∞ 1..∞ Block
Function
0..∞
0..∞

Code execution
Task organization
530 Int J Adv Manuf Technol (2007) 35:527–540

CPU Resource Program Task


(HW) (SW)
PROGRAM ProgA TASK TaskB
VAR_INPUT ... INTERVAL...
CAL FB... PRIORITY...
Global
PROGRAM ProgA WITH TaskB;
variables (SW)
I/O (HW)

Programmable Logic Configuration


Controller (HW) (SW)
Fig. 3 relationships between hardware and software

instruction list language. This is complementary to the work that components interact. A connector is specified by the
presented here, as the proposed schema could be integrated type of the connector, the roles defined by the connector
in the markup language for the body of POUs in IL. type, and the constraints imposed on the roles of the
There are different XML technologies [36–39] that allow connector. Components are connected by attaching their
getting information or setting it from/to the model. In [40] ports to the roles of connectors.
an integration development environment is presented that Another important concept is the architectural style. An
uses the markup language proposed in this paper as the core architectural style defines patterns and semantic constraints
to integrate the COTS tools for supporting the development on a configuration of components and connectors. As such,
cycle of industrial control applications. In the same way, it a style can define a set or family of systems that share
could be possible to integrate any of the development tools common architectural semantics [41].
mentioned above, as well as any PLC programming tool. A component-based approach to describe industrial
control systems consists of identifying the components,
connectors and the architectural style that allow describing
3 Component-based modelling of IPMCS both, the hardware and software architectures of the
application. The model must be completed with the relation-
The component-based strategy aims at managing complexity, ships between the elements of both architectures, as they
shortening time-to-market, and reducing maintenance require- represent the same system. For instance, if the hardware
ments by building systems with existing components. Primary architecture describes three different PLCs in the application,
reasons for component production and deployment are the software architecture must describe three automation
independency of components from their context; independent projects, one for each PLC. Or if the code uses a variable that
component development, testing, configuration and later represents a value from a sensor, the hardware architecture
reuse, as well as upgrade and replacement in running systems. must contain an input within an I/O board that matches in
Generally speaking, software architectures are defined as type (BOOL, BYTE or other) with such variable. Otherwise,
configurations of components and connectors. A compo- the application model results incoherent.
nent is an encapsulation of a computational unit and has an The hardware architecture represents the electronic-
interface (e.g., port) that specifies the capabilities that the electrical engineering view. Thus, it deals with the physical
component can provide. connectors encapsulate the ways equipment that constitutes the control system. Typically

Fig. 4 General overview of the


industrial control system mark-
up language
Int J Adv Manuf Technol (2007) 35:527–540 531

Fig. 5 General overview of eeEng_ML.xsd

controllers (PLCs) where the control code is executed, I/O On the other hand, the software architecture represents
devices, used to monitor and command the process and bus the software engineering view and it implements the
segment, in the case the instrumentation is distributed. functionality of the control system. As commented above,
Usually, the controllers and the I/O devices are composed the software model proposed by the IEC 61131 standard [2]
by a set of boards: the power supply, the CPU, memory defines the software architecture of industrial control
cards, communication cards and others. Controllers and bus systems. Briefly, the elements provided to define a control
segments are related by a communication board. application are the following: each PLC or Open PLC

Fig. 6 Definition of nodes from a base XML element


532 Int J Adv Manuf Technol (2007) 35:527–540

Fig. 7 General overview of swEng.xsd

(manufacturer independent control system) is represented boards, except the communication board, that represents a
by a configuration. It contains resources and tasks. type of connector. All components are characterized by the
resources provide support for program execution while manufacturer, serial number and firmware version. Every
tasks allow the designer to control the execution rates of type of component adds new characteristics. For instance,
different parts of the program. Finally, resources also the component that describes a bus segment is characterized
contain programs, a type of program organisation unit at least by the speed and the protocol of the OSI application
(POU) that executes code. The code could be written in any layer. It is also possible for a component to have character-
of the five programming languages provided by the istics defined by the manufacturer.
standard and it makes use of function block and function Related to hardware connectors, there is one type for
POUs. The former is the key POU for achieving software each description level. Each communication board that
reuse. POUs define and/or use variables, characterized by connects a node to a bus segment represents a segment-
their visibility, type and value. connector. The so-called data-connector is used at the
second level diagram, and it represents data contained in I/
3.1 Modelling elements of the electronic-electrical O cards. In particular, a data-connector is associated to each
engineering view byte in a digital card, or to each analogue channel. In both
cases, connectors are characterized by their relative address
The hardware architecture description of a distributed in the card and their size. Figure 1 illustrates the hardware
industrial control system can be described in two levels. components and connectors.
The first level is a global view that represents the high level
architecture by means of nodes interconnected by bus 3.2 Modelling elements of the software engineering view
segments. The second level describes each node by means
of the modules and boards that compose it. The Fig. 1 The software engineering domain components and con-
illustrates the main elements involved in the description. nectors correspond to the elements of the IEC 61131-3
In this domain view, components do not encapsulate a standard software model. Two types of components are
computational unit, but they are used to characterise the considered: those that allow defining the architecture
hardware equipment. They may contain information useful (configuration, resource and task), i.e., they do not
for configuring the hardware during the application start- represent a computational unit but they contain other
up. The hardware components are bus segments, nodes and components that contain code or organise the execution of

Fig. 8 Checking the ProgInst


<xs:key name="POUId">
pouName value
<xs:selector xpath="sw:Types/sw:Pous/sw:Program"/>
<xs:field xpath="@name"/>
</xs:key>
<xs:keyref name="refPOUid" refer="sw:POUId">
<xs:selector xpath="sw:Instances/sw:Configuration/sw:Resource/sw:ProgrInst"/>
<xs:field xpath="@pouName"/>
</xs:keyref>
Int J Adv Manuf Technol (2007) 35:527–540 533

Fig. 9 Schematron rule for


<rule context="sw:Task">
checking the sw:task
<assert test="(current()/@period and current()/@trigger)
or (not(current()/@period and current()/@trigger))" priority="high">
A task mus be periodic or by event
</assert>
</rule>

components containing code (POU). The latter type allows 4 A markup language for describing ICSs
the achievement of true reusability, but the former type
allows the definition of correct software architecture and In this section, a markup language for describing industrial
they are directly related to hardware components. control systems is proposed. It makes use of the software
The software model also defines dependencies between and hardware components and connectors and implements
these components, as illustrated in Fig. 2. A configuration the composition rules. The markup language has been
represents the complete software architecture that correspond defined as a XML schema (icsML.xsd)1 and it allows one to
to the PLC it represents. It contains at least one resource. define applications in terms of three XML schema elements
Each resource contains the executable, code structured in as illustrated in Fig. 4: the hardware architecture (eeEng),
programs. Optionally, they may contain tasks, that can be the software architecture (swEng) and the mappings
activated by event or by time and that have a priority. The between components and connectors in both views.
periodic and sporadic execution is achieved by associating The electronic-electrical engineering XML schema
programs and function block POU instances to tasks. In this element is illustrated in Fig. 5. As commented above, an
sense, all the programs and function blocks associated to the ICS is composed by at least one processing node that can
same task execute at the same period and priority. have distributed I/O. The connection between a processing
On the other hand, software connectors correspond to the node and its I/O or among processing nodes is described by
IEC 61131-3 variables and they represent the communica- means of a bus segment.
tion between software components. In fact, their visibility In order to define the node and bus components, the
identifies the components that are involved in the commu- extension mechanism is used as illustrated in Fig. 6a. The
nication: VAR_ACCESS identifies the communications common characteristics are defined as a basic type
between programs residing in different configurations. (genericComponent). New types that add other character-
VAR_GLOBAL at configuration level identifies communi- istics are defined for the genericBus and genericBoard.
cation between programs residing in different resources of The different type of boards (IO, power supply,
the same configuration. VAR_GLOBAL at resource level processor, memory card, ...) are defined by means of a
identifies the communication between programs of the type that extends the generic board type.
same resource. Finally, VAR_LOCAL identifies the com- A node is defined as a set of boards. Figure 6b illustrates
munication among nested POUs [2]. the definition of a processing node from Siemens manu-
facturer. It is composed by a set of boards: the power
supply, the processor, a memory card and a communication
3.3 Relationships between hardware and software views card. All of them extend the basic characteristics of the
boardTypes of Fig. 6a.
The hardware and software architectures describe the same Repositories organised by manufacturer and range of
control system from different point of view. Thus, they are product could be used to achieve hardware maintainability.
not independent. In order to represent a consistent applica- The software engineering XML schema element illus-
tion, components and connectors in each view must be trated in Fig. 7 is defined by the following constraints and
related. In particular, a PLC must correspond univocally to composition rules imposed by the IEC 61131-3 software
a configuration, a CPU is related to a resource and data- model.
connectors (representing a byte of digital I/O or an The description of the software architecture has two
analogue channel) are related to a global variable or a field main parts: one containing the types (data and POUs)
of a global variable, as Fig. 3 illustrates. defined by the programmer and used by the application
Finally, if the control system consists of more than one (sw:Types), and the other containing the automation project
PLC, the communication between them requires a rela-
tionship between each communication board (segment-
connector) and an IEC 61131-3 access variable (VAR_- 1
A prototype can be found at http://www.disa.bi.ehu.es/gcis/projects/
ACCESS) that contains the exchangeable information. merconidi/ics_ML
534 Int J Adv Manuf Technol (2007) 35:527–540

Fig. 10 TIME data type in XML <xs:simpleType name="TIME">


schema
<xs:restriction base="xs:string">
<xs:pattern value="(T|t|TIME|time)(#\d*\p{P}?\d*d)"/>
<xs:pattern value="(T|t|TIME|time)(#\d*d\d*\p{P}?(_)?\d*(h|m|s|ms))"/>
<xs:pattern value="(T|t|TIME|time)(#\d*d\d*\p{P}?(_)?\d*h\d*\p{P}?(_)?\d*(m|s|ms))"/>
<xs:pattern value="(T|t|TIME|time)(#\d*d\d*\p{P}?(_)?\d*m\d*\p{P}?(_)?\d*(s|ms))"/>
<xs:pattern value="(T|t|TIME|time)(#\d*d\d*\p{P}?(_)?\d*s\d*\p{P}?(_)?\d*ms)"/>
<xs:pattern value="(T|t|TIME|time)(#\d*h\d*\p{P}?(_)?\d*(m|s|ms))"/>
<xs:pattern value="(T|t|TIME|time)(#\d*h\d*\p{P}?(_)?\d*m\d*\p{P}?(_)?\d*(s|ms))"/>
<xs:pattern value="(T|t|TIME|time)(#\d*m\d*\p{P}?(_)?\d*(s|ms))"/>
<xs:pattern value="(T|t|TIME|time)(#\d*m\d*\p{P}?(_)?\d*s\d*\p{P}?(_)?\d*ms)"/>
...
</xs:restriction>
</xs:simpleType>

itself (sw:instances). This separation of concerns was first range of values and by their representation patterns. The
proposed by the TC6-XML group of PLCopen. The work definition of the elementary data types in XML is illustrated
presented here proposes three main changes to the original in Fig. 10 through the definition of the TIME data type.
proposal: firstly, each type of component identified in Figure 11 illustrates the definition of a task instance of
Sect. 3 within the IEC 61131 software model is defined as a priority eight and period one second. The period has to be
XML schema element. Thus, some elements in the expressed using the TIME type format. The first example
PLCOpen TC6 schema become attributes in the new uses other representation pattern (TIME_OF_DAY type)
proposal. Secondly, a SimpleType of a XML schema and the XML parser will raise an error.
element is defined for each elementary data type of the Additionally, a set of schematron rules for checking
IEC 61131-3 standard. This allows one to check the cross reference values have been developed.
correctness in default values of variables. Finally, in order The third XML element of the icsML schema represents
to assure that the architectural style for describing an the relationships between components and connectors of the
automation project is followed, XML schema key-keyref hardware and software architectures, as illustrated in Fig. 12.
elements as well as schematron rules have been used to A set of 39 composition rules have been implemented in
assure consistency. These modifications are necessary if order to assure that the industrial control application
other tools, such as modelling, configuration or documen- conforms to the constraints of the architectural style: 33
tation tools may generate or consume part of the model. correspond to composition rules of the hardware and the
The configuration component (sw:configuration) is char- software architectures themselves and the other six assure
acterized by its connectors or variables (global and access) consistency between the hardware and software architec-
and at least by one resource component. This latter is also tures (in terms of mappings between both architectures).
defined by its connectors (global variables), optionally by These latter have been implemented as part of the icsML
task components and at least by one POU instance of XML schema using the key-keyref elements [43] jointly
program type. Figure 8 illustrates a key/keyref example for with schematron rules. Figure 13 illustrates an example. In
assuring that the value of the POUName attribute within this case, it corresponds to a mapping between a hardware
each program instance (sw:ProgInst) is one of the applica- component (processing node) and a software component
tion POUs defined within the Types element (sw:Types). (configuration). Using the key-keyref XML schema ele-
Figure 9 illustrates an example of a schematron rule that ment, one is assured that both elements exist. A schematron
checks if a task component is defined as periodic or by rule allows the assurance that this mapping is unique.
event. One and only one attribute is required.
On the other hand, the software architecture connectors,
the variables, are characterized by their visibility (global or 5 Generation of the automation project
access), type and initial value. In this sense, and in order to
check the correctness of the initial value, the data types One possible application of the proposed modelling is the
considered as elementary by the standard [42] have been use of the model for automatically generating the automa-
defined in XML. The data types are characterized by their tion project in the target PLC programming tool. Other
Fig. 11 Checking the correctness It does NOT follow IEC 61131-3 TIME data
period value of IEC 61131-3 <task name=“task_1" priority="8" period="00:00:01.0“/> type pattern format
task
<task name=“task_1" priority="8" period="T#1s0ms“/> It follows IEC 61131-3 TIME data type pattern
format
Int J Adv Manuf Technol (2007) 35:527–540 535

Fig. 12 Definition of the relationship between hardware and software components and connectors

related XML technologies are useful to achieve this goal. In 5.1 The tool offers import/export option
particular, those that allow extracting, filtering, processing and
formatting the information contained in the application XML Commonly, every tool allows one to import/export part of an
file. In particular, the extensible stylesheet languageXML automation project stored in its database. The format usually is
technology [44] consists of a language for transforming a kind of structured text whose structure is tool dependent.
XML documents [36], and a XML vocabulary for specifying However, since PLCopen TC6 XML defined the PLCopen
formatting semantics, XSL-FO [37]. Other technologies such XML interface to support communication between PLC
us document object model (DOM) [38] and simple API of programming tools, it is possible to find tools that offer XML
XML (SAX) [39] are very useful for generating XML files import/export. Depending on the import/export option (struc-
or for manipulating XML files. tured text or PLCopen XML); the steps to follow to obtain the
Figure 14 illustrates the sequence of actions to be carried automation projects from the application.xml are different.
out for each PLC/configuration defined in the application If the programming tool imports/exports projects or part
XML file. of them from/to structured text, the processing must not
First of all, it is necessary to add the information that the only add the tool dependent information, but also transform
tool expects (every tool has its own characteristics related the xml file into structured text that the tool expects and
to the definition of an automation project). This adaptation, vice versa (case a of Fig. 14).
transforming a XML file to another XML file with different Figure 15 illustrates this case for the CoDeSys program-
content and/or structure, could be performed by means of ming tool from Automation Alliance [4]. This tool allows
the XML stylesheet, 2Tool.xsl of Fig. 14. It processes the exporting/importing the application POUs or the overall
input file, adds the tool dependent information and software architecture to/from a structured text file with .exp
generates the file Tool.xml. From this XML file, the extension. The input file is the application.xml that follows
automation project for the target tool can be generated. the icsML language. The XML stylesheet developed
The following sub-sections describe the two possible (2CoDeSys.xsl) adds the tool dependent information and
situations that arise depending on the capabilities of the gives as output file the structured text expected by
PLC programming tool to import/export information. CoDeSys. To perform these transformations two different

key/keyref schema elements


<xs:key name="configurationId">
<xs:selector xpath="sw:swEng/sw:Instances/sw:Configuration"/>
<xs:field xpath="@name"/>
Schematron rules
</xs:key> <rule context="rel:Component_ee_sw">
<xs:keyref name="refConfigurationId" refer="ics:configurationId"> <assert test="count(@configuration)='1'" priority="hight">
<xs:selector xpath="rel:relationships/rel:Component_ee_sw"/> configuration only could correspond to a one and only one node
<xs:field xpath="@configuration"/> </assert>
</xs:keyref> <assert test="count(@node)='1'" priority="hight">
<xs:key name="nodeId"> node only could be associated to a one and only one configuration
<xs:selector xpath="ee:eeEng/ee:Node/ee:ProcessingNode/*"/> </assert>
<xs:field xpath="@name"/> </rule>
</xs:key>
<xs:keyref name="refNodeId" refer="ics:nodeId">
<xs:selector xpath="rel:relationships/rel:Component_ee_sw"/>
<xs:field xpath="@node"/>
</xs:keyref>
Fig. 13 A configuration must correspond univocally to a processing node
536 Int J Adv Manuf Technol (2007) 35:527–540

Fig. 14 Steps to generate the automation project depending on the tool import/export option
types of XSL templates have been used: match that As an example of the use of XML stylesheets, Fig. 15
contains the processing to be applied to a particular XML shows the involved templates that read the application
element. This processing could be organised by means of XML and generate the interface of all the POUs defined
the so-called name templates, that allows structuring the within the application. In this case, the output is a text file
transformation. Table 1 lists the set of templates. following the CoDeSys structure. Four templates are used:
<xsl:template match="sw:Interface"> 3
<xsl:template match="*" mode="POU"> 1 <xsl:if test="sw:Variables[@visibility='in']">
<xsl:variable name="type"> <xsl:text>VAR_INPUT</xsl:text>
<xsl:call-template name="pouType"/> <xsl:apply-templates select="sw:Variables[@visibility='in']"/>
</xsl:variable> <xsl:text>END_VAR</xsl:text>
<xsl:value-of select="$type"/> </xsl:if>
<xsl:text> </xsl:text><xsl:value-of select="@name"/> <xsl:if test="sw:Variables[@visibility='out']">
<xsl:apply-templates select="sw:Interface"/> <xsl:text>VAR_OUTPUT</xsl:text>
<xsl:apply-templates select="sw:Body"/> <xsl:apply-templates select="sw:Variables[@visibility='out']"/>
<xsl:text>END_</xsl:text><xsl:value-of select="$type"/> <xsl:text>END_VAR</xsl:text>
</xsl:template> </xsl:if>
<xsl:if test="sw:Variables[@visibility='inout']">
<xsl:template name="pouType"> 2 <xsl:text>VAR_INOUT</xsl:text>
<xsl:if test="contains(name(),'Program')"> <xsl:apply-templates select="sw:Variables[@visibility='inout']"/>
<xsl:value-of select="'PROGRAM'"/></xsl:if> <xsl:text>END_VAR</xsl:text>
<xsl:if test="contains(name(),'FunctionBlock')"> </xsl:if>
<xsl:value-of select="'FUNCTION_BLOCK'"/></xsl:if> <xsl:if test="sw:Variables[@visibility='external']">
<xsl:if test="contains(name(),'Function')"> <xsl:text>VAR_EXTERNAL</xsl:text>
<xsl:value-of select="'FUNCTION'"/></xsl:if> <xsl:apply-templates select="sw:Variables[@visibility='external']"/>
</xsl:template> <xsl:text>END_VAR</xsl:text>
4 </xsl:if>
<xsl:template match="sw:Variables"> <xsl:if test="sw:Variables[@visibility='local']">
<xsl:for-each select="./*/*"> <xsl:text>VAR</xsl:text>
<xsl:value-of select="@name"/><xsl:text> : </xsl:text> <xsl:apply-templates select="sw:Variables[@visibility='local']"/>
<xsl:value-of select="substring-after(name(),'sw:')"/> <xsl:text>END_VAR</xsl:text>
</xsl:for-each> </xsl:if>
</xsl:template> </xsl:template>
Fig. 15 Templates for generating the interface of the POUs
Int J Adv Manuf Technol (2007) 35:527–540 537

Table 1 list of templates of 2CoDeSys.xsl stylesheet

Templates Characteristics

<xsl:template match="ics:IndustrialControlSysten"> It acts as a main function


<xsl:template match="sw:Eng"> It selects the SW architecture
<xsl:template match="sw:DataTypes"> It generates the derived data types
<xsl:template match="*" mode="POU"> It identifies the application POUs
<xsl:template name="pouType"> It returns the POU type
<xsl:template match="sw:interface"><xsl:template match="sw:Variables"> They generate the POU interface
<xsl:template match="sw:Body"><xsl:template match="sw:FBD">... They generate the POU functionality or body. There is a
template for each programming language
<xsl:template match="sw:Configurarion"><xsl:template match="sw: They generate the automation project structure as defined
resource"><xsl:template name="globalVars"><xsl:template match="sw: in CoDeSys tool
task"><xsl:template match="sw:ProgInst">

two for declaring the POU with the corresponding reserved XML stylesheet must add the tool dependent information and
tags; other template for generating the interface; and the last give to the resulting XML file the particular structure for the
template for characterising the name and the type of each target PLC programming tool. Two examples of commercial
formal parameter of the POU. tools that support XML import/export are MULTIPROG4.6®
Note that the content of the generation templates imple- (a PLCopen TC6 XML compliant tool) from KW Software
ments the processing needed to obtain a text file under- and Unity® from Schneider manufacturer.
standable by the target tool. In particular, the automatic generation of the automation
On the other hand, if the PLC programming tool can import / project from the application.xml file to Multiprog4.6® PLC
export a project from/to an xml file, for instance following the programming tool is developed by means of the 2PLCOpen.
interface defined by PLCopen TC6 XML, the transformation is xsl stylesheet. It is composed by a set of templates, one for
from icsML XML file to XML (case b.1 of Fig. 14). Thus, the each IEC 61131-3 software element. It adds to the resulting

Fig. 16 swEng template for <xsl:template match="sw:swEng">


adding the manufacturer depen- <xsl:element name="project">
dent information <xsl:element name="fileHeader">
<xsl:attribute name="companyName"><xsl:value-of select="'KW-Software'"/></xsl:attribute>
<xsl:attribute name="companyURL"><xsl:value-of select="'www.kw-software.com'"/></xsl:attribute>
<xsl:attribute name="productName"><xsl:value-of select="'MULTPROG'"/></xsl:attribute>
<xsl:attribute name="productVersion"><xsl:value-of select="'4.7'"/></xsl:attribute>
<xsl:attribute name="creationDateTime"><xsl:value-of select="@modificationDateTime"/></xsl:attribute>
</xsl:element>
<xsl:element name="contentHeader">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="version"><xsl:value-of select="'1160655546'"/></xsl:attribute>
<xsl:attribute name="modificationDateTime"><xsl:value-of select="concat(substring-
before(@modificationDateTime,' '), 'T',substring-after(@modificationDateTime,' '))"/></xsl:attribute>
<coordinateInfo>
<pageSize x="999" y="999"/>
<fbd><scaling x="2" y="2"/></fbd>
<ld><scaling x="2" y="2"/></ld>
<sfc><scaling x="2" y="2"/></sfc>
</coordinateInfo>
</xsl:element>
<xsl:element name="types">
<xsl:element name="dataTypes">
<xsl:apply-templates select=".//sw:dataType"/>
</xsl:element>
<xsl:element name="pous">
<xsl:apply-templates select=".//sw:pou"/>
</xsl:element>
</xsl:element>
<xsl:element name="instances">
<xsl:element name="configurations">
<xsl:apply-templates select=".//sw:configuration"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
538 Int J Adv Manuf Technol (2007) 35:527–540

Fig. 17 The generation of the automation project for ISaGRAF tool

XML file the tool dependent information. Figure 16 commercial PLC programming tools have been selected.
illustrates as an example the template that reads from the The first one is the ISaGRAF4.2® tool that, although being
input file the root element (sw:swEng) and generates in the IEC 61131-3 compliant, as far as authors know, it supports
output file the corresponding root element, project, adding neither the definition of tasks nor program instantiation.
the multiprog tool dependent information (fileHeader, Thus, it is necessary to apply a XML stylesheet in order to
companyName, companyURL, productName, productVer- perform the transformations needed to have an automation
sion and so on). project understandable by the tool (ISaGRAF.xml file): no
task definition and resources characterised as cyclic,
5.2 Import/export through tool API periodic (characterised by the period and the priority) or
sporadic (characterised by the event that activates it). The
In order to illustrate the more common case (option b.2 of stylesheet unifies the program definition and instantiation in
Fig. 14), i.e., no support for XML import/export, two the resulting file and it also defines as many resources as

Fig. 18 Generation of STEP 7 project


Int J Adv Manuf Technol (2007) 35:527–540 539

tasks with different period (if the periods are not harmon- use of XSL and SAX or DOM technologies to import, export
ics). Finally, an application is developed that gets infor- and transform the software architecture between different
mation from the ISaGRAF.xml file and stores it in a PLCs. Finally, another focus of interest that is being
MS-Access™ database, which is the storage format for investigated is the use of graphical XML languages (SVG)
ISaGRAF projects. This application makes use of DOM to add to the markup language an abstract layer that allow the
which is very useful for getting information from a XML edition and test of the application design. The immediate
file and entering it to the tool by means of its application benefit of the work presented here is that industrial end users
program interface. Figure 17 illustrates the template of the could reuse control code in different PLCs from different
stylesheet that looks for the tasks and for each task, it looks manufacturer.
for the programs and function blocks associated to it. Then,
it defines the necessary resources: one cyclic containing the
POUs not associated to tasks and the timed and by event Acknowledgements The authors gratefully acknowledge the finan-
cial support of the European Union’s Information and Science
resources. Technologies programme for the FLEXICON project IST-2001-
The second example illustrates the case of a tool having 37269 and MCYT&FEDER under projects DPI 2003-2399 and DPI
a proprietary software model: the Simatic Administrator 2006-4003.
from Siemens manufacturer. In this case, the processing that Authors would line to thank the anonymous reviewers for their
valuable comments.
the XML stylesheet must perform is more complicated, as
the software model of STEP 7 is different. Thus, besides
adding the tool dependent information, it also has to
convert the elements of the IEC 61131-3 software model References
into STEP 7 elements.
Figure 18 illustrates the mapping proposed in this work 1. PLCOpen international Organization, available at: http://www.
plcopen.org/
between the elements of both software models, as well as 2. Lewis RW (1988) Programming industrial control systems using
part of the XML stylesheet that performs the commented IEC 1131-3. IEE Control Engineering Series. 1998
transformations. In particular, the programs not associated 3. John K-H, Tiegelkamp M (2001) IEC1131-3: programming
to tasks are transformed to FCs to be executed in the industrial automation systems. Springer
4. Automation Alliance, available at: http://www.automation-alliance.
organisation block OB1. programs associated to tasks are com/
mapped to timed OBs. 5. CoDeSys of Smart Software Solutions, available at: http://
www.3s-software.com/
6. Edan Y, Pliskin N (2001) Transfer of software engineering tools
from information systems to production systems. Computer and
6 Conclusions Industrial Engineering 39:19–34
7. Crnkovic I, Schmidt H, Stafford J, Wallnau K (2005) Automated
This work has applied the concepts of CBSE to industrial component-based software engineering. J Syst Softw 1:1
control systems applications. Two different views have 8. Crnkovic I, Larsson M (2002) Building reliable component-based
software systems. Artech House publisher, ISBN 1-58053-327-2
been identified as the domains involved in the design of 9. Nierstrass O, Arevalo G, Ducasse S, Wuyts R, Black A, Müller P,
such type of systems. The concept of component and Zeidler C, Genssler T, van den Born R (2002). A component
connector drawn in CBSE has been used and adapted in model for field devices. In: Proceedings of the First International
order to identify the different components and connectors, IFIP/ ACM Working Conference on Component Deployment
10. Schmidt H (2003) Trustworthy components: compositionality and
its role in each domain, the relationship between the prediction. J Syst Softw 65(3):215–225
different views as well as the composition rules for 11. XML schema, available at: http://www.w3.org/XML/schema
describing the target applications. A markup language 12. Rick Jelliffe schematron rules, available at: http://www.ascc.net/
(icsML) has been proposed. The implementation makes xml/schematron/
13. Bonfé, Fantuzzi (2000) Mechatronic Objects encapsulation in IEC
use of XML schema and XML schematron rules technol- 1131-3 Norm. Proceedings of the 2000 IEEE Int. Conf. on C A,
ogies to implement the composition rules of the architec- pp. 598–603
tural style. This allows the use tools other than PLC 14. Heverhagen T, Tracht R (2001) Integrating UML-RealTime
programming tools for describing applications (UML-based and IEC 61131-3 with function block adapters. Proceedings of
the IEEE International Symposium on OO RT Distributed
or scalar vector graphics-SVG-based) as coherency and Computing
consistency checks are performed. This markup language is 15. Jacobson I, Christerson M, Jonsson P, Övergaard G, (1992)
being used as the core of an integrated development Object-oriented software engineering. Addison-Wesley
environment achieving a model based design. There are 16. Rumbaugh J, Blaha M, Premerlan W, Eddy F, Lorensen W, (1996)
Object-oriented modelling design. Prentice Hall
other extensions to this work that include the interoperability 17. Young KW, Piggin R, Rachitrangsan P (2001) An object-oriented
between PLC programming tools from different manufac- approach to an agile manufacturing control system design. Int J
turers achieving true reusability. It could be achieved making Adv Manuf Technol 17:850–859
540 Int J Adv Manuf Technol (2007) 35:527–540

18. Gonzalez VM, Mateos F, Amos N (2003) MLAV. Object-oriented 31. Estévez E, Marcos M, Sarachaga I,Orive D. A methodology for
methodology for the analysis and modelling of the control logic of multidisciplinary modeling of industrial control systems using
discrete event systems, SSGRR 2003 UML, In Proc of the 5th International Conference on Industrial
19. International Electrotechical Commision, IEC International Work Informatics. Austria, Viena, July, 2007. Acepted for presentation
in Progress, IEC 61499-3 (2004). Function Blocks for Industrial 32. Kandare G (2001) Model-based software design for procedural
Process Measurement and Control systems. 2004 process control with programmable logic controllers. The 2nd Int.
20. Lewis RW, (Robert W) (2001) Modelling control systems using PhD student workshop on systems and control, [COBISS.SI-ID
IEC 61499 Applying function blocks to distributed Systems. The 16409639]
Institution of Electrical Engineers 33. Bani Younis M, Frey G. Visualization of PLC programs using
21. Thramboulidis K (2005) IEC 61499 In Factory Automation. Int. XML”. In Proc. of the American Control Conference (ACC2004),
Conf. on Industrial Electronics, Technology&Automation Boston, USA, pp. 3082–3087, June 2004
(CISSE-IETA 2005). December 2005 34. Bani Younis M, Frey G. Formalization and visualization of non-
22. Thramboulidis K (2004) Developing a CASE tool for distributed binary PLC programs”. Proceedings of the 44th IEEE Conference
control application. Int J Adv Manuf Technol 24:24–31 on Decision and Control (CDC 2005) and European Control
23. CORFU Framework, available at: http://seg.ee.upatras.gr/corfu/ Conference (ECC 2005) Seville, Spain, pp. 8367–8372, Dec. 2005
dev/index.htm 35. Bani Younis M, Frey G. UML-based approach for the re-
24. Thramboulidis K (2002) Development of distributed industrial engineering of PLC programs”. Proceedings of the 32nd Annual
control applications: the CORFU framework. In Proc of 4th IEEE Conference of the IEEE Industrial Electronics Society, Paris,
International Workshop on Factory Communication Systems, France, pp. 3691–3696, November 2006
Vasteras, Sweden, August 28–30, 2002 36. XSL available at: http://www.w3.org/TR/xsl
25. Thramboulidis K, Tranoris C (2001) A function block based 37. XSL-FO available at: http://www.w3schools.com/xslfo/default.asp
approach for development of distributed IPMCS applications. In 38. DOM: http://www.w3.org/DOM/
Proc of the 10th IEEE International Conference on Advanced 39. SAX http://www.saxproject.org/
Robotics (ICAR 2001), August 22–25, 2001, Budapest, Hungary 40. Estévez E, Marcos M, Gangoiti U, Orive D (2005) A tool integration
26. ISaGRAF, available at: http://www.isagraf.com/ framework for industrial distributed control systems”. In Proc of the
27. PLCopen Technical Committee 6. Available at: http://plcopen.org/ 44th IEEE Conference on Decision and Control and European Control
TC6/XML_Intro.htm Conference, pp. 8373–8378, CDC-ECC, Seville, Spain (2005)
28. XML, available at: http://www.w3.org/XML/ 41. Medvidovic N, Taylor RN (1997) Exploiting architectural style to
29. Pruitt et al (1998) Steve Pruitt, Doug Stuart, T.W. Cook. “The merit develop a family of applications. IEE Proc Software Eng 144(5–
of XML as an Architecture Description Language Meta-Language”. 6):237–248
Microelectronics and Computer Technology Corp, October 1998 42. International Electrotechnical Commission. IEC International
30. Estevez E, Marcos M, Iriondo N, Orive D. Graphical Modelling Standard IEC 61131–3:2003, Programmable Controllers, Part 3:
of PLC-based Industrial Control Applications. In Proc of the 26th Programming Languages, 2003
American Control Conference, New York, USA, July 2007. 43. Van der Vlist E (2002) XML Schema,. Ed. O’REILLY
Acepted for presentation 44. Fidwell D (2001) XSLT. Ed O’REILLY

You might also like