Copyright @ IFAC Programmable Devices and Systems, Ostrava, Czech Republic, 2000
PROGRAM STRUCTURE AND DIAGNOSTIC ASPECTS IN APPLICATIONS APPLIED IN PLCs
Andrzej NOWARA, Miroslaw CHMIEL
Institute ofElectronics, Si/esian Technical University, Gliwice, Poland e-mail:
[email protected]
Abstract: The main task of control program loaded in any PLC is to ensure proper functionality of the designed machine or technological line. From the diagnostic and maintenance point of view the same program is to ensure fault detection, machine status check and machine restart to be done with ease. Such aspects are connected with many items, one of the most important is program structure. Intention of the authors is to present some remarks regarding different program structures, programming aspects, which support users and maintenance to detect and cover faults and stoppages. Copyright © 2000 IFA C Keywords: control applications, diagnostic, programmable logic controllers, programs, structured programming
1. INTRODUCTION
manufacturer or supplier establishes the program modules - Siemens S5, S7 (Berger, 1989; Simatic S7· 400.. , 1998; STEP7 Reference Manual, 1996) or it is a result of logical partition introduced by a programmer - Omron C series (C200H.. , 1994).
In most cases automation of the industrial production lines is performed by applying Programmable Logic Controllers (pLC) which a dynamic growth can be noticed in the recent years. Such devices complement relay based as well as computer aided control systems. The main advantage of PLC is their flexibility as far as changing control conditions are concerned.
The main task of control program loaded in PLC memory is to ensure the proper functionality of the designed machine or technological line. Usually, the same program is used to do tests of functionality, to do diagnostic, to modify and improve program and to learn. This is a basic requirement of the effective diagnostic and maintenance. From this point of view there are some aspects which are to be considered during program creating. One of the most important one is program structure. The others are documentation, symbols, signal definitions, programming technique.
Creating industrial applications comprises some phases, including a definition of control conditions, definition of I/O list, hardware configuration and software preparation. Usually, the two last items are performed using computer aided software tool, which defines user's environment. This software is equipped with the test and diagnostic functions either and becomes an integrated part of the system. In such environment user creates the program and its structure, makes modifications, makes tests and commissioning. Program structure is a consequence of the design and functionality of the PLCs because
Some remarks on different program structures, programming aspects that support users are given in tillS paper.
161
but also as a set of instruction creating logical structure, some important advantages referenced to fault analyse can be achieved.
2. PROGRAM STRUCTIJRE AND DIAGNOSTIC WHY SO IMPORTANT? Control systems comprise both hardware and software. Software consists of the operating system of programmable device, control program and user interface. After installation and commissioning of such systems the job of the supplier and programmer(s) is finished. The system is handovered to the user and starting from this time it is his responsibility is ensure the proper functionality and to diagnostic in case of faults. In general it is relatively difficult to write the control program in such way, that the idea of full diagnostic and fault recognition is implemented using typical interface like operator panels or HMIs where each signal and combinations of signals are checked to display the direct reason of faults. The software "amount" calculated in number of bytes or words only for diagnostic purposes is greater than software written to control the machine. Additional work time is to be considered as well.
3. PROGRAM STRUCTURES OVERVIEW The base for the creating of different program structures is PLC and its design and functionality. In general it is module configuration oriented device and there are two basic elements in hardware structure: a CPU together with a memory and I/O modules (Gilles, 1990). The PLC memory contains system software as well as user control programmes written in a form of series of instructions executed by the CPU in a cyclic scanning way. Cyclic scanning way of processing implies very important feature of the PLC. it means there is a certain fixed time after which the action for the specified events is observed accordance to control algorithm. The concept of processing using interrupts is applied in PLCs as well, but usually it does not play the basic role in control application. The background is that interrupt mechanism can mask some events what can result as delayed reaction of system.
The other possibility is to analyse the control functions written in control program. In such approach the control program has to fulfil extended requirements. Basically, the additional requirements are related to program structure. The program structure implies such aspects like transparency, analyse of result of logical operations, signal state check, signal state force possibilities and they are the basic actions done by users to recover the run mode of the controlled machine in case of breakdowns. The most important criterion for this approach is diagnostic time to investigate the root cause of problem and it results as breakdown time. This criterion determines the efficiency of the maintenance, and especially in case of production lines it has a fundamental importance.
There are 4 basic structures applied in control programs: • linear • hierarchical • Sequence Function Chart - SFC • Processes Linear structure._Linear program corresponds to way of program processing method performed by PLC. Such a program seems to be suitable for small applications and program content can be displayed on a few screens computer. The basic advantages of this structure are simplicity, functionality of machine is easily understandable, and signal states and results of control functions can be checked with ease. These features are consequence of the consolidation of the control program in one program module.
The other criterion is time required to recover the run mode of the machine, it means to restart the machine. Usually there is a predefined state of the machine described as "start position" and from this position the machine can be restarted with ease and safety. But time needed to reach this position from any state for all elements of the complex machine can be unexpectedly long. If there are more such predefined positions states entered to the control programs the mentioned above time needed to restart is reduced significantly.
Example of linear structure implemented in Omron PLC is presented on fig. 1.
MODULE 1 LD AND NOT LD AND OR LD OUT
The last aspect related to the structure of the control application is the user understanding of the control function and control sequence in general. The influence of this aspect on already mentioned ones seems to be obvious. The mentioned aspects could be considered as examples of consequences of different approach to control programs. Interpreting control program not only as set of instructions processed cyclically by PLC
000.00 000.01 000.02 000.03 100.01
END
Fig. 1. Linear program structure.
162
MODULE1 CONO CALL pal"
MODULE 2
/
These parameters can be defined as input, output, local or transient ones and the proper signals are to be assigned when call is executed. As example of function the program module which control analog processing can be presented.
MODULE4
UNCONO CALL
pa1·w
pa3" "
UNCONO. CALL
However, usage of functions leads to potential problems regarding test and diagnostic. The reason is that the same function is called with different parameters several times and program monitoring can not provide clear information about signal states and function results because of overwriting during following calls. To avoid this some of PLC manufactures i.e. Siemens (STEP7 .. , 1996) extend the user aided software by introducing the possibility of definition of call path to trace the program structure. The other possibility is to monitor variables instead of control program (program module).
UNCONO. CALL
MODULE3
Fig. 2. Hierarchical structure of programming. Hierarchical structure. Applications written to control production stations or lines are complex programs where different types of machines are installed and different control functions are required. In such a program there is a need to break large control tasks into smaller ones written in program modules to keep the advantages of programming like in linear structure. Program understanding requires more knowledge and experience of operators and takes more time.
Sequence Function Chart (.')FC). SFC represents the behaviour of controller as a sequence of steps and transitions. Each step describes control conditions and actions to be done when conditions are activated. Transition is a set of conditions which defines when the previous step becomes inactive and the next is activated. The step represents a section of program corresponds to the actual process in the application, the transition describes when the state of the machine is to be changed.
The modules correspond with technological or functional aspects of the production process. Program execution is realised by calling and jump to nested program modules which creates hierarchical structure (fig.2). When the module is executed control returns to the calling module to the point just after the point from which the module was entered. The limitation of the nesting is coming from the operating system of PLC and is one of the system parameters.
Manufacturer with the special software package. which allows presenting the steps and transitions in the graphic way, usually supports SFC programming. This increases understanding of the functionality of the machine significantly, because the sequence control is represented in structural manner showing events, conditions and actions.
The main advantages of hierarchical structure are as follows: • programming is done more conveniently because programmer concentrates on smaller, simpler fragments • improved readiness of the program • some procedures can be used several times • modifications can be done easily knowing program structure and modules • test and diagnostic can be simpler for the same reasons like programming.
Examples of different types of graphs are presented on fig. 3.
The characteristic program elements - subprograms can be distinguished when hierarchical structure is implemented: • subroutines - enable to reuse a given set of instruction and their call can be placed in control application as many time as desired in the algorithm. i.e. the same subroutine may be called from different places in the program. The calls (jumps) are conditional or unconditional. • functions - allow a single subroutine to replace several subroutines that have identical structure but different operands (formal parameters).
Fig. 3. Examples of graphs representing SFC programming.
163
Assuming that each machine is treated as a sequence and such additional information like step number, conditions to activate the step are written using basic control instruction (AND, OR, NOT), action connected to output signal are based on activated step number, the status of the machine-sequence can be diagnosed quickly. If the understanding of the process and behaviour of the machine is known enough, SFC offers a lot of exact information needed to detect the potential cause of problems.
inside the step can be found and checks in the transparent structure.
4. REQUIREMENTS TO BE FULFILLED BY THE CONTROL PROGRAM Even in case of hierarchical structure fault detection and machine status can be easily recognised but some requirements are to be kept by programmer in phase of program creating. The below used sequence is to be interpreted as a set of steps defined to control the functionality of machine. Each machine has its own sequence.
Processes - event programming. This kind of programming is referred to interrupts processing. Definitely there are 3 kinds of interrupts implemented in PLCs: alarm, schedule (periodic or one shot) and counter (including high-speed counter). The interrupts correspond to events or tasks with high priority, what requires their immediately execution and interruption of background tasks. Such a situation occurs when strong important events are to be controlled i.e. output current is to be calculated to avoid critical overloading in RL circuit. These tasks are complimented with so-called background task. The different priority can be assigned to background tasks as well. As examples of background tasks the keyboard control and fault display can be given.
The requirements are as follows: • Program modules are to be referred to the technological process It is natural way of programming and it is consequence of control algorithm. The function of the PLC is to generate the proper operation according to the algorithm. Program modules are to be referred to the machines In case of usage of the same or similar device types in process, the requirement is only to parameterise the device for different application. The job can be done in more comfortable way having dedicated subroutine or function. •
In general the program structure for event processing is a hierarchical structure, because event procedure is to be written in a dedicated program module. Opposite to subroutines and function the jump to the module is not controlled by programmer or user but is caused by occurring or disappearing event. The indirect mechanism of memory addressing or distributed jump instructions seem to be applicable to categorise background tasks. Usually event driven programs are tracked and monitored with difficulties because the corresponding program modules are not processed cyclically. The diagnostic is extremely difficult when events occur in random way and rarely. Usually simulation of these events is required during commissioning and detailed information about functionality of such working machine is absolutely necessary.
•
Program module identification (ID, name, number) nomenclature has to be fixed It is obvious that finding the program module is much quicker when transparent rules of nomenclature are set and followed in the control application. Comments and symbols support this aspect very well. In other case the additional description (papers, files) are to be issued and available. •
Subprograms (subroutines and functions) are to be interpreted as extended instructions It means that the objective is to create the subprograms that process the set of instruction for defined input parameters and result is written to output parameters. Such interpretation of subprograms allow the user to avoid the unnecessary analyse of the content to determine whether the correspond process part or device are faulty or not.
Based on information about different aspects of programming presented above and author experience (Nowara, and Chmiel, 1998; Chmiel, et al., 1995; Chmiel, et al., 1997) the requirements to be fulfilled by the control program and the concept of the software package are described in the following chapters. The main idea is to provide the user software, which allows him to cover problems and stoppages quickly and gives the possibility to modify and extend the control functions. The chosen structure is structure based on steps and transitions. This structure ensures the possibility that the status of each device in machine can be recognised having only step number and conditions of control function
•
Subprograms which refer to the system memory are to be interpreted as "black box" This is very strong requirement and has to be kept without exceptions. Direct, indirect addressing, read, write system variables, manipulating with the operating system can be done only by experienced programmes. Usually any mistake in system address range results as stoppage of PLC.
164
points are: "go to initial position", "end of cycle", "move to point. .. ".
•
Technological areas and safety areas are to be established In general, the technological process consists of independent sub-processes, which can be treated as technological areas. The areas are hardwired as independent safety ones in sense of safety conditions and equipment (emergency stop, safety gates... ). The area selection is carried out on the operator panel with the area selection switch. The keys and lamps are assigned to the selected area respectively, control and display the status.
•
Special flags to determine step and transition conditions are to be defined Sequence conditions for the step execution can be written to the predefined flags. Based on value computed cyclically and assigned to this flag the step is executed or skipped. The flag is used to calculate the step number as well. Knowing step number the proper action is outputed by the PLC in reference to the actual sequence step. The same interpretation can be connected to the definition of the transition conditions.
•
Signals which determine machine status are to be defined The set of signal are to be defined (usually under fixed address) that describe the status for each area and machine. Typically there are operation mode (automatic. manual, step by step) and state (nm, stop, fault, synchronisation).
Usage of set and reset instruction only when necessary Set and reset instructions allow memorising the status of the machine. This can lead to dangerous situation when the status of the machine is changed in such way, that conditions for reset or set respectively are bridged. The "real" state-step and the memorised one can be different and unexpected action can be initialised. This is the reason why the set and reset instructions are to be applied carefully in the sequence control. •
•
Machine synchronisation inside areas is to be ensured Synchronisation mechanism is to be implemented to define the state of each machine and to define the pennission to start. Full synchronisation is achieved when each state-step in sequence of the machines is defined completely and allows to distinguish the state. During synchronisation process all steps are tested whether they are executable in automatic mode. Furthennore the synchronisation must be called before automatic mode is switched on.
Each fault is to be defined separately and comprehensively It is a fundamental requirement for complete fault recognition and diagnostic. •
•
Control programs points that enable save and easy machine restart have to be predefined This aspect is connected to the previous one. In case of complex sequences and large number of steps the defined and existing points from which start is done with ease and save are useful and helpful. The typical
Data blocks with parameterisation data are to be defined It was already pointed that special flags to define machine status or step and transition conditions are to be entered. There are a lot of other information required to control the sequence or group of •
~
SEQl SEQ2 SEQn
....-----.&...,
rS;;.;EQ;;;.;..l- - - - . . , SEQ2 SEQn
ACT BL
~
COND BL ~
step number
jump distributor
load STeps Ilags
.'epl: =STEP_AUTO
output acflans
=ffiANS AUTO
... =STEP_MAN ...
-mANS_MAN
slep2:
-----~ Fig. 4. Diagram of the sequence cascade structure.
165
USER BL
sequences like: total number of steps, step number, watchdog time or fixed waiting time for each step, number of active steps found during synchronisation, conditions for automatic and manual modes, status of safety circuits, co-ordinates of predefined positions. These signals are to be accessed by user continuously.
6. SUMMARY
5. SOITWARE STRUCTURE OF THE SEQUENCE CASCADE
The paper touches the very important subject connected to the programming concept, program structure, program requirements from diagnostic point of view. The author's experience shows that control programs are to be created with the scope to enable the users to do their jobs, it means diagnostic and maintenance as friendly and effective as it is possible. For this reason the control program has to support additional aspects regarding test and diagnostic besides the control functions. The basic aspect is the program structure. In this paper the authors wanted to point out its importance. Next the review of different programming structure is presented and the fundamental requirements are determined. The concept of realisation of one of the structure is described.
The proposal of the concept of the software, which is designed to follow the requirements presented above, is shown on fig. 4. The key blocks are MAIN_BL, ACT_BL and COND_BL with correspond data blocks MAIN_DB and SE~DB.
This subject is wide and extensive. It is our hope that the ideas presented and comments made will help in making better use of the PLC in industrial control systems. It could be a good starting point for further improvements and advanced ideas.
•
Symbols and comments are to be prepared in detail In general the program modules and instructions are named using mnemonics. The symbol and comments complement and extend the module names and additionally can contain information, which describes special and important program functions.
The sequence cascade is administered by the dedicated block MAIN_BL. Furthermore two program modules are assigned to each sequence COND - BL and ACT- BL. COND - BL includes conditions for step execution and transition in both automatic and manual modes. According to the operation mode of the sequence the programmed steps enabling interlocks and transition conditions are scanned. Thus it is possible to distinguish the interlocks in manual mode and in automatic mode. The sequence cascade administration block MAIN_BL supplies the status of the step flags for each sequence cascade. The sequence step flags stored in sequence database SE~DB may be used to execute actions.
REFERENCES Berger, H. (1989). Automating with the Simatic S5 115U Programmable Controllers. Siemens AG C200H Programmable Controllers. Operation Manual (1994). Omron. Chmiel, M., W. Ciazynski and E. Hrynkiewicz (1995). An Overview of Process Data Access and Program Execution Methods in PLCs. International Conference Programmable Devices and Systems PDS'95. Gliwice, Poland. Chrniel, M., A. MaIcher and A. Nowara (1997). Vertical pickling control line (in Polish). Maszyny Technologie Materialy. vol. 2, 18-19. Sigma, Warszawa. Gilles, M. (1990), Programmable Logic Controllers. Architecture and Applications. John Wiley & Sons, West Sussex, England. Nowara, A. and M. Chmiel (1998). Fuzzy Logic Control Implementation in PLCs. International Conference Programmable Devices and Systems PDS'98. Gliwice, Poland. Simatic S7-400 and M7-400 - Programmable Controllers - Hardware and Installation. Manual (1998). Siemens AG. STEP7 Reference Manual (1996). Siemens AG.
These actions have to be programmed in the ACT BL. The area definition is included in AREA_BL. The interface to the devices assigned to each area is programmed in DEVn_BL modules. The basic start conditions and operation mode are set in INIT_BL. The extended diagnostic is to be programmed in USER BL. There is a tight connection between the sequence cascade number and the program modules. All requirements listed in previous chapter are available and managed by proposed structure. Further functions like conditional jumps, branching, step skips are implemented as well.
166