Академический Документы
Профессиональный Документы
Культура Документы
DEVELOPMENT
Jozef Kulisz.* Robert Czerwinski.** Jan Mocha.*** Miroslaw Chmiel.****
Abstract: The paper discusses hardware and software tools used to support Programmable Logic
Controller (PLC) program testing and verification. An idea of a PC-based object simulator is presented.
The simulator consists of a PC equipped with an appropriate I/O card, and a simulator program running
on the PC. The simulator is capable of emulating behavior of real industrial objects. Thus a significant
part of software tests can be performed with the use of the simulator, instead of a physical object. This
can significantly facilitate, and accelerate development of an application.
Keywords: Industrial control, Programmable logic controllers, Program diagnostics, Debugging,
Simulation, Process simulators, Software engineering, Software productivity
1. INTRODUCTION
Testing and verification of complex applications constitutes a Using switchboards can be useful, if the number of PLC
serious problem for PLC (Programmable Logic Controller) inputs to emulate is not big. In some cases, where separate
programmers. In today’s highly competitive world, where devices or small groups of actuators work independently
design and construction companies compete both by reducing from one another, it is also possible to separately test portions
costs, and time to market, control and PLC engineers often of software controlling separate devices.
have work under pressure. Working to tight deadlines Unfortunately it often happens, that the installation has to be
enforces the management to shrink time schedules. Many operated by complex algorithms (e. g. sequences), imposing
parts of the design, construction and commissioning work many interlockings between various parts of the control
have to be done concurrently. Work on the program has to be system, including SCADA (Supervisory Control And Data
started and conducted, while essential parts of the Acquisition) for remote control, visualisation, reporting etc.
installation, that is supposed to be operated by the Under such circumstances testing separate devices is not
application, aren’t yet assembled. Even during the actual sufficient, and using switchboards to test the program as a
commissioning it often happens, that time slots, during which whole is practically unmanageable. It would require
the controlled equipment is freely available for testing, are following the algorithms, tracking the interactions, and
limited. For those reasons a substantial part of a PLC operating tens of switches in real time to provide adequate
application development process has to be conducted at simulation of real hardware.
office, while the equipment that is to be operated by the
program is not accessible to the programmer. So far the task of PLC program testing is hardly supported by
specialised software and hardware tools. The main purpose of
Furthermore, performing some test on real hardware can be the paper is to propose a new approach to PLC application
either difficult, or even impossible for technological, or, what testing and verification – an object simulator, which is an
is even more important, for safety reasons. independent device. The concept is presented after an
It’s a common practice, that at the beginning stages PLC overview of the methods of PLC program testing used so far.
programs are tested using switchboards wired up to PLC
input modules. By operating switches in the proper manner 2. TOOLS SUPPORTING PLC APPLCATION TESTING
one can emulate operation of real hardware, which will later
be connected to the PLC. By observing the indicator LED-s 2.1 PLC simulators
mounted on output modules, the programmer is able to check
whether the program generates the desired logic levels at A PLC simulator is a PC program, capable of simulating
PLC outputs. This method can also be used with analog behaviour of an actual PLC. The simulation is based on a
signals, it demands just applying a little more complex program code, written in the language characteristic for the
hardware, capable of producing analog values, e. g. voltages. simulated PLC, which is interpreted by the simulator
program. States of inputs of the simulated PLC can be forced of them simulates behaviour of the actual PLC, and the other
using an appropriate GUI (Graphical User Interface), and in one – the controlled objects. The simulators exchange
the same manner states of outputs and internal variables can information about the states of PLC inputs and outputs using
be observed (Fig. 1). tags, i. e. variables available at the level of the operating
system.
Dedicated object simulator modules are contained, apart from
PLC simulators, in the TrySim (TrySim, 2010) and PC_Simu
(PC_Simu, 2000) programs. Both programs feature simple
graphical editors, and the simulated objects can be assembled
by the user from a number of primitive elements.
In all of the concepts presented above the object is simulated
in the same PC, together with the PLC executing the tested
control program. This approach can thus be schematically
Fig. 1. The concept of a PLC simulator. depicted in Fig. 2.
A PC-based object simulator has been programmed in C/C++ Listing 1. The Timer1 routine – main data processing.
using the Borland C++ Builder environment, and the At the beginning the object image (ObjIMG()) function is
OpenGL library. A screenshot of the main window of the executed. The function refreshes the variables connected with
developed object simulator is presented in Fig. 6. To object buttons. Then the inputs to the object are read from the
practically test the proposed concept, at first a simulator of a I/O card (PortRead()). Next the most important part of the
belt conveyor was prepared. This enabled carrying out simulator engine is executed - the Proc() function. The
experiments, and testing different configurations and Proc() function processes all variables, and evaluates output
algorithms. In future a library of classes modeling various states of the object (e.g. signals form the simulated
industrial objects can be developed. photocells).
There are two important tasks of the Proc() function. First of
all, the simulator must correctly model physical aspects of the
industrial object. For example, in the belt conveyor there
might be a situation, in which both drives (left and right) are
simultaneously activated by the PLC program under test.
This could possibly damage the belt, or the drives. Such
errors are monitored in the developed simulator. The belt
conveyor doesn’t work, if both drives are active. Moreover –
the simulator indicates such a situation by making the
conveyor blink. The second important task of the Proc()
method is to refresh, and reevaluate states of variables used
for visualization of the controlled process.
The last function in the simulator engine routine is
PortWrite(), which enables transmitting outputs of the object
(evaluated in Proc()) to the I/O card.
Reliable simulation of industrial objects controlled by a PLC
Fig. 6. Main window of the object simulator. is possible, if the simulator sample time is at least an order of
magnitude shorter, than shortest time periods that can be
The engine of the simulator is based on two main classes detected or generated by the PLC. The Windows system is
named TCtrl and TIOMod. The TCtrl class includes variables not well adapted to programming real-time applications. It is
bound up with controlling the belt conveyor drives, indicator thus difficult to guarantee a predefined response time for the
lights, photocells and buttons. The class contains two main simulator. Practical experiments prove, that the I/O card used
methods: ObjIMG() which enables refreshing button with the proposed solution can work reliably for sample rates
variables, and Proc() – the main function processing data. of 1 ms. As we can estimate a PLC scan time to several tens
of milliseconds, the simulator speed obtained is well
Elements facilitating data exchange with the I/O card (see p. sufficient for testing all the functions that are programmed
3.1), like driver handles, USB port opening and closing using the normal serially-cyclic paradigm of PLC operation.
functions, port reading and port writing functions, etc., are Reliability of testing time-critical functions, i.e. interrupts,
high speed counters, and pulse outputs, is a distinct question.
It is a realistic assumption that during a normal PLC
operation an external interrupt is not triggered several times a
millisecond. This means that also interrupt sources can be
reliably simulated using the proposed solution. PLC high
speed counters, and pulse outputs can however work at
frequencies of up to several tens of kilohertz. This means that
their functionality cannot be well tested with the proposed
simulator. Testing at so high frequencies requires in fact a
hardware-software solution. A special I/O card is necessary,
containing hardware counters, and pulse generators.
Fig. 7. A simplified diagram of a digital I/O terminal of the
Visualization of the belt conveyor was developed in 3D USB-4750 card.
graphics using the OpenGL library (OpenGL, 2010).
OpenGL is a low-level, procedural API, requiring from the 4. CONCLUSIONS
programmer to specify the exact steps necessary to render a
scene. This task is accomplished by using a set of base The paper presents an overview of hardware and software
primitives. The scene is rendered cyclically using the TTimer tools used to support PLC program testing and verification. A
class of the Borland C++ Builder. Variables modified in the concept of a PC-based object simulator is proposed. The
Proc() function of the TCtrl class are used to provide simulator consists of a hardware, and a software part. The
animation (List. 2). hardware part is a PC equipped with an I/O card, providing
the interface to PLC inputs and outputs. Operation of the
void Timer2(void) equipment and devices, which shall be controlled by the PLC,
{ is simulated by a program running on the PC. The program
OpenGL->Scene(Ctrl); reads the states of control signals, generated by the PLC,
} evaluates appropriate feedback signals, and sends them back
to PLC inputs through the I/O card.
Listing 2. The Timer2 routine – visualisation.
As scanning of signals generated by the PLC can be
performed at a sample rate of 1 ms, the simulator response
3.1 I/O card time is much shorter, than a typical PLC scan time. The
simulator should thus behave to the PLC in the same manner,
The USB-4750 data acquisition device from Advantech was as a real industrial object (provided that the object is correctly
used as the I/O card (Advantech, 2009). USB-4750 is a modelled in the simulation software).
32-channel isolated digital I/O module for the USB bus. The
main advantages of the module are: As the simulator is a separate device communicating with the
PLC through physical I/O-s, most of PLC, and control
• each I/O channel corresponds to a bit in an I/O port, (it is software functionality can be tested, including interrupts. The
very easy to program this module), simulation is however too slow, to reliably test operation of
high speed counters, and pulse outputs. This requires special
• supports dry and wet contacts,
hardware solutions, which are planned as future
• galvanic isolation provides protection of up to 2,500 developments of the basic concept.
VDC,
Quality and reliability of the tests depend mainly on quality
• features a counter, or timer, of object modelling. It seems thus to be good practice to
appoint the tasks of developing the model of the object, and
• features digital input interrupt lines to a PC, the actual PLC software, to different programmer teams.
• is compatible with the USB Plug & Play specification, The paper presents the concept using an example of a simple
and thus is easy to use, belt conveyor. The authors intend to develop in future a
library of universal industrial objects, e.g. a one-direction
• internal logic is powered from the USB port (no external drive, a motor-operated valve, for the simulator. By
power connection is required, except for an object power combining models of simple elements, the user will be able
supply). to quickly build a simulator model for his specific
installation.
The USB module used is equipped only with isolated digital
inputs and outputs, as presented in Fig. 7. Modules equipped It shall be stressed, that the concept of simulation presented
with analog input/output channels or thermocouple- here is not meant to be a full replacement for test procedures
compatible input channels are however available, too. on real objects. Ensuring reliable and fault-free operation of a
control system is never possible without tests on site,
employing all components of the system fully operational. In
the authors’ opinion the simulator can however handle all
stages of an application development process, except final
verification. It seems to be reliable enough to detect most of
errors in the software, and in particular verify correctness of
algorithms at a higher level of hierarchy, networks, data
exchange with SCADA, etc. Because using the simulator is
safe, and much more convenient, than testing with real
hardware, it can significantly shorten commissioning time.
The proposed idea of an object simulator seams to be also an
attractive option for training purposes. A set of various object
models can be prepared for a PLC programming course. The
models can be easily launched and exchanged, and the
students will have the possibility to solve various problems,
that can be faced by developing commercial applications.
Using a simulator is cheaper, safer, and much more
convenient, than using real machines and objects.
REFERENCES
Advantech (2009), USB-4750 32-channel Isolated Digital I/O
USB Module, User Manual,
http://www.advantech.com/products/USB-4750/mod_1-
2MLJMR.aspx
CoDeSys (2003), User Manual for PLC Programming with
CoDeSys 2.3, 3S - Smart Software Solutions GmbH
ICS Triplex ISaGRAF (2009), ISaGRAF
http://www.isagraf.com
IBHSoftec (2010a), S7 Simulation PLC,
http://www.ibhsoftec-sps.de/english/Selection_Sim.htm
IBHSoftec (2010b), Extended Simulation S5,
http://www.ibhsoftec-sps.de/english/Selection_Sim.htm
Kulisz J. (2004), PLC Software Development supported by
utilising a Simulator Program Block, Proc. of the
International Conference on Programmable Devices and
Systems, PDS’2004, Cracow, Poland, November 18th -
19th, 2004, pp. 121-125
Mikoś Z., Wróbel G., Hayduk G., Kwasnowski P., Jachimski
M., Zygmunt H. (2009), Środowisko ISaGRAF do
tworzenia rozproszonych aplikacji sterowania i regulacji,
in Systemy czasu rzeczywistego. Postępy badań i
zastosowania, WKiŁ, Warszawa, pp. 43-62 (in Polish)
OpenGL (2010), The Industry's Foundation for High
Performance Graphics, http://www.opengl.org/
PC_Simu (2000), http://personales.ya.com/canalPLC
PLCSim (2007), S7-PLCSim V5.4 – User Manual,
A5E00992424-01, Siemens AG
RSLogix (2004), RSLogix Emulate. Getting Results Guide
Doc ID EMULAT-GR002A-EN-P, Rockwell
Automation, www.software.rockwell.com
RSLogix (2005), RSLogix Emulate 5000. Getting Results
Guide, Publication LGEM5K-GR015A-EN-P, Rockwell
Automation, www.software.rockwell.com
S7_200 (2000), http://personales.ya.com/canalPLC
TrySim (2010), Cephalos Gesellschaft für Automatisierung
mbH, http://www.trysim.de/en/
Unity (2007), Modicon M340 PLC Automation Platform
Unity Software, DIA6ED2061001EN-US, Schneider
Electric, www.us.telemecanique.com