Program debugging device and process

Abstract: A process and a device for debugging a sequentially executed program, such as an SFC program having a plurality of blocks containing a plurality of steps, wherein a desired program route (51) is registered in a normal route table (9), by block and step identifier, and used as a basis for comparison with the program as it is actually run by block and step, and recorded in an executed route table (10). Where a difference is identified, the program run may be either stopped and the current block and step displayed, or the program may continue its run and each identified difference be recorded in a faulty route table (11), for later display.

Description: BACKGROUND OF THE INVENTION Field of the Invention The present invention relates to a device and a process for debugging a program to be run by a programmable controller. Description of the Background An SFC (Sequential Function Chart) indicates a programming language which allows a program running procedure and conditions to be represented clearly by dividing the sequence of a program into a plurality of steps in a flowchart format. An SFC may be utilized to represent a program for a programmable controller (hereinafter referred to as the "PC") which program-controls an object to be controlled. The development of a debugging device and a debugging process that facilitates more effective program writing is desired in order to permit the SFC type program to be used in a wide variety of applications. A "step break method" is one of the conventional debugging processes used with a debugging device for SFC-based programs in PC applications. Fig. 10 is a block diagram illustrating a CPU module of the PC and a peripheral device for writing a program for the PC, for debugging the program written, for monitoring the program when it is run, and for other purposes. In Fig. 10, the numeral 1 indicates a CPU module of the PC, comprising an input section 2 through which data is entered from other modules (not illustrated), an operation section 3 for performing data operations, an output section 4 for outputting data to other modules (not illustrated), a power supply section 5 acting as the power supply of the entire module, an SFC program storage 6 for storing an SFC program, and a data storage 7 for storing data incoming from a peripheral device 8 and exchanging information with the SFC program storage 6. The peripheral device 8 has a structure to perform a program writing function, a written program monitoring function and a debugging function, and includes a step break information table 12 for storing information on step breaks for program debugging. Fig. 11 shows the contents of the step break table 12 comprising block numbers 12A, break step numbers 12B and cycles 12C. Fig. 12 gives an SFC program example, and Fig. 13 is a flowchart illustrating a step break processing procedure. As shown in Fig. 12, the SFC program is made up of blocks 20 to 24. Each block includes at least (i) an initial step 30, which indicates the beginning of the block; (ii) basic steps 31, which are basic units within a block comprising execution units of the SFC program; (iii) transition conditions 32, which are the conditions of transition to the next step; (iv) block driving steps 33 for starting another block; and, (v) an end step 34 for declaring that a series of block processings has been completed. The group from the initial step 30 to the end step 34 is referred to as a "block". In a current program environment, a maximum of 256 blocks, e . g ., (0) to (255), can exist in a SFC program. Conventionally, block (0) is referred to as a "main block" 20, from which the run of the SFC program begins. Within any of the blocks, another block may be specified by a user at the block driving step 33 and the run of the program will shift to the specified block. In the initial step 30, at basic steps 31 and transition conditions 32, the corresponding detailed sequence programs of a PC may be written using ladders or the like. As shown in the SFC program example of Fig. 12, the main block 20, i . e ., Block 0, includes a selective branch 35. The selective branch will execute only a step where a transition condition has been first enabled among a plurality of steps 31 connected in parallel. Also included is a selective connection 36 for terminating the processing performed by the selective branch 35. In an operation of the program, beginning with the main block 20, step (1) is first executed, after the step (1) 31 is executed, a selection processing is performed because of the transition condition 32. The condition leads to four block driving steps (1) - (4). By executing any one of the block driving steps (1) to (4), any of the routes starting from corresponding Block (1), (2), (3), or (4) is executed. When any of the Blocks (1), (2), (3) and (4) has been selected, the steps in the selected block are executed in order from the initial step 30 to the end step 34. When the end step 34 has been executed, the program execution returns to the initial step 30 of Block (0) and forces a block driving step 33 to be executed starting from the next transition condition. After any of the steps (2), (3), (4) and (5) has been executed, the step (6) is processed. When the end step 34 is executed, the execution returns to the initial step 30 again and the series of operations is then repeated. Instead of the above simple description of the SFC, a more complex operation may be conducted, as would be apparent to one of ordinary skill in the art. The establishment and operation of a step break process, one of the known debugging processes, will now be described in reference to the flowchart shown in Fig. 13 and the illustrations in Figs. 10-12. In the establishment of a step break process by the peripheral device 8, a start is first effected at step 200. Any previously existing step break information is read from the data storage 7 of the PC CPU module 1 into table 12 of the peripheral device 8, at step 201. Then, at step 202, the user determines whether or not totally new data on step break points ( i . e . a whole new table) are to be registered into the step break information table 12 or whether simple additions or corrections alone are desired. When totally new data are to be registered, at step 203, the user registers in table 12 the block numbers 12A at which a break is desired to occur, the step numbers 12B at which a break is desired to occur, and the numbers of cycles 12C after which a break is desired to occur at the specified step. The new data are registered in place of the previously written data in the step block information table 12, which was read from memory 7 at the step 201. If the user determines that all new data are not to be registered, then the process proceeds directly to step 202A. At step 202A, a determination is made as to whether or not corrections should be made to the existing data. When only corrections are to be made to the existing data, the user corrects, at step 204, the block numbers 12A at which a break is desired to occur, the step numbers 12B at which a break is desired to occur, and/or the numbers of cycles 12C after which a break is desired to occur at the specified step. When corrections are not made to the existing data, or after completion of step 204, the contents of the step break information table 12 are then written into the data storage 7 of the PC CPU module 1, at step 205. The processing of the PC CPU module 1 is then performed. First, the step break operation is started at step 206 and the PC program is run. The operation section 3 compares, at step 207, the data in the data storage 7, i . e ., the blocks 12A and steps 12B in the step block information table 12, with the current run state of the SFC program stored in the SFC program storage 6, i . e ., the current blocks and steps. If they do not match, the step 207 is repeated until they match. When they match, the step break operation is stopped at the corresponding step, at step 208, to terminate the processing. The blocks 12A, the steps 12B in those blocks and the numbers of cycles 12C which are step break points registered into the step break information table 12, may be set as required. Ordinarily, the step break points should be provided at important points on a route, other than a normal route in order to check for a deviation from the normal route. However, the step break points may be strategically provided on a normal route to confirm that the normal route has been executed properly, thereby enhancing the debugging of the SFC program. For example, assume that the step break information table is established as shown in Fig. 11 and is operative with respect to the SFC program in Fig. 12. Also assume that during the program's first cycle, it passes to Block 2; in the 2nd cycle, it passes to Block 3; and, in the 3rd cycle, it passes to Block 4. If the above sequence is the "normal route", then break points would be set on step 1 of each of Blocks 1, 3 and 4 in the 1st cycle, because a deviation form the "normal route" through Block 2 is to be detected. Also, for similar reasons, break points are set on step 1 of each of Blocks 1, 2 and 4 in the 2nd cycle. For a different reason, explained subsequently, a break point is set on step 5 of Block 0 in the 3rd cycle. Thus, if a step break operation is performed when step break points are set on the above step break information table, and if it is run normally, step break will not occur either in the 1st or 2nd cycle, but it will occur at step 5 of Block 0 in the 3rd cycle. Specifically, a step break will occur after Block 4 is performed and thus it is confirmed that up to the 3rd cycle, the program is run normally. Nonetheless, the extensive use of step break points for debugging will result in programming inefficiencies. For example, when using the conventional SFC program debugging process as described above, a step break must be set at each pertinent branch point to check the route passed per branch processing in an SFC program. This causes the number of set breaks to increase as the number of branch processings increases, resulting in a cumbersome debugging process for the SFC program. Document US-A 4 183 462 discloses a method and an apparatus for diagnosing a fault in a sequence control system performing control in accordance with a predetermined sequence. A signal detector is provided for detecting the presence of a sequence step as it occurs. The step detected in real times is compared to a program sequence pre-registered or stored in a sequence memory. However, the steps are not stored for later comparison purpose. Document EP-A-0 407 295 discloses a procedure for observing the execution of a control program. Said document does not give the teaching of storing a normal route in a table. Moreover it does not assign pointers to normal route blocks of the control program and to specified normal route steps within said blocks. It is, accordingly, an object of the present invention to overcome the disadvantages in the conventional process by providing an SFC program debugging process which does not require step break setting and ensures ease of checking executed routes. SUMMARY OF THE INVENTION The present invention provides an SFC program debugging device and process which allows routes on which an SFC program runs normally to be registered beforehand, an actual route on which the SFC program is running to be registered sequentially, the actual run route to be compared with the pre-registered normal route at the termination of a series of runs, and the different block and step in the SFC program to be displayed as an error. This and other objects are solved in advantageous manner basically by applying the features laid down in the independent claims. Further enhancements are provided by the subclaims. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a block diagram illustrating a PC and a peripheral device acting as an SFC program debugging device according to the disclosed embodiments. Fig. 2 shows the contents of a normal route table illustrated in Fig. 1. Fig. 3 gives an SFC program example. Fig. 4 is an SFC program debugging processing flowchart according to which the run of the SFC program is stopped if any difference is found in the comparison of normal and executed route tables. Fig. 5 shows the contents of an executed route table illustrated in Fig. 1. Fig. 6 shows the contents of a faulty route table illustrated in Fig. 1. Fig. 7 gives an SFC program example illustrating second and fourth embodiments, respectively. Figs. 8 and 9 comprise an SFC program debugging processing flowchart according to the present invention. Fig. 10 is a block diagram illustrating a conventional PC and peripheral device. Fig. 11 shows a conventional step break information table. Fig. 12 shows a shown SFC program example. Fig. 13 is an SFC program debugging processing flowchart according to a conventional step break method. DESCRIPTION OF THE PREFERRED EMBODIMENTS The first embodiment will be described with reference to Figs. 1 to 4, wherein like reference characters employed in the conventional system designate like or corresponding parts therein. Fig. 1 is a block diagram illustrating a peripheral device 8'serving as a PC monitoring device equipped with an SFC program debugging function of the present invention. The configuration of the PC CPU module 1 is identical to that of the conventional system shown in Fig. 10. In Fig. 1, the numeral 8' indicates a peripheral device, which includes a normal route table 9 for storing normal routes, an executed route table 10 for storing executed routes, and a faulty route table 11 for storing faulty routes. Fig. 2 shows the contents of the normal route table 9 which consists of pointers P , identified by number 9A, normal route blocks 9B and normal route steps 9C. Fig. 3 provides an SFC program example, where path 51 represents a sequence of operation, and Fig. 4 is a processing flowchart. Operation will now be described in accordance with the processing flowchart in Fig. 4. This debugging processing is performed only by the peripheral device 8' of the PC and the description of the operation focuses on peripheral device 8'. First, execution is started at step 100. Before the monitoring of the SFC program is initiated, at step 101, the contents of the normal route table 9 corresponding to a block currently being displayed are read from the peripheral device 8'. The table output may be displayed to the user. At step 102, the user reviews the displayed data and decides whether or not a normal route block 9B and/or a normal route step 9C in the current normal route table needs to be newly registered. If the user decides that a new registration is required, the new data are added at step 103. For example, if the SFC program shown in Fig. 3 follows the route 51 during a normal run and would further proceed to step 31, the registration of this new information in the table 9 can be made. Specifically, the user registers Block (0) 20 and step 31 so that the normal run is extended according to the new data in the normal route table 9 of the peripheral device 8'. When the user has decided at step 102 that new registration is not required, then the user must decide at step 102A, whether or not block or step data should be corrected. If corrections are required, the user makes, at step 104, a correction to the block and step on route 51 where a normal run is made in the normal route table 9 of the peripheral device 8'. If at step 102A corrections are not required, the process proceeds to step 105. Although not shown in the flow chart, the addition or correction of new data can be performed on a loop basis, if multiple additions or corrections are required. The peripheral device 8' then gives a remote run command to the PC CPU module 1 at step 105, and starts monitoring the PC CPU module 1. When the monitoring is initiated, the value of the pointer 9A corresponding to the data in the normal route table 9 is first set to 1 at step 106. At step 107 the peripheral device 8' commands execution of a step within a block by the PC CPU module 1. The peripheral device 8' compares, at step 108, the block and step currently being executed by the PC CPU module 1 with the normal route block 9B and normal route step 9C of the pointer 9A in the normal route table 9 of the peripheral device 8'. If they match, the pointer 9A in the normal route table 9 is incremented by 1 at step 109 to refer to the next normal route step 9C. At step 110, it is decided whether the execution of the current step in the current block has been completed. If the step has not been completed, at step 110A, it is decided whether it has gone beyond a predetermined time (time up). If it has not exceeded the predetermined time, then it goes back to step 110, and repeats the above processing. If it has exceeded the predetermined time, the executed circuit will be displayed at step 112. When execution of the step has been completed, i . e ., when the currently executed block or step has changed, this change is detected at step 110. Then, the peripheral device 8' determines, at step 111, whether or not the step currently being executed by the PC CPU module 1 is the end step 34 in the current block i . e . block (0) 20. When it is not the end step 34 in the current block, the execution returns to the step 108 for further processing. The flowchart remains in the loop 110, 110A until the program proceeds to the next step for execution by the CPU, which should be the normal route block and step identified by the current portion in table 9. When it is the end step 34 in the current block, the process moves to step 114 and the peripheral device 8 gives a remote stop command to the PC CPU module 1 and stops the monitoring of the PC CPU module 1 and the processing is terminated at step 130. If the block and step currently being executed by the PC CPU module 1 are different from the normal route block 9B and normal route step 9C then identified by the pointer 9A in the normal route table 9 of the peripheral device 8' at the step 108, the circuit of a transition condition 32 preceding the different step 31 is displayed at step 113. The CPU remote stop and monitoring stop of step 114 is executed and the processing is terminated at step 130. The invention will be described in accordance with Figs. 1 to 3 and Figs. 5 to 9. Fig. 5 shows the contents of the executed route table 10 which consists of pointers I in 10A,executed route blocks 10B and executed route steps 10C. Fig. 6 provides the contents of the faulty route table 11 comprising error numbers 11A, faulty route blocks 11B and faulty route steps 11C. Fig. 7 gives an SFC program example and Figs. 8 and 9 comprise a processing flowchart of the second embodiment. An SFC program debugging procedure according to the second embodiment will be described with reference to the processing flowchart in Figs. 8 and 9 and the structures of Figs. 1, 2, 5 and 6. First, at step 101, the contents of the normal route table 9 corresponding to a block currently being displayed are read from the peripheral device 8' of Fig. 1, before the monitoring of the SFC program is initiated. At step 102, when the user wishes to newly register a normal route block 9B and a normal route step 9C to the normal route table 9, the user registers the required data to the normal route table 9 of the peripheral device 8 as shown in Fig. 2 at step 103. Thereafter the program proceeds to step 102A. Also, if no new data are to be added, the program proceeds directly to step 102A. At step 102A, a determination is made as to whether data are to be corrected. If data are to be corrected, the user makes a correction to the normal route table 9 of the peripheral device 8' at step 104 and proceeds to step 105. If no new data or corrections are to be made to the normal route table 9, the flowchart proceeds to step 105. The peripheral device 8' gives a remote run command to the PC CPU module 1 at step 105, and starts monitoring the PC CPU module 1. Steps 100 to 105 are identical to those in the processing flowchart of the first embodiment illustrated in Fig. 4. When the monitoring is initiated, the block and step currently being executed by the PC CPU module 1, as on a route 52 in Fig. 7, are first stored into the executed route table 10 of the peripheral device 8' as shown in Fig. 5. Assuming that currently Block (0) 20 and step 0 of Fig. 7 are being executed, the table at pointer I (0,0) will be completed. Next the loop which is made out of steps 116 and 116A is executed, i . e ., at step 116, the step in the block which is currently executed is performed and if it has not been completed, at step 116A it is determined whether a predetermined time has passed since the start of the execution (time up). If the currently executed step of the current block has been completed at the step 116, i . e ., execution has changed to step 1, the peripheral device 8' determines, at step 117, whether or not the step currently being executed by the PC CPU module 1 is the end step 34 in the current block, e . g ., Block (0) 20. If the execution has not yet reached the end step 34 in the current block e . g ., Block (0) 20, it returns to step 115 and repeats the processing. When the end step 34 has been executed by the PC CPU module 1 at the step 117, the peripheral device 8' gives a remote stop command to the PC CPU module 1 at step 119 and stops the monitoring of the PC CPU module 1. If at step 116A the execution of the current step has exceeded a predetermined time, a "time up" alarm is displayed at step 118 and the processing moves to step 119 for a stop. When the monitoring has been stopped at step 119 of Fig. 8, the value of the pointer 9A corresponding to the data in the normal route table 9 and that of the pointer I 10A corresponding to the data in the executed route table 10 are set to 1 at step 120 of Fig. 9. Then, the peripheral device 8' compares, at step 121, the normal route block 9B and normal route step 9C of the pointer 9A in the normal route table 9 of the peripheral device 8' with the executed route block 10B and executed route step 10C of the pointer 10A in the executed route table 10 of the peripheral device 8'. When they do not match, the unmatched executed route block 10B and executed route step 10C of the pointer 10A in the executed route table 10 are stored into the faulty route table 11 as shown in Fig. 6 at step 122. At step 123, a check is then made to see whether the data of the normal route table 9 and those of the executed route table 10 are both final. With the exception that either or both of the data in the normal route table 9 and executed route table 10 are final, at the step 123, the pointer 9A in the normal route table 9 and the pointer 10A in the executed route table 10 are incremented by 1 at step 124. In this manner, the tables now will refer to the next normal route block 9B/normal route step 9C and executed route block 10B/executed route step 10C. After the pointers have been incremented, the execution returns to step 121 and repeats the processing. When either or both of the normal route table 9 data and executed route table 10 data are final at the step 123, a check is made to see whether data exist in the faulty route table 11 at step 125. When data exist, the contents of the faulty route table 11 are shown on a display (not illustrated) of the peripheral device 8 and the processing is terminated. The preferred embodiments of the invention have been described with respect to SFC programs but may be applied to other programs such as ladder-type programs, as would be understood by one of ordinary skill. Although this invention has been described in at least one preferred form with a certain degree of particularity, it is to be understood that the present disclosure of the preferred embodiments has been made only by way of example and that numerous changes in the details and arrangement of components may be made without departing from the scope of the invention as claimed.

Claims: A program debugging device comprising: normal route registering means (9) which routes are registered beforehand on which a program runs normally in a programmable controller (1) for program-controlling an object to be controlled; program running means (3) for running the program; executed route registering means (10) for determining the steps of the route actually run by the program; route comparing means (1) for sequentially comparing the normal run route registered beforehand and the actually run route (52); and displaying means for displaying the faulty portion (11) of the program which is found to be different in the route comparison carried out by the route comparing means, characterized in that said normal route registering means comprises a normal route table (9) in which first pointers (9A) are assigned to predetermined normal route blocks (9B) and to predetermined normal route steps (9C) within each normal route block (9B) along the normal route, said executed route registering means comprises an executed route table (10) in which the executed route blocks (10B) and executed route steps (10C) of the actually run route (52) are registered at assigned second pointers (10A), said route comparing means (1) are adapted to perform the sequential comparison after the program run has been completed, wherein the predetermined normal route block (9B) and normal route step (9C) at the first pointers (9A) of the normal route are compared with the executed route block (10B) and executed route step (10C) at the respective second pointers (10A), recording means are provided for recording differences at respective third pointers (11A) assigned to respective faulty route blocks (11B) and faulty route steps (11C). The device of Claim 1, wherein the program is a sequential function chart (SFC) program, comprising normal route blocks (9B) made up of a plurality of normal route steps (9C). The device of Claim 1 or 2, wherein the displaying means are adapted to display the respective normal route block (9B) and normal route step (9C) where a difference is identified. The device of any of Claims 1 to 3, wherein the normal route registering means (9) comprise means for registering new route portion information and correcting existing registered route information. A program debugging process comprising the following steps: a) registering (101-104) beforehand a normal route (52) where a program, having a plurality of normal route blocks (9B), runs normally in a programmable controller (1) for program-controlling an object to be controlled, the normal route being registered in a normal route table (9) under first pointers (9A) assigned to predetemined normal route blocks (9B) and to predetermined normal route steps (9C) within each normal route block (9B) along the normal route; b) actually running (105-130) the program and sequentially registering (115) the executed route on which the program is actually run, the executed route being registered in an executed route table (10) in which the executed route blocks (10B) and executed route steps (10C) of the actually run route are registered at assigned second pointers (10A); c) after completion of the program run in step (b), comparing (120, 121) the pre-registered normal route and the executed route on which the program has actually run, wherein the predetermined normal route block (9B) and normal route step (9C) at the first pointers (9A) of the normal route are compared with the executed route block (10B) and executed route step (10C) at said assigned second pointers (10A); d) recording (122) differences at respective third pointers (11A) and displaying each faulty route block (11B) and faulty route step (11C) at which a difference is identified as a result of the comparing step. The method of Claim 5, wherein the registering step (101-104) comprises at least one step of adding new program data (102, 103) and correcting existing program data (102A, 104). The method of Claim 5 or 6, wherein the comparing step (120, 121) is conducted until either the normal and/or executed route data are concluded (123, 125, 126), and the recording and displaying step (127) is conducted thereafter. The method of Claim 5, 6 or 7, wherein the program is an SFC program comprising normal route blocks (9B) made up of a plurality of normal route steps (9C), and said displaying step comprises displaying as an error (129) the faulty route block (11B) and faulty route step (11C) of the executed SFC program route (52) for which a difference from the pre-registered route is identified. The method of any one of Claims 5, 6 or 7, wherein the program comprises a faulty route block (11B) and faulty route step (11C) and the displaying step comprises displaying the faulty route block (11B) and faulty route step information (11C) recorded in the recording step. The method of any one of Claims 5 to 9, wherein the program running step is subject to time limits on the execution of each program portion (116-118). The method according to any of Claims 5 to 10, wherein the program is a ladder program.

Inventors: MASAYUKI TANIGUCHI, MASAYUKI, TANIGUCHI, Masayuki, Taniguchi, c/o Mit. Denki Mekatoronikusu
Applicants: MITSUBISHI ELECTRIC CORP, MITSUBISHI DENKI KABUSHIKI KAISHA
Application year: 1992
Main classification: G06F11
IPC codes: G05B19, G06F11