Priority is claimed on Japanese Patent Application 2003-280506 filed Jul. 25, 2003.
This invention relates to simulation aid tools and ladder program verification systems, as well as program products.
Programmable logic controllers (PLC) are commonly used as a control device in factory automation. Such a PLC is usually comprised of a plurality of units of various kinds combined appropriately together such as a CPU unit for carrying out calculations according to a control program, an input unit connected to input devices such as sensors and switches for receiving their on/off signals therefrom as input signals, an output unit connected to output devices such as actuators and relays for transmitting output signals thereto, a communication unit connected to a host apparatus or the like for exchanging data therewith and a power source unit for supplying power to these units. The PLC thus structured is adapted to cyclically repeat processes such as taking input signals inputted through the input unit into the I/O memory of the CPU (the so-called IN-refresh process), performing logical calculations on the basis of a control program which is created by using the preliminarily registered ladder language (the calculation process), transmitting the results of such a calculation process to the output unit by writing them in the I/O memory (the OUT-refresh process), and thereafter making communications with a host apparatus or a display device connected to the network (the so-called peripheral service processes).
Prior to the start of an actual operation, however, it is necessary to carry out a preliminary verification process in order to ascertain whether the control program will operate correctly. Such preliminary verifications are usually carried out without actually using the equipment, the control program being tested as a desk research such that the number of adjustment steps to be actually carried out at the site (such as program corrections and editing) can be reduced. According to one of the currently carried out test methods, an input signal is provided from a simulator device to a PLC incorporating the control program to be verified. Such a simulator device may be adapted to generate a test input signal for the PLC and to have it inputted to the PLC but a separate program (written, say, in the ladder language) for generating an input signal for the test is necessary for the simulator device to have inputted to the PLC. In the past, such a program for generating a test input signal was created manually. Recently, however, attempts are being made for improvements in order to reduce the manpower required for the creation of such a program. Japanese Patent Publication Tokkai 10-133717, for example, disclosed a method according to which several basic ladder circuits are preliminarily prepared according to a representative pattern of the inspection test and stored in a memory. A scenario means is provided to arbitrarily select one of these several basic circuits and its prosecution sequence and the contents of input/output data are manually set such that a ladder program can be automatically created by reading out a necessary ladder circuit from the memory by the scenario means. The labor for creating a ladder program for simulation can be somewhat reduced by such a method.
By prior art methods of preliminary verification, however, the ladder program for test input was created manually and hence a programmer with a skill in ladder programming was required. In particular when a complicated test is required, a high level of skill is frequently required. Especially where the ladder program to be tested has a large number of input interfaces, the ladder program for test input may become enormous and it becomes cumbersome to create such a program for test input, requiring an increased number of preparatory work steps. By a method of using preliminarily stored basic ladder circuits to create a ladder program for simulation, on the other hand, only tests within a limited range can be carried out and those tests not intended by the basic ladder circuits cannot be carried out. If any test outside the intended range is desired, it becomes necessary to create a new program manually.
Moreover, prior art methods could only ascertain whether or not the control program would correctly function when input signals were correctly inputted in a correct sequence but were incapable of checking the operations when an input signal different from a normal signal was inputted. Since they cannot stop the program execution being carried out on the PLC, furthermore, the test cannot be interrupted in its midst and hence the result of any instantaneous result change could not be ascertained.
It is therefore an object of this invention to provide a simulation aid tool, a ladder program verification system and a program product capable of automatically creating a ladder program for test input by automatically extracting variables for test input from the target control program to be tested.
A simulation aid tool according to this invention may be characterized as comprising a variable extracting part for analyzing a ladder program to be tested and extracting variables, including input variables, used in this ladder program, a test input sequence managing part for managing a test input sequence describing a table that correlates command, variable name and normal input value of each of the input variables in the extracted variables in the order of test input, and a test input ladder generating part for generating a test input ladder program according to the test input sequence created by the test input sequence managing part.
According to this invention, a test input sequence is created by arranging input variables in the order in which they are executed and a test input ladder program is automatically generated according to this test input sequence. In other words, the test input sequence is arranged in the order of test input and is in the form of a table that correlates normal values, etc. of each of the input variables. Thus, a ladder program for these input variables can be created by placing junction points having the normal values of these input variables as the input condition. Since they are listed in the order of input, a test input ladder program for outputting input signals can be easily created by arranging these ladder circuits in the order of input.
Thus, since the test input ladder can be created without being conscious of ladders, even a mechanical designers without the knowledge of ladder can carry out tests of a high level. Since variables to be inputted can be easily picked up even from a long and complicated ladder, the number of test design steps can be reduced. If the logic for checking the result is buried on the test input ladder, furthermore, even an instantaneous change in the result can be made detectable.
In addition to the above, there may be further provided a variable managing part for storing the variables extracted by the variable extracting part by classifying into input variables and output variables and storing the input variables in correlation with values that can be assumed as test input values and a test input pattern managing part for referencing the test input values stored in the variable managing part and creating and managing a test input data pattern including an abnormal pattern having an abnormal value which is not a normal value set as a test input value of a specified input variable in test input sequence such that the test input ladder generating part is adapted to generate the test input ladder program based on the abnormal pattern. If a test input ladder program can thus be created on the basis of an abnormal pattern, it becomes possible to check the operations not only under normal conditions but also at the time of occurrence of an abnormal situation. It becomes possible also to automatically create a ladder program for continuously carrying out a plurality of test cases such as abnormal cases and this makes it possible to conduct unmanned tests.
The ladder program contains a plurality of programs (component programs) structured in units of modules. The aforementioned test input sequence managing part creates a test input sequence in units of these modules for each of the programs and may preferably be provided with a module test sequence importing part for importing the test input sequences thus created thereby in units of modules to a test input sequence of the whole ladder program so as to be synthesized. This embodiment is preferable because the test input sequences created in units of modules can be utilized when the test input sequence for the entire control program is created.
A ladder program verification system according to this invention may be characterized as having a network connecting a virtual I/O (which is a programmable controller for generating virtual I/O having installed therein the test input ladder program created by the simulation aid tool of this invention as described above) and a programmable controller (hereinafter “the programmable controller”) for executing a test target program (which is a ladder program to be tested) and wherein the virtual I/O is adapted to execute the test input ladder program to obtain test input signals and to sequentially transmit the test input signals to the programmable controller through the network, and the programmable controller is adapted to obtain the test input signals and to execute the test target program based on the obtained test input signals. With a ladder program verification system thus structured, a ladder program can be preliminarily verified by using an automatically created test input ladder program for a test input such that time control can be effected and the same test can also be repeated easily.
The ladder program verification system may be further so structured that the simulation aid tool and the virtual I/O are network-connected, that the simulation aid tool is adapted to download the generated test input ladder program to the network-connected virtual I/O, and that the virtual I/O is adapted to execute the downloaded test input ladder program and to output the test input signal. In the above, the network that connects the simulation aid tool and the virtual I/O and the network that connects this virtual I/O and the programmable controller which executes the test target control program may be the same or different. If they are the same, the simulation aid tool will also be able to upload the test target control program from the programmable controller.
A program product according to this invention may be characterized as comprising a first program part for carrying out a first process of analyzing a test target ladder program and thereby extracting variables that are used in the ladder program, a second program part for carrying out a second process of managing a test input sequence describing a table that correlates command, variable name and normal input value of each of input variables in the extracted variables in the order of test input, and a third program part for carrying out a third process of generating a test input ladder program according to the test input sequence created in the second program part.
In summary, variables for test input are automatically extracted from a control ladder program such that a test input ladder program is automatically generated. Thus, even a user such as a mechanical designer without any knowledge of ladder can carry out a test of a high level.
The invention is described by way of an embodiment for carrying out a preliminary verification of a control program incorporated in a PLC which is the target of a test where there is no sensor or other input devices present or under a condition where the factory automation system as a whole is not functioning and no input signal is being provided from any of the input devices even if they are present.
In order to carry out this verification, an input signal must be provided to the target PLC at a specified timing. According to the present embodiment, this input signal for the verification is generated by another PLC (which is hereinafter also referred to as the “PLC for generating virtual I/O” or merely the “virtual I/O”). This PLC and the target PLC are connected by a network so as to allow communications therebetween and the input signal is generated by causing a verification program (the “virtual input ladder program”) to be executed by this PLC for generating virtual I/O and is communicated to the target PLC. The verification program is preliminarily created and downloaded to the PLC for generating virtual I/O. The test is carried out as the PLC for generating virtual I/O provides the generated input signal to the target PLC at a specified timing and the target PLC executes the control program to be tested on the basis of the received input signal. Verification whether the operation is carried out normally or not and debugging are carried out on the basis of this result.
Some of the control programs mounted to the PLCs 5 may comprise function blocks. A function block is comprised of input and output parameters, internal data and a program code and is written with a quadrangular body part at the center, an input part on the right-hand side of the body part and an output part on the left-hand side of the body part. The body part is a program for a block of actions and is created separately by the ladder language.
According to this invention, a simulation aid tool 1 for generating a virtual input ladder program for providing verification input signals to the target PLCs 5 to be tested, a PLC for generating virtual I/O (the “virtual I/O PLC”) 2 for outputting a test input signal at a specified timing by executing a virtual input ladder program created by this simulation aid tool 1, an action monitor 3 for monitoring the conditions of the target PLCs 5 during the operation test or the test results and the target PLCs 5 for testing are all connected to the same network. Thus, the simulation aid tool 1 functions to create a virtual input ladder program on the basis, for example, of the target control program to be verified mounted to the target PLC to be tested and to download the created program through the network 6 to the PLC 2 which is to become the virtual I/O generating simulator (the “virtual I/O”). The virtual I/O PLC 2 executes the downloaded virtual input ladder program to thereby output the input signals through the network 6 to the target PLCs 5 to be tested at a specified timing.
As the target PLCs 5 to be tested receive the input signal from the virtual I/O PTC 2 at the specified timing, they carry out the control program sequentially. The conditions during the execution of the test program and the result of the execution can be monitored by the action monitor 3. In other words, the action monitor 3 can collect and display the data stored in the IO memories of the target PLCs 5 to be tested and thereby check their operations. Alternatively, a 3D simulator may be separately activated within the action monitor 3 so as to have the action of a robot or the like controlled by the PLCs 5 displayed on the image screen on the action monitor 3 as in a virtual space based on the collected data such that its motion can be checked.
The simulation aid tool 1 for creating a virtual input ladder program may be realized by installing an application program with specified functions in a personal computer. Such a personal computer may have other tools with different functions also installed. Its structure may be as shown in
In
In the case of a control program composed of a plurality of component module programs, module data are managed for each of the component module programs by a module data managing part 12. The module data include a list of input-output variables for the module (“variable data”), a module ladder program (“ladder”) and test sequence and test pattern data set at the time of the testing (“test set data”). The module data managed by this module data managing part 12 are also obtained by uploading from the PLC 5, as done by the test target ladder managing part 11. The module data managed by the module data managing part 12 may be transmitted to another processing part when called by the test target ladder managing part 11.
Variables defined in the test target program are managed by a variable managing part 13. Input variables, output variables and inner variables are separately managed within the range of test target. For the convenience of explanation, let us assume that a total system control program as shown in
When both the action command and the action condition are switched on, the total system control program outputs a clamp action signal (out/return) and, after the action, it is completed at the timing when the end LS (limit switch) is switched on. As the whole system, the action of clamp 1 is started when both a device action command and a device action condition are switched on and the action is completed when the action of clamp 1 is completed.
The variable managing part 13 classifies all variables defined in the test target program into input variables and output variables within the test target range. A list with the structure of a table as shown in
Of the variable data managed by the variable managing part 13, the variable names and the data types are extracted by an I/O variable extraction part 14. In other words, it is this I/O variable extraction part 14 that serves to obtain the test target ladder program through the test target ladder managing part 11 and to extract the input variables by analyzing its contents. Explained more in detail, the ladder program is scanned for all variables defined by the test target ladder and those used as output variables are classified as an output variable and those not used as such are classified as an input variable. For example, if the total system control ladder is as shown in
The operations of the I/O variable extraction part 14 are carried out as shown by the flowchart of
For each extracted part, it is then determined whether it is used in an output command (Step ST3) and it is classified as an output variable (Step ST4) if it is used as an output command (YES in Step ST3). If it is not used as an output command (NO in Step ST3), it is determined whether it is used in an input command (Step ST5). If it is found to be used in an input command (YES in Step ST5), it is classified as an input variable (ST6) because this means that it is being used only in an input command. If it is not being used either in an output command or in an input command (NO in Step ST5), it is eliminated from the variable list (Step ST7).
The routine described above is repeated until all variable names have been classified (YES in Step ST8).
Of the data managed by the variable managing part 13, the input values to be taken by input variables other than the Boolean variables are inputted by a test set inputting part 15 adapted to receive test set data inputted by the user. If the user operates a mouse to make an input, it is transmitted to the variable managing part 13 as the test input value so as to be stored therein in correlation with the corresponding variable name.
The test set sequence indicative of the test input sequence of the input variables defined by the user is managed by a test input sequence managing part 16 adapted to obtain the input variables extracted by the I/O variable extraction part 14, to reference the sequence of their execution in the target ladder program to be tested and to create a test input sequence as shown in
The test input sequence and the test result check timing for the test input are described by using a script language. In other words, the sequence commands and operands of IN, CHECK and CALL are described. The operand of the IN command is an input variable, and this command is for inputting data to the input variable. Since the variable selection can be made from the input variable list, a selection which is easy and not likely to cause an error can be made. The operand of the CHECK command is an output variable and this command is for checking a change in the output variable against input data. Since the variable selection can be made from the output variable list, a selection which is easy and not likely to cause an error can be made. The operand of the CALL command is a sequence name and this command is for calling a test sequence which is separately defined. A test sequence may be made into a structure by means of this command. Although
The input data pattern managing part 18 has the function of creating test input values for an abnormal pattern based on a test sequence with a normal pattern as shown in
It is by such functions, for example, that the variables described in a sequence are outputted for a display and the user selects a list of variables with which it is desired to create a combination pattern.
The input data pattern managing part 18 functions as shown in the flowchart of
Next, test input data on specified variables are obtained from the variable managing part 13 (Step ST12). In the case of a variable of an other-than Boolean data type, all data on input values that can be taken (20 and 30 in the case of Device action speed in the example of
Next, the number N of the variables of which the value is to be changed from the default value is set equal to 1 (Step ST13). A pattern is formed by changing the input value from the default value (that is, the value set in the normal pattern) for N of the specified group of variables (Step ST14). The pattern thus created is registered in the input data pattern managing part 18 (Step ST16), which serves to manage test input patterns for variables described in test input sequences, if another identical pattern is not already registered (NO in Step ST15). If there is another identical pattern already registered (YES in Step ST15), the program does not do anything. In this manner, an abnormal pattern with at least one variable with an input value which is not normal is created.
It is then examined whether or not all patterns combining N variables different from the default values have been created (Step ST17). If they have not (NO in Step ST17), a new pattern (that is, another pattern with the input values of N variables other than those changed in Step ST14 set at values different from the default values) is created (Step ST19) and the program returns to Step ST15. If this pattern is not registered yet (NO in Step ST15), it is registered in the input data pattern managing part 18.
If ail patterns have been created (YES in Step ST17), if the value of the dummy index N at this moment agrees with the number of variables for which creation of pattern has been specified (Step ST18). If they agree (YES in Step ST18), the program is ended because this means that all abnormal patterns have been created. If they do not agree (NO in Step ST18), the value of the dummy index N is incremented by 1 (Step ST20) and Step ST14 and the steps thereafter are repeated with the incremented value of N. In this manner, all abnormal patterns having only one of the specified variables is set to a value different from the default value are created, all abnormal patterns having any two of the specified variables are set to values different from the default values are created, etc. such that the number of variables to have values set differently from the default values is increased by 1 each time, until an abnormal pattern with all specified variables taking a value different from the default value is created such that all abnormal patterns that are to be created can be created.
Consider the sequences shown in
Next, since N is set equal to 2 (Step ST20), Steps ST14 and ST19 are carried out with this new value of N such that abnormal patterns with two of the specified three variables set to a value different from the default value are created and registered.
Thereafter, N is set equal to 3 and Step ST14 is carried out with N set equal to 3, creating an abnormal pattern with all three specified variables set to a value different from the default value. Since the judgments in Steps ST17 and ST18 become YES in this situation, the process for creating abnormal patterns is now ended. In all, seven abnormal patterns are thus created by the input data pattern managing part 18.
According to the embodiment of the invention described in
For this purpose, the user specifies a range for importation from the module test sequence, thereby indicating the position where the total system sequence currently being set should be imported, and outputs a request to import. In response, the variable managing part 13 checks whether the variable written in the operand of the IN command of the module test sequence is an input variable or an inner variable in the total system ladder. After this checking is done, the IN command having the variable made into an inner variable is replaced in CHECK command.
If it is desired to reuse a test sequence for “clamp 1 module” when the total system ladder test sequence shown in
Next, the destination position of the total system test sequence specified by the user is obtained (Step ST22). In the example of
Next, the test sequence data in the specified range of the test set data corresponding to the module specified from the module data managing part 12 are read out (Step ST23) such that the sequence commands on each line of the module test sequence data which have been read out are obtained (Step ST24).
It is then examined whether or not the sequence command defined in the obtained line is IN command and the described variable is an inner variable in the total system ladder (Step ST25). If these conditions are satisfied (YES in Step ST25), IN command is changed into CHECK command (Step ST26) and it is inserted into the total system sequence (Step ST27). If the described variable is not an inner variable (NO in Step ST25), the line which has been read out is inserted into the total system sequence (Step ST27).
It is then examined whether or not all of the lines within the specified range have been inserted (Step ST28). If there is a line which has not been inserted (NO Step ST28), the program returns to Step ST24 to carry out the next cycle of steps on the next line. By thus repeating Steps ST24 to ST28, all sequence lines within the specified importation range can be inserted into the desired positions in the total system sequence.
Final test data as shown in
The final test data (with input data patterns (normal and abnormal patterns) added to test input sequence) shown in
The function of the virtual input ladder generating part is explained next with reference to the flowcharts shown in
Next, each processing part is explained to describe the process for creating the ladders. The ladder corresponding to the IN command in Step ST21 is created by executing the flowchart shown in
If an IN command has been detected (YES in Step ST42), another IN command with an identical operand is searched for (Step ST43). In other words, a step for switching the same variable on or off is searched for.
Regarding all of the IN commands referenced in Steps ST41 and ST43, corresponding pattern values are obtained from the input data pattern managing part 18 to check whether there are inputs of changes OFF→ON and ON→OFF (Step ST44). If there is an input of change OFF→ON (YES in Step ST45), the ON-part of a self-hold circuit is created on the basis thereof (Step ST46). If there is an input of change ON→OFF (YES in Step ST47) the OFF-part of the self-hold circuit is created on the basis thereof (Step ST 48). A self-hold circuit corresponding to an input variable is completed by combining the ON-part and the OFF-part thus created in Steps ST46 and ST48 (Step ST49). Next, it is determined whether or not there is an IN command in the steps subsequent to the detection in Step ST41 (or Step ST50 in the previous cycle after the second time) (Step ST50). If such an IN command is found to be present (YES in Step ST42), a self-hold circuit is created by executing the processes after Step ST43. The steps described above are repeated to a ladder circuit is created corresponding to all of the IN commands.
Next, the process of creating a self-holding circuit described above will be explained for “clamp 1 out LS1” of Step No. 12 and “clamp 1 out LS2” of Step No. 13 as examples.
For each pattern, the timing for the switch OFF→ON is detected and the pattern number and the sequence step number are grouped together with the AND-condition. The timing for the switch ON→OFF is similarly detected for each pattern and the B junction point of the pattern number and the B junction point of the step number are grouped together with the AND-condition. Thereafter, the circuits corresponding to the OFF→ON timing grouped for all patterns are grouped together with an OR-condition and the circuits corresponding to the OFF→ON timing are grouped together with an AND-condition to create an input ladder corresponding to one input variable.
In the case of “clamp 1 out LS1”, for example, since it is switched from OFF to ON at Step No. 12 of the normal pattern, pattern 1 and step number 12 are connected in series (AND) to form a ladder circuit which becomes the ON-part of the self-hold circuit. Since it is switched from ON to OFF at step number 12 of Pattern 2 (during occurrence of abnormality), step number 12 of Pattern 3 (command no-input), etc., an AND connection is formed with the B-junction points of the corresponding pattern numbers and step numbers. In this manner, a self-hold circuit as shown in
The ladder corresponding to the CHECK command of Step ST33 is created by carrying out the flowchart shown in
If a CHECK command is present (YES in Step ST52), a corresponding check value is obtained from the input data pattern managing part 18 and the A junctions or the B junctions are combined corresponding to the check values with an OR-condition (Step ST53). Junction points corresponding to the step numbers are added with an AND condition to complete a check circuit (Step ST54). Thereafter, the CHECK command is searched for in the subsequent steps (Step ST55). This is done by determining whether a CHECK command is present or not in the subsequent steps since the detection in Step ST51 (or the previous Step ST55 at the second or later time). If the CHECK command is present (YES in Step ST52), the processes thereafter are repeated.
After all CHECK commands have been referenced (NO in Step ST52), a step shifting circuit is created (Step ST56) and this series of processing is completed. A virtual input ladder as shown in
In the step where the CHECK command is described, it is checked whether the operand has been changed to its value. If the CHECK value is ON for each pattern, the pattern number and the variable to be checked are grouped together with an AND-condition (Pattern 1 & clamp action command) and if the CHECK value is OFF, the pattern number and the B junction point of the variable to be checked are grouped together with an AND-condition (Pattern 2 & clamp action command and Pattern 3 & clamp action command). Thereafter, the grouped circuits of all patterns are grouped together with an OR-condition and the step numbers where a CHECK command is described are added with an AND-condition.
When the CHECK condition in this ladder is satisfied, a flag indicative that a step is in execution, outputted from the ladder, is switched off and this process is completed.
The IN command proceeds unconditionally to the next step but the CHECK command proceeds to the next step only when the CHECK condition is satisfied. In other words, the shift takes place at the timing when the coil is switched off while the step describing the CHECK command is being executed. This may be realized by a ladder circuit as shown in
The process of ladder creation corresponding to the CALL command in Step ST34 may be carried out according to the flowchart of
If a Call command is present, an execution/non-execution value is obtained from the input data pattern managing part 18 and junction points corresponding to the pattern set for execution are grouped together with an OR-condition (Steps ST62 and ST63). In the subsequent steps, thereafter, the CALL command is referenced (Step ST64), that is, it is checked whether a CALL command is present or not in steps after Step ST64. If a CALL command is present (YES in Step ST62), the processes in and after Step ST63 are carried out.
If no CALL command is found although the final line has been reached (NO in Step ST62), a step-shifting circuit is created (Step ST65) and this series of processing is concluded. As this series of processing is carried out, a ladder circuit as shown in
A pattern for executing the CALL may be added by an OR-condition in order to stop until the start flag of the sequence to be called and the sequence execution end flag of the sequence to be called are switched on. As is clear from
When the junction point for the execution of initialization sequence is switched on, the virtual input ladder circuits created on the basis of the called initialization sequence are sequentially executed. When the last of the circuits is executed (when the execution end flag of the called sequence is switched on), the execution of this step is considered completed. Although not shown graphically, a virtual input ladder program can be created by the virtual input ladder generating part 20 also on the basis of the called initialization sequence shown in
Shifting to the next pattern is carried out after the last line of the present pattern is carried out. Since the execution of the next pattern is started from the first step number, a ladder program that checks whether the execution has been concluded to the last of the defined steps (Step No. 17) and then shifts the pattern to be executed to the next pattern is created. For example, a circuit as shown in
The virtual input ladder program thus created by the virtual input ladder generating part 20 is downloaded to the virtual I/O 2 through the network 6 by means of a loader 21.
Although an example has been shown wherein a virtual input ladder program is created based on a normal pattern and an abnormal pattern, this is not intended to limit the scope of the invention. It is sufficient if the virtual input ladder program is created at least based on a normal pattern.
Number | Date | Country | Kind |
---|---|---|---|
2003-280506 | Jul 2003 | JP | national |