ELSEVIER
Copyright © IF AC Programmable Devices and Systems, Ostrava, Czech Republic, 2003
IFAC PUBLICATIONS www.elsevier.comllocalelifac
SOFTWARE INDUSTRIAL CONTROLLER - "SOFT PLC" Miroslaw CHMIEL Edward HRYNKIEWICZ Adam MILIK Krzysztof ZAK Institute of Electronics Silesian Technical University. Akademicka 16; 44-100 Gliwice; Poland
[email protected];
[email protected]
Abstract: The paper presents state of work carried over Logic Controller assembled with standard PC computer and remote object units. Presented system is equipped with software package that allows programming of control algorithms with use of Ladder Diagram and execution of programmed algorithm. Some PC machine can be used for program development. system control and monitoring. Copyright © 2003 IFAC Keywords: PLC, Distributed I/O group, Software PLC, LAD
1. INTRODUCTION Since the 80's Programmable Logic Controllers were used with a grate success in the domain of industrial controllers. They have replaced relay control systems, analogue regulators and even minicomputers. New ideas and solutions made PLCs more versatile than ever.
Since the 90's personal computers are used to programming PLC and to edit documentation of control programs. PLCs also become more complex and advanced offering work in large computer networks. Dynamically developing and growing software packages for Supervisory Control and Data Acquisition (SCADA) are the reason for trends in development of PLCs. SCADA systems are the top most layer of control system. Those systems complement and extend capabilities of PLCs. Following function can be carried out by SCADA systems: • Data acquisition, processing and archiving that are directly obtained from controllers system • Reporting current state of plant and equipment, use of supplies and other useful management reports • Visualisation of controlled industrial processes in graphical way • Alarm and warning generation caused by limit value exceeding • Collecting data useful for optimal production control and management.
Quick modification and adaptation to applications demands was achieved by easier programming without need of hardware modification. Commonly it is thought that increasing number of PLC application was caused by: • Similarities in ladder diagram used in PLC programming to schematic diagrams of relay and switch based control systems • High and continuolJ.Sly rising reliability of industrial computers that can operate in severe industrial condition and environments • Programmatically supervised tests and diagnostic of controlled inputs and outputs and system diagnostics. • Design of specific set of instruction that takes into account industrial specific condition of control program execution • Human Machine Interface (HMI) that allows to communicate PLCs with operator panels, displays, personal computers and other devices in order to support external supervision of control and production process.
The paper presents an idea of PLC that uses PC computer as computing unit. Popularity, availability and versatility of PC computers made us to try it in control application. Software PLC is not quite new solution and some manufacturers offer similar constructions [Legierski et al 1998][Michel G. 1992]
7
-
[Berger H. 1989]. Presented solution in comparison to standard hardware PLCs is as follows: Advantages: • Low cost, controller and software editor located on the same computer • Small number of components required to build control system: 1. PC computer - main unit 2. Dedicated communication card for PC 3. Remote 110 modules • Easy to configure and start Disadvantages: • Long response time is caused by long time of main loop execution. PC processor better operates on words or bytes then on single bits. Bit operations and manipulations are time consuming. Long distance serial transmission also consumes a lot of time. Typical PC isn't suitable to work in severe industrial condition • Reliability of such system is lower than typical hardware PLCs. In order to assure similar level of reliability special real time operation system (RTOS) on PC platform must be used. 2.
!
Converter \'---,/1 RS232-RS485
1/'-----'\1
Power supply & transmission
Next group
Fig. I. Physical architecture of soft PLC neighbourhood of controlled plants and equipment. Both parts of system are connected with use of transmission line according to RS-485 standard. Connection is made with use of twisted pair of wires. Central unit is dedicated to execute control algorithm according to prepared ladder diagram. Control algorithm can be edited and debugged in main computer. Main unit also monitors state of network connection during program execution. All failures and system messages are reported to system operator (presented in system console). Main unit consists of following components: • PC computer at least 486 with 2MB RAM 40MB HD and SVGA card • Bridge device RS232 to RS485 with optoisolated buffers • System printer • VGA monitor • Keyboard and pointing device.
INITIAL ASSUMPTION
Software PLC consists of software part that contains controller program and control algorithm editor as well hardware part that consists of PC machine and some additional hardware. Typical PC computer can not be used in industrial condition. Whole system was divided into two parts. System consists of central unit build from PC and remote part, which contains object inputs and outputs. Each remote group contains power supply and transmission module (PST). This is a basic module that maintains communications with main unit (PC). Each remote group can service up to five inputoutput modules card (MIO). Each MIO card is equipped with eight binary inputs and outputs.
Bridge device is responsible for standard conversion between RS-232 and RS-485 standards. In order to avoid damages of serial port in PC bridge unit is equipped with optoisolated buffers that assure electrical isolation of remote part with main computer.
Let consider system that contains 96 binary inputs, 96 binary outputs and 96 binary internal variables (markers or flags). Usually in typical modem systems number of inputs is bigger then number of outputs but there are many examples from real life that require larger number of outputs than inputs (e.g. packing machines, rake system in electrofilters). In order to simplify design and meet different control system requirement only one type of MIO card was designed with same number of inputs and outputs. In Fig. I is presented physical structure of controller. 3.
=]1
J
Remote part of controller connects controlled object with the central unit. Communication between main and remote units is established through RS-485 standard line. Remote part allows for local signal inspection, diagnostics of remote point operation and connection diagnostics. Remote part consists only from input-output groups that are connected together with transmission line
HARDWARE
Each group consists of following components: • Single module of power supply and communication bridge (PST). Power supply delivers two stabilised voltages 5 Volts and 24 Volts. Regulators can source current of 2 and 4
Hardware part is divided into two blocks that differ mainly installation location but also functionality. Main part of system is located in environment conditions that allow for proper work of typical PC computer. Object control part is placed in the nearest
8
Amperes respectively. Transmission part assure connection of group to transmission network • Up to five input-output modules (MIO) that connects controlled object with controller. Each module is equipped with 8 inputs and outputs.
75MHz clock time out can be estimated from equation (2) ... _ D ·e _16 · 10000 -213[ ] '0 - - - 6 . ms fose 75 ·10
Each group maximally can service up to 40 inputs and outputs. Limitation for number of MIO cards is caused by case of type EUROPAC-PRO that allows only placing five cards inside. All inputs of controller are designed for 24VDC industrial standard with common ground level. Input voltages in range from 0 to 5 volts are interpreted as low state on input. Voltages from 12 to 30 are interpreted as high state. All outputs are switched by relays with single common wire. Relays can work with voltages up to 250V with current up to lA.
Where: C - number of command executions D - clock cycles per command execution fose - clock frequency In case when data would not arrive during wait period it is assumed that there are communication problems. Following steps are undertaken: • Control program execution is stopped • System error command is transmitted to all cards • Internal flags are cleared • Failure signalisation on console with message of possible problem detection and occurrence time (which card has not responded).
Maximal distance between main unit and most distant component must not exceeds 1200 meters. Main unit computer is equipped with communication converter card that connects it to RS-485 network, system printer and console (VGA colour monitor, keyboard and pointing device). System can operate automatically after proper configuration and switching power on so it is not required to install console equipment. Control system has scattered construction so communication with main computer and remote modules is very important. Communication converter card realise following functions: • Serial transrruSSlOn standard conversion between RS232 and RS485 with speed of 115200 bits per second • Electrical isolation between main unit and communication network of remote modules.
Remote module communication protocol implementation is as follows : • MIO cards receive address and compare it with its unique address. When parity check fails it is asserted by blinking control indicator in front panel • When bit Presence Check is set controller immediately sends back its address and confirm its presence in system • When Presence Check bit is cleared controller waits for 277ms for next data byte. In case of next byte is not received during this period connection failure is signalised by blinking indicator on module front panel. • When data byte arrives in period shorter than 277ms from receiving address its integrity is checked. When data integrity test has passed. Received data is put to outputs. Inputs state is collected and put into 50 stages shift register. Logical and is performed on register contents and result is transmitted to main computer. Before data can be transmitted direction of data line must be reversed. Data transmission organisation takes 65 microcontroller (i8051 derivative) machine cycles.
3. 1 Data Exchange Serial Protocol Main computer that is master device exchanges data with remote components of controller that acts as slaves. During control program execution at the beginning of program loop data are exchanged with remote modules. Main computer executes following sequence of data exchange • Selection of appropriate card by sending address word. Time required for sending single 8 bit character with one start and stop bits can be calculated from equation (1) D 10 Ts =-=--=86.8[~] VT 115200
(2)
'I = D ·e = 12 · 65 =705[) o fose 11,0592 . 106 ,~
(3)
Where: C - number of cycle D - number of clock cycles per machine cycle fose - oscillator frequency When received by MIO card address doesn't match its unique address next data transmission is ignored for time of about 80ms. It is protection against interpreting transmitted data as an address byte.
(1)
•
Address byte is followed with output data byte. Data transmission time is described by equation (1 ). • When address and data bytes are transmitted main computer waits for remote module response. As response is send input state of module. Main computer waits for response for about ten thousand machine cycles. For Intel Pentium with
Data exchange total time between PC machine and MIO card is calculated in equation (2)+(3)=(4)
9
Counter is a counting up unit triggered with rising edge of an input signal. Counting range covers up 3 decades from 1 to 999 pulses. Number of counted pulses is compared with assigned count limit value. Counter is set to 0 when count limit value is reached or a dedicated clear input of the counter become active. In ladder diagram counter is denoted with string "CNT".
Tw =315 +To =3 ·86,8.10-6 +70,5·10-6 = 330,9[JlS](4)
With use of profiler tool number of required machine cycles were calculated fOf computing: • single network computation takes 15k cycles that takes (5) TA = D·e = 16 . 150?0 = 3,2[ms]
fose
•
Software PLC programming environment doesn't allow for subprogram creation. All functions in current project are executed one by one in closed loop. Network sheet number determines computation order. Time required for single loop run is calculated during program design. Execution time depends on number of configured MID cards and number of network sheets. Currently there is not implemented mechanism that checks one loop execution time during normal operation ofthe controller.
auxiliary procedures for all networks independently from its number takes 50k cycles Tp = D · e = 16 ·50000 = 100ms] 6 75.10 fose
•
(5)
75 · 10
(6)
single loop execution time depends on number of used MID cards, number of network pages and can be derived from equation (7)
Rules of the controller operation are based on ladder diagram analysis performed by PC computer. MID modules through RS-485 network and specific communication bridge supply all required computation arguments.
(7)
Where: L - number of MID modules
N - number of network pages Calculated times will be shorter when we have better PC computer. 4.
5.
MAIN UNIT ALGORITHMS AND FUNCTIONAL DESCRIPTION OF SOFTWARE PACKAGE
Software package of main unit contains not only controller functionality but also ladder diagram editor and diagnostic tools. Ladder diagram editor allows preparing network diagrams or modifying already existing. Diagnostic functionality checks remote hardware part of controller and network connection. It is useful in determining any problems with remote units or communication network. During normal operation of the controller following information can be retrieved: • System operation time since last start • All system variables (inputs, outputs, flags) can be watched • Calculated maximal loop execution time • System messages queue with time of its occurrence (e.g. system start, communication lost with card, system stop attempt)
CONTROLLER FUNCTIONAL DESCRIPTION
Most of industrial control process belongs to group of on-off control type. Designed controller works only on discrete variables. It is enough to meet requirements of most industrial application. Control program is implemented with use of ladder diagram (LD). This method was chosen by practical consideration. This is commonly used and is said to be most convenient and communicative programming method than the others by programmers and maintenance stuff. [Chmiel et al 2002] Logical functions are computed as sum of products. Each product has up to ten variables while logical sum can merge up to ten product outputs. Realisation of logical function is similar to PAL circuit architecture. Controller is able to execute up to 100 logical functions placed on separate network pages.
System is automatically started up after power is turned on. This eliminate need of external supervision to minimum. Intelligent MID cards equipped with achieved increased operation safety also: • Watchdog timer protection against unpredicted behaviour • Transmission of control signals to the controlled object • Signal acquisition, sampling and analysis on module inputs • Failure detection of remote units.
Each function independently from used arguments or number in network pages collection can contain additional component just before its output (when all logical calculation are completed) like timer or counter. Timer component delays the switching on time in time range from 0.1 to 99.9 seconds. Time measure accuracy is better than 0.1 second. In ladder diagram editor cell containing timer is marked with string "TMR".
Software package on PC computer consists of two programs:
10
• •
Ladder diagram editor SOFT PLC that enables creation and edition of ladder di;grams Run time control process program PROCESS that executes given ladder diagram.
5.2 PROCESS Software Logic Controller System
PROCESS execution begins from system diagnostics. All crucial for control program execution components are being tested. Test starts from communication check between main unit and required remote modules. After completing all tests execution of control algorithm can be started. In case that card or remote module is missed system fail command is send to all modules that are present. In this case remote modules open all controlled circuits and remain in fail state. Main unit is placed into alarm state and waiting. In alarm state main unit continuously monitors state of network and checks of missed modules. When for presence communication is re-established and seems to be stable normal operation of controller can be restored. Control program starts from fail safe point. Other possibility of leaving fail state is return to SOFT_PLC and manual diagnostic of system. When all faults and damages are repaired system can be manually placed into normal operation.
Both programs can operate independently from each other. Designed by SOFT]LC ladder diagram is stored in file that than is used by PROCESS as a control algorithm. 5.1 Ladde r diag ram editor (SOFT_PLC)
This program works in graphical mode. After starting a computer it is loaded and executed. Based on information written to configuration files start up of program is executed. When auto start mode was previously selected controller start sequence IS executed. Following steps are executed: • Number and connection of MIO cards is determined • Required MIO cards addresses are enumerated • Maximal time for single loop run is calculated.
In normal operation mode before diagram analysis begins data from remote modules are gathered in main unit. When all required input data are collected analysis of ladder network can be started.
All those system configuration information and ladder diagram structures are written to input file for PROCESS program. When all those operation are completed PROCESS program is invoked and control process begins.
After processing all input diagnostic and auxiliary procedures are executed. Following functions are assigned to this procedures: • System time keeping functions • System clock update • Local keyboard service routine • System state graphical visualisation • System variable presentation (if this option was requested in configuration data).
In case that auto start option was not activated program SOFT_PLC remains in edit mode after reading configuration file. SOFT_PLC is designed as program and system configuration editor. In program is implemented editor of ladder diagrams. Not only is it used to program edition but also to verification and validation of physical layer of controller. Number of required MIO card and their addresses are determined and validate. When control program is being edited information about available controller resources are dynamically recalculated. Designer continuously can monitor number of available network pages, free inputs, outputs and internal variables (internal flags). Single loop run time is also on-line estimated.
Then computation results are transmitted to remote MIO cards. This end single loop run. When last step is completed computation cycle is a new started. Single network sheet is computed row by row. When whole row is computed and logical value of operation is calculated and placed in last row. Then logical value of next row is calculated. When calculation of all rows in network is completed logical or operation is performed on partial results that were previously obtained. Calculation structure resembles PAL circuit architecture that consists of 10 terms. Each term has 10 independent inputs. Final result of network computation is send to actuator. Between switch network and actuator can be placed timer or counter component. Those components allow to obtain in easy way complex time and sequential dependencies in control algorithms.
Some options that influence work of PROCESS can be controlled from SOFT]LC program. Auto start option and variables monitoring can be turned on or off through menu of SOFT]LC. Variable monitoring is kind of debug options that reduces computation speed of controller but is useful during design time. In release version that is fully tested can be switched off.
Network row analysis is not optimal solution but is very easy to program. Some optimisation rules were worked out that accelerates calculation of final results. Following rules based on Boolean equations evaluation were applied:
11
resistant). Other components of remote module also meet industrial requirements.
•
Analysis of current row is abandoned when first unfulfilled condition is met (logical and with constant 0) • Next row analysis are abandoned when currently completed row have value of logical 1 (logical or with constant 1) • Network page analysis is abandoned when there is not actuator or actuator is undetermined.
Developed software package is easy to use. Graphical interface is highly communicative and allows almost intuitive programming. Diagnostic procedures assure fail-safe behaviour of controlled system in case of any disturbances. Implemented safety procedures in main control program and in remote unit controllers brakes normal operation of controller in case of any serious problem. System is placed in fail safe state. Carried out experiment show that system behaves according to made assumptions and meets our expectation.
Detailed analysis process is presented in Fig. 2. Controller program can be stopped manually. In order to avoid unintended process stop. Before control process is stopped stop key must be pressed for at least 3 seconds. When stop request is notified by system stop request is transmitted to remote modules that must open all outputs. This state is little similar to fail state. 6.
7.
Legierski T., J.Kasprzyk, J.Wyrwal, J.Hajda "PLC Programming" (in polish) Wydawnictwo Pracowni Komputerowej Jacka Skalmierskiego Gliwice 1998 Michel G. "Programmable Logic Controllers Architecture and Applications", John Willey & Sons, 1992 Berger H. ,,Automating with the SIMATIC S5115U", Siemens Aktiengesellschaft, Berlin and Munich, 1989, Chmiel M., Hrynkiewicz E., Muszynski M. "The way of ladder diagram analysis for small th compact programmable controller", The 6 Russian - Korean International Symposium On Science and Technology, Russia Novosibirsk, Korus 2002
SUMMARY
Manufacturers of PLCs rather rarely propose construction of controllers based on PC as main computing unit of controller. Recently we have observed slightly growing interests in area of PLCs assembled from industrial PC machine with additional specific hardware. Controller system in our case was divided into main unit and object control unit that is located in closest neighbourhood of controlled engine. Object control unit is designed to work in very severe industrial condition. Case of remote unit was designed as highly resistant to industrial condition. Case meet requirements of IP-45 standard (splash and dust
column 0
column 1
REFERENCES
column 9
column 2
row 0
~
rowl
Network Arguments
row 2
row 9
Data Exchange
Auxiliary
Control Program Execution page 0
page 1
page 2
-1 :==If------1OOf----------jOO>----[!]~
Procedures page 99
"\
-[~~~~
~_______________________________P_ro_gram ____ C_YC_I_e_____________________________________~ Fig. 2. Network analysis algorithms diagram
12