Abstract--Hardware-in-the-Loop (HIL) simulation is a technique that is used for the development and testing of controlled systems to operate complex machines ...
1
Hardware-In-the-Loop Simulation for Validating PLC Programs a,b
K. Tebani
a
B. Mihoubi
a
a
Equipe: Systèmes Robotisés de Production, Centre de Développement des Technologies Avancées, Baba Hasen Algérie, Alger 16303. [ktebani,bmihoubi, mkadri, mgaham, bbouzouia]@cdta.dz
Abstract--Hardware-in-the-Loop (HIL) simulation is a technique that is used for the development and testing of controlled systems to operate complex machines and systems. With HIL simulation the physical part of a machine or system is replaced by a simulation. The basic idea of this paper is to test industrial control software by connecting a controller, e. g. a PLC (Programmable Logic Controller) to a discrete event simulator (FlexSim), which provides system reactions and sensor signals similar to the behavior of real hardware, e. g. an industrial manufacturing line. In order to establish a connection between the simulator and the PLC, an OPC (OLE for Process Control) server interface and a JAVA platform has been developed. Index Terms--Hardware In the Loop (HIL), Simulation, PLC (Programmable Logic Controller), FlexSim.
1. INTRODUCTION An automation system is usually considered as being a compound of two cooperating parts. The plant or the operative part represents the physical process. It includes a set of elements such as sensors, actuators, machines, robots, etc. And the controller (PLC) is connected so that process related information is sent from the plant towards the controller and control instructions are sent from the controller towards the plant. In traditional testing of PLC programs, the PLC controller is directly connected with a physical hardware. The main disadvantage with this approach is that it involves great risk on the hardware part; add that regular production has to be stopped during the testing and debugging. In order to protect the system components, an approach based on simulation is proposed [2], [6]. In this context the controller and the plant are connected in closed loop behavior, and this kind of simulation is called software in the loop simulation (SILS). Some recent studies deal with simulation considering the real controller instead of the controller model in the closed loop behavior with the plant model. It is called hardware in the loop simulation (HILS).The comparison between these methods is shown in Fig.1. In this work, we focus on the last category of simulation applied to automated systems. Our objective will be based on the functionality of the simulated system with a real controller PLC. To achieve this, we have used
M. Kadri b
a
M. Gaham
a
B. Bouzouia
Laboratoire de Conception et Conduite des Systemes de Production( L2CSP), University Mouloud Mammeri of Tizi Ouzou, Algeria, 15000 Algeria
the simulator FlexSim, which is discrete event manufacturing simulation software in order to model a manufacturing system represented in this work with a packaging system, and we have implemented the control program of this system in the real PLC. In order to communicate the real PLC with the PC on which a simulation model of the plant runs on, we have developed a communication interface based in the OPC server and JAVA platform. And we have shown that a simulation of the real automated system with the same control system can interact and respond to signals from a control system in the same way as the real system, and that it presents the same pattern of behavior. The presented approach can be applied in various disciplines. In the industrial environment this approach can be applied in PLC testing program of the automated system on the simulated system without any risk of damaging the equipment. It can be applied also in the automatic control courses. The simulation model was created in the FlexSim simulation software. This offers a presentation in 3D of the automated system. The application of this approach in the laboratory in educational or training institutions helps the students to obtain some knowledge about the modeling, operation and control of automation systems, without that they will in actual contact with the plant, in order to protect the students and equipment. The paper is organized as follows: In Section 2 we present the HIL simulation interest. In the Section 3 we describe the different based elements used in the approaches proposed. The hardware in the loop simulation of production system is presented in the section 4. Finally, we end with the conclusion and perspectives in the Section 5. 2. THE HIL SIMULATION INTEREST Hardware-in-the-loop (HIL) simulation is a technique for performing system-level testing of embedded systems in a comprehensive, cost effective, and repeatable manner. HIL simulation is most often used in the development and testing of embedded systems, when those systems cannot be tested easily, thoroughly, and repeatedly in their operational environments.
2
Traditionnel testing Control system Same
HIL Simulation
SIL simulation
Control system
Vertual control
(=) = PLC Hardware/Plant
PLC Simulation/Plant
PLCSim =
Simulation/Plant
Fig.1.The difference between the different approaches Fig.1. The difference between the different approaches
Different approaches are proposed for the application of the hardware in the loop Simulation in the control of manufacturing industrial. In these approaches, several software simulators are proposed, and different methods of the communication between the software part and the hardware part are created. In [9] the author tested industrial control software by connecting a PLC to a discrete simulation/ emulation software tool (Arena). Another approach of the Hardware in the loop simulation of production system in the object to minimize the stabilization time of a production system, caused by
mechanical device not being properly adjusted and faults in the control program, has been proposed in [15]. Another interest of the hardware in the loop simulation is its important role in typical labs in educational institutions. With the HIL simulation approaches, students can experiment with systems that are impossible to work with in a laboratory, being potentially dangerous or of huge dimensions or very expensive processes. An approach dedicated for the manufacturing and mechatronics education is presented in [12]. In this approach, a remote simulation of robot is developed and a communication between the different parts of the HIL system is implemented using the internet technologies. In [13], the author developed an interactive real-time digital control system that can be used in the modeling and controls courses. For the implementation of this environment, the author used the off-the-shelf components, such as standard personal computers and data acquisition cards, as well as software tools from MathWorks and a C++ compiler. 3. SYSTEM COMPONENTS DESCRIPTION The hardware in the loop simulation system is composed in general of the hardware part which is represented in this work by the real controller PLC, and a software part connected between them by the communication interface. In this section we display a general description of the different tools used in this paper such as a controller PLC, the software simulation, and the communication interface which is based to the OPC server.
Serial port
Today, the hardware in the loop simulation has become an indispensable technique for the verification and validation of the systems in various disciplines, such as the aerospace, automotive [3], [5], Aeronautics [4], and industrial environment. In the context of automotive for example, the HILS allows developers to validate new hardware and software automotive solutions, respecting quality requirements and time-to-market restrictions. In a typical HIL Simulator, engine dynamics are emulated from mathematical models and executed by a dedicated real-time processor. In addition, an I/O unit allows the connection of vehicle sensors and actuators (which usually present a high degree of non-linearity). Finally, the Electronic Control Unit (ECU) under test is connected to the system and stimulated by a set of vehicle maneuvers executed by the simulator. In power electronics, the HIL simulation used to reduce development cycle increases efficiency, and improves reliability and safety of these systems for large number of applications. In the industry, the HIL approach has many advantages because the simulation is performed with the real program running in the real controller. This can be very important, especially when different timescales are considered from a real point of view, mainly in what concerns the real evolution of the controller and its timescale, running in real conditions of work [1]. In this context, the model of manufacturing system is running in the PC and controlled with real PLC.
PLC Twido Fig.2. Hardware in the Loop Simulation Fig.2. Hardware-in-the-Loop-Simulation
Conv2
ock1
Stock2
Conv4
Source2
packaging
ock1
buffer combiner Conv3
Robot
3
Conv1
Sensor
Source1
Counter
Fig.3. simulated model
Fig.3. Simulated model
A. Simulator FlexSim FlexSim [16] is an object-oriented software environment used to develop, model, simulate, visualize, and monitor dynamic flow process activities and systems. FlexSim is a complete suite of development tools to develop and compile simulation applications. Today, FlexSim is used to the modeling in the production manufacturing, storage and delivery, transport systems and other fields [7] [8]. Models of systems are created in 3D and assembled by drag and drop. In FlexSim it is possible to import input data for different processes by taking data collected from the real world and turn it into mathematical formulas that drive the simulation. FlexSim supports SiL and HiL but one has to create the logic for itself in order to enable the required communication. This can be done via TCP/IP, DLL or by converting the FlexSim model into C++ and writing the logic directly. B. PLC programming and I/O modules Control of industrial processes is often realized using small digital computers called the programmable logic controllers (PLCs), where the hardware and software are specifically adapted to industrial environment. PLCs are used in many industries and machines. It was originally intended as relay replacement equipment for the automotive industry. Nowadays, the PLC is virtually used in every imaginable industry. The PLC is composed of an automation component controller and input/output modules (I/O) interconnected by a network. PLC execution is sequential. It runs programs, updates the results refreshed inputs and outputs and responds to external commands. This loop is executed as quickly as possible. One loop is called the cycle time. Cycle time defines the time taken by the PLC to respond to the input variation conditions and also determines the time taken to reply to external commands. Most PLC brands support five programming languages de- fined in ladder diagram (LD), structured text (ST),
instruction list (IL), Function Block Diagram (FBD) and sequential function chart (SFC). The PLC used in this work is the Twido TWDLCAA24DRF controller which has 14 digital inputs and 10 digital outputs. For the PLC program we used the Ladder Diagram (LD) program (simple system). For sequential systems of the important size, the ladder program becomes unreadable; the SFC is more suitable for these systems. C. OPC OPC was founded by a few companies in the mid-90s in order to ease the exchange of process data [9]. OPC has been, and still is developed by the OPC Foundation [10]. OPC is implemented using a client/server approach. The program that requests information is the client and the program that provides the information to the client is the server. OPC consists of several specifications [10]-[11]. These specifications contain information about how the server and the client should exchange data. OPC DA (Data Access) was the first specification [9] that made it possible for any OPC DA client to access data from an OPC DA server that fulfills the same specification. OPC DA is used for moving real-time data from devices to Microsoft Windows applications, where real time here means current data in the device, not historical. In this work, we take advantage of this specification in order to recover at any time the new values of the inputs signal for the PLC, and to transmit at any time the new values of the outputs to the simulated system. 4. HARDWARE IN THE LOOP IMPLEMENTATION In this section, we will describe the various elements and various steps for the utilization of our approach, using a packaging system as an example. In our environment, we have the simulation model created in FlexSim simulator, running on a PC, a real PLC acting as the control system and the communication interface between the two. The different steps are summarized as follows:
4
Read Inputs
(Socket)TCP/IP JAVA
Serial port
FlexSim Execute user program Update Outputs
OPC
Wait
PLC Inputs Outputs
Fig.4 Fig.4. Communication interface
The automation system built in FlexSim simulator The physical connection between the PC and a PLC done using a serial port The communication between processes inside the PC done using OPC and platform JAVA. This configuration has been adopted in order to answer to some specifications of the system. Particularly, when new system has to be developed, it is enables to have only modifications in the 3D simulated model and the PLC program, and avoid from the modifications of the communication interface. A. 3D Simulation model The first step in the process of HIL simulation is to develop 3D model of the production system. A part model of the complete industry system is developed. Some components are already provided directly in FlexSim library (conveyor, robot,..) while other components are imported from external 3D modeling tools such as packaging machine and sensor. Fig.3 describes this part model of industry system which represents a packaging system. The products are transported by a conveyor (conv1) to the buffer system. In the same time, the empty cardboard cartons are conveyed (conv2) to the combiner. A robot is placed between the combiner and the buffer system (stock1), in order to fill the cardboard cartons with products. The full cardboard cartons are transported by the conveyor (conv3) to the packaging machine. Finally, the finished products are conveyed (conv4) to the stock. The simulator FlexSim is equipped with several type of the conveyor. In our model we have used the Basic conveyor and we have taken advantage of the last one, which has the decision point to
add the sensors to the convoying system. The buffer system is limited to the 4 products, and a counter placed at the entry. These sensors and counter represent the inputs of our system used for the description of PLC program. The outputs of the system are described in the simulator for the trigger page of each used object. B. PLC Program of the packaging system Once the simulation model is implemented in software simulation, the PLC program needs to be created and an I/O signals list used by the PLC has to be defined. The original file containing the hardware configuration, which determines the type of the used controller (CPU) as well as the Power Supply and the Input/output modules (I/O) in the normal case. In this work we are interested in controlling a simulated operational part, where I / O are configured in the simulator. So just set the type of the CPU in the hardware configuration and the inputs and the outputs objects are used with mnemonics. PLCs run ladder logic programs that modify outputs based on the inputs. Continuing with our example of a conveyor and the inputs would be signals from the decision point and the counter placed in the buffer system, outputs would be the signal or order (start/stop) to the conveyor and the robot. C. Communication interface Once we have at our disposal a PLC program implemented in the real PLC and the simulation of the automated system created in the FlexSim simulator, we have to develop a communication interface between the simulation software and the real PLC in order to exchange data between the simulated system and the real PLC. Last step in HIL simulation is the verification of the developed PLC program which also is the main objective of this project. The communication between the API and the
5
FlexSim simulator must be established. For this, we have developed a communication interface between the simulation software and the real PLC in order to exchange data. The interface is depicted in Fig.4 where a PC connected via serial port to the control system, in which the simulation system is reigning. This later is controlled by a ladder logic program implemented in the real PLC. In order to retrieve/send the data from the PLC/to the PC, we have used the OPC interface and we have created in it the input/output image table. This image table includes this data in the form of items; each item is characterized by its own name and address. OPC is adapted for communication with PLC, which is not the case with Flexsim. Then, to establish the communication between the simulation system and OPC, a JAVA platform is developed, and socket server implemented. The simulation system sends the data which represents the new values of the sensors (inputs) in the form of a messages, thanks to the socket() command of the JAVA platform. This later processes the message and change the value of the items corresponding to the data in the image table created in the OPC. The PLC reads these new values of the inputs and executes the user program and then the new values of the outputs in the image table in the OPC. The JAVA platform in its turn sends these new values of the outputs in the form of an order to the FlexSim. This later receives these values and changes the function of the actuators. Remarque Our approach is based on the sent message and the received message between the API and the simulated system. Then, to ensure that the simulation system takes into account for each instant the received messages a clock is created to the level of simulated system, this last manages the messages, and she guarantees also the synchronization between the two parts (the simulated part and the real part). 5. CONCLUSION The most important result to point out in this work is that we have been able to verify that an automated system simulated with FlexSim software can be controlled with an external controller, and that simulation of the real automated system with the same control system interacts and responds to signals from a control system in the same way as the real system. In order to establish the communication between the real PLC and the PC on which a simulation model of the plant runs on a communication interface based of the OPC and JAVA platform is developed. A first perspective of this work is to apply the results of this study for creation of an automated model which can be applied in the universities, in order to ease the acquisition of knowledge about the modeling, operation and control of automation systems. The second
perspective of this paper is the validation of distributed manufacturing approach using the integration of a multiagent system. The use of the OPC in the communication interface increases the response time of this architecture which imposes a time constraint in the simulation system, it is very interesting to seek other means of communication between these two parts (the simulated part and the real part) REFERENCES [1]
[2]
[3]
O. Ljungkrantz, K. Akesson, M. Fabian, Y. Chengyin, “Formal Specification and Verification of Industrial Control Logic Components”. IEEE Transactions on Automation Science and Engineering, vol.7, no.3, pp.538 - 548, 2010. S. Seidel, U. Donath , “Error-free Control Programs by means of Graphical Program Design, Simulation-based Verification and Automatic Code Generation”. Proceedings 8th Modelica Conference, Dresden, Germany, March 2011. S. Raman, N. Sivashankar, W. Milam, W. Stuart, and S. Nabi, “Design and Implementation of HIL Simulators for Powertrain Control System Software Development”. Proceedings of the American Control Conference,1999.
[4]
D. Jung , P. Tsiotras, “Modelling and Hardware-in-the-loop Simulation for a Small Unmanned Arial Vehicle”, conference and Exhibit 7-10 may 2007, california.
[5]
I. R. Kendall, R. P. Jones, “An investigation into the use of hardware-in-the-loop simulation testing for automotive electronic control systems”. Control Engineering Practice, vol 7, Issue 11, pp. 1343-1356, November 1999.
[6]
R. Drath, P. Weber, N. Mauser, “An evolutionary approach for the industrial introduction of virtual commissioning”. Emerging Technologies and Factory Automation, IEEE International Conference on, pp.5-8, ETFA 2008
[7]
J.Q. et al., The magnesium-smelting production line simulation and optimization based on Flexsim, Industrial Engineering, vol.12, no. 2, pp.78-81, 2009.
[8]
L. Gang, An Shengmin, Liao Junjun, “The Optimization and Simulation of Automobile Spread Production Line”. Industrial Engineering, vol. 11, no. 6, pp.71-76, 2009.
[9]
M. H. Schwarz and J. Boercsoek, “A survey on OLE for process control (OPC)”. In Proc. 7th Conf. Int. Conf. Appl. Comput. Sci., Venice, Italy, 2007, Vol. 7, pp. 192-196.
[10]
OPC Foundation [Online]. http://www.opcfoundation.org, 2010-10-01
Available:
[11] X. Hong and W. Jianhua, “Using standard components in automation industry: A study on OPC specification”, Computer Standards & Interfaces, vol.28, pp.386-395, 2006. [12]
H.Temeltas, M.Gokasan, S. Bogosyan , A. Kilic, “ Hardware in the Loop Simulation of Robot Manipulators through Internet in Mechatronics Education”. IECON 02. International Conference on. IEEE. vol.4, pp. 2617- 2622, 2002.
[13] S. Panayiotis , Shiakolas, Development of a Real-Time Digital Control System With a Hardware-in-the-Loop Magnetic Levitation Device for Reinforcement of Controls Education, IEEE Transactions on Education, vol.46, no.1, February 2003. [14]
Bin Lu, “A Low-Cost Real-Time Hardware-in-the-Loop Testing Approach of Power Electronics Controls”. IEEE Transactions on industrial electronics, vol.54, no.2, April 2007
[15]
C. Sang Park , Minho Chang, “ Hardware-in-the-loop simulation for a production system”. International Journal of Production Research, vol. 50, no.8, pp. 2321-2330, 2012.
[16]
B. William, “Nordgren, Flexsim simulation environment”. Proceedings of the 2003 Winter Simulation Conference, pp 197-200.