Microprocessors and Microsystems 30 (2006) 497–508 www.elsevier.com/locate/micpro 0141-9331/$ - see front matter 2006 Elsevier B.V. All rights reserved. doi:10.1016/j.micpro.2006.06.001 Analysis and implementation of the IEC 61131-3 software model under POSIX Real-Time operating systems Inmaculada Plaza ¤ , Carlos Medrano, Alfonso Blesa Department of Electronic Engineering and Communications, EUPT—Teruel University of Zaragoza, Spain Available online 30 June 2006 Abstract In this paper, we present a proposal to implement the IEC 61131-3 software model. This model establishes the high-level elements of the Programmable Logic Controllers. We discuss some of the points of the standard that should be clariWed before implementing it, such as concurrency, variable scope and cyclic operation. We show the implementation guidelines using POSIX compliant Real-Time Operat- ing Systems, in particular RTLinux running on PCs. A translator has been implemented accepting textual descriptions following the IEC 61131-3 standard. 2006 Elsevier B.V. All rights reserved. Keywords: Programmable Logic Controller; IEC 61131-3; POSIX 1. Introduction Traditional programming languages for PLCs (Pro- grammable Logic Controller), such as Ladder program- ming, had several drawbacks, including [1]: weak software structure, poor facility to handle complex data structures, limited control over program execution, limited facilities for software reuse and the use of diVerent symbols between PLC products. The IEC 61131-3 standard is a global standard for control programming that tries to overcome these problems in order to improve software quality. In this paper, we will focus on the software model and the programming organization units (POU) deWned in the standard. Among other advantages, the use of the standard elements promotes the development of well- structured programs, code reuse and the application of software engineering principles such as encapsulation and data hiding. Linux has already been used in control systems, such as in the MatPLC project [2,3], which has also been ported to the QNX POSIX compliant Real-Time operat- ing system and includes its own IEC61131-3 compiler [4]. However, its manual states that it still lacks some fea- tures such as semantic checking, error messages and mul- tiple conWgurations and tasks [2]. In addition, MatPLC speci Wes a much more general framework than PLC pro- gramming. Formal speciWcation for a subset of IEC PLC languages can be found in [5]. Johansson and Öhmann [6,7] considered the implementation of IEC 61131-3, but focused on graphical languages and used a very speciWc tool, the real-time expert system G2 from the Gensym Corporation. In the present paper, we consider the case of a single PLC, so communication functions are not considered, and we will centre on IEC 61131-3 standard programming methods. The standard is often understood as a set of pro- gramming languages to describe algorithms. However, it also includes conWguration elements and allows the user to deWne its own POUs or data types. Therefore, in the present work, we review the main concepts of the IEC 61131-3 soft- ware model, highlighting its weak points. Then, we will explain an implementation proposal using a general pro- gramming language, C, and POSIX operating systems, in short POSIX/C. As a speciWc Real-Time operating system we will use RTLinux [8], which fulWls the minimal Real Time system proWle (POSIX 1013.13). A translator from IEC 61131-3 to POSIX/C has been built following the * Corresponding author. Tel.: +34 978618102; fax: +34 978618104. E-mail address: iplaza@unizar.es (I. Plaza).