Abstract:
In numerically controlling a machine tool having a plurality of movable members controlled by respective programs, the programs are automatically altered to reliably avoid collision between the movable members. Labor and time required for the operator to alter the programs are reduced.

Description:
This application is a continuation of application Ser. No. 07/423,544, filed Oct. 13, 1989, now abandoned, which is a continuation of U.S. Ser. No. 07/130,116 filed Oct. 26, 1987, now abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     The present invention relates to a method of and an apparatus for preventing tool collision to avoid interference between movable members such as a plurality of tool posts by automatically altering a machining program when such interference occurs. 
     Machine tools are numerically controlled for automatically machining workpieces. To machine a workpiece to a design drawing with a numerically controlled machine tool, numerical control commands in a prescribed format, i.e., a machining program, must be input to a numerical control apparatus. 
     A machining program for such a numerical control apparatus makes it possible to control a multi-axis for moving two tool posts, i.e., tool rests, independently to enable the two tool rests to cut the workpiece simultaneously. For example, a four-axis lathe shown in FIG. 4 has two tool rests TP1 and TP2 and moves the tool rests TP1 and TP2 independently along X- and Z- axes for machining a workpiece WK. By controlling the positions and paths of these tool rests TP1 and TP 2 according to a machining program comprising independent programs for the respective tool rests, the workpiece WK can be machined to a desired shape in a much shorter period of time than would be possible with an ordinary two-axis lathe. 
     Since, however, the single workpiece WK is simultaneously machined by the two tool rests TP1 and TP2, an accident may possibly occur due to interference between the tool rests TP1 and TP2. The machining programs for the respective tool rests should be of such a nature that they will prevent collision of the tool rests TP1 and TP2. To check such an interference, an actual machining process according to the machining programs to be checked is simulated on an animated screen. A tool interference checking process is effected by visually observing a simulation and determining that a collision or interference is caused when the paths of movement of the two tool rests intersect each other. The machining program includes a program for a tool rest 1 and a program for a tool rest 2 as shown in FIG. 3(a). Denoted in FIG. 3(a) at N100, N101, N102, N103, ... are data items for numerically controlling the movement of the tool rest 1, that is, blocks of a format of numerical control commands, and N200, N201, N202, N203, ... are blocks of a format of numerical control commands for numerically controlling the movement of the tool rest 2. FIG. 3(b) illustrates the paths of movement of the tool rests 1 and 2 displayed on the animated screen of a display unit during simulation of an actual machining effected by executing the tool rest programs. As shown in FIG. 3(b), the path of the tool rest 1 crosses the path of the tool rest 2 in the block N102 for the tool rest 1 and the block N202 for the tool rest 2. It can therefore be confirmed on the display screen that the tool rests 1 and 2 will actually collide with each other at the intersection of the tool rest paths, as shown in FIG. 4. 
     As described above, it has heretofore been known to effect a tool interference checking process by simulating an actual machining process according to a machining program on a display screen and checking the tool rests for their mutual interference. If an interference occurs in the tool interference checking process, then the program is altered or corrected manually by the operator. Therefore, the operator is required to think each time an interference happens, or always understand accurately, what part of the machining program is to be revised and how it is to be modified. Therefore, much labor and time have been needed in preparing a machining program. 
     SUMMARY OF THE INVENTION 
     It is an object of the present invention to provide a method of and an apparatus for preventing tool collision to avoid a tool interference in advance by automatically altering a machining program when tool rests interfere with each other during machining simulation on an animated display, through the utilization of a conventional tool interference checking process on an animated display. 
     According to the present invention, the conventional problems are solved by a method of preventing tool collision, including the steps of simulating and displaying the paths of movement of a plurality of movable members driven by respective independent programs in advance of an actual machining process, selecting the movable member to be moved first and the movable member to be stopped when an interference occurs, and correcting the programs to avoid the interference between the movable members by inserting a dwelling code into the programs. 
     With the method of the invention, in the event of an interference between tool rests during machining simulation on an animated display, machining programs are automatically altered in order to avoid such an interference. Therefore, labor and time required for the operator to alter the machining programs are reduced, and actual damage to tools which would otherwise result from the execution of the machining programs can be avoided. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram of a system for carrying out a method of the present invention; 
     FIG. 2 is a schematic view of a four-axis lathe; 
     FIG. 3(a) is a diagram showing, by way of example, a machining program for a four-axis lathe; 
     FIG. 3(b) is a diagram showing an animated screen displaying paths of movement of two tool rests; 
     FIG. 4 is a view explaining an interference between tool rests in an actual machining process; 
     FIG. 5 is a diagram of system parameters required by an automatic collision prevention program; 
     FIG. 6 is a flowchart of an operation sequence of the automatic collision prevention program; 
     FIGS. 7(a), 7(b), 7(c), and 7(d) are diagrams showing, by way of example, modifications of machining programs by using dwelling M codes; and 
     FIG. 8 is a diagram showing an interference between tool rests in an actual machining process. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     An embodiment of the present invention will hereinafter be described in specific detail with reference to the drawings. 
     FIG. 1 is a block diagram showing, by way of example, a numerical control NC system for controlling a four-axis lathe. 
     Denoted in FIG. 1 at 10 is a processor for effecting numerical control by executing programs, 11 is a programmable controller for programmed execution of operation of an electric power circuit which carries out sequence control of a four-axis lathe, and 12 is a program memory storing various control programs to be executed by the processor 10. The memory 12 also stores an automatic collision prevention program for automatically altering machining programs according to the present invention. A data memory 13 stores data required for executing the programs for the processor 10 such as machining programs composed of data formats of numerical control commands. A working memory 14 serves to temporarily store the results of arithmetic operations effected by the processor 10. A paper tape puncher 15 records data on a paper tape by punching the same. A paper tape reader 16 reads numerical control commands (NC commands) punched in an NC tape. A pulse distributor 17 effects an arithmetic operation to distribute pulses according to a motion command from the processor 10 and issues distributed pulses commensurate with the commanded amount. Denoted at 18x1, 18z1, 18x2, and 18z2 are servo circuits for driving tool rests TP1 and TP2 in the directions of X- and Z-axes by controlling the X1 and Z1 axes and X2 and Z2 axes of a four-axis lathe 19. A parameter memory 20 stores system parameters required for executing the automatic collision prevention program. A display controller 21 has input keys for setting the system parameters and the like. A display unit 22 serves to display the paths of movement of the tool rests on an animated screen as shown in FIG. 3(b). An address data bus (hereinafter referred to as a &#34;bus&#34;) 23 allows data to be transmitted between the processor 10 and the memories 12, 13, 14 and 20, and an input/output device. 
     The automatic collision prevention program stored in the program memory 12 will be described with reference to FIGS. 4 through 6. 
     During simulation of an actual machining process according to machining programs, and if an interference occurs (shown in FIG. 3) between the tool rests TP1 and TP2 (shown in FIG. 2) in a block N102 for the tool rest 1 and a block N202 for the tool rest 2, as shown in FIG. 4, the automatic collision prevention program automatically inserts dwelling M codes into prescribed positions in machining programs in order to move the tool rest of higher priority at first and temporarily stop the tool rest of lower priority. In order to start executing the automatic collision prevention program it is necessary for system parameters as shown in FIG. 5 to be preset. 
     The system parameters include a tool rest priority parameter, a dwelling M code parameter for stopping movement of a tool rest and determining the interval of stoppage of the tool rest, and a repetitive execution parameter for determining whether a machining program is to be repeatedly executed until no interference occurs. An initial value for the tool rest priority parameter is &#34;0&#34;. If the tool rest priority parameter is &#34;0&#34;, the operator can set it to &#34;1&#34; or &#34;2&#34; when an interference occurs between the tool rests during execution of the machining programs. When the priority parameter is &#34;1&#34;, the tool rest 1 has higher priority, and when the priority parameter is &#34;0&#34;, the tool rest 2 has higher priority. The stoppage interval of the dwelling M code parameter has an initial value of &#34;200&#34;, and can be selected in the range of from &#34;100&#34; to &#34;999&#34;. The repetitive execution parameter has an initial value of &#34;0&#34;. When the repetitive execution parameter is &#34;0&#34;, dwelling M codes are automatically inserted into prescribed positions in the machining programs, and then the machining programs are rewound to restart the machining programs from the beginning. When the repetitive execution parameter is &#34;1&#34;, a dwelling M code is automatically inserted into prescribed positions in the machining programs, and then the machining programs are rewound to stop program execution. 
     If the above system parameters are properly established, the automatic collision prevention program will be executed according to the flowchart shown in FIG. 6. 
     Machining programs to be checked are prepared in the data memory 13 in step (1) by entering the machining programs through the tape reader 16, for example. Thereafter, in step (2) the four-axis lathe 19 is switched to a memory mode, i.e., a mode in which the programmable controller 11 and the pulse distributor 17 are disconnected from the bus 23 in FIG. 1, for data transfer only between the data memory 13 and the display controller 21. Then, an animated screen is displayed on the display unit 2, in step (3) and the machining programs are started from their first addresses to begin simulation of an actual machining process in step (4). The machining programs are successively executed block by block in step (4). Whether an interference has occurred between the tool rests is checked during the execution of the machining program in step (5). If no interference is caused, then control returns to step (4) and the machining programs are executed. If an interference is experienced, then control goes to step (6) which ascertains whether the priority parameter is &#34;0&#34; or not. If the priority parameter is not &#34;0&#34;, then it is &#34;1&#34; or &#34;2&#34;. Therefore, a dwelling M code is inserted into prescribed positions in the machining programs, as described in detail later on, dependent on the value of the priority parameter, in step (7). If the priority parameter is &#34;0&#34; in the step (6), then an inquiry as to a priority tool rest is displayed on the display unit in step (8). The operator then enters, in step (9) through a key, a tool rest priority parameter &#34;1&#34; or &#34;2&#34;. Then control goes to step (7). After the dwelling M code has been inserted in step (7), the machining programs are rewound back to their first addresses in step 10. Whether the repetitive execution parameter is &#34;0&#34; or &#34;1&#34; is ascertained in step (11). If the respective execution parameter is &#34;0&#34;, then the execution of the machining programs is completed in step (12). If the respective execution parameter is &#34;1&#34;, control goes back to step (3) to execute the machining programs again. 
     Step (7) will be described in detail with reference to FIGS. 7(a) through 7(d). 
     In the event of an interference shown in FIG. 4 with the tool rest 1 having higher priority than the tool rest 2 (i.e., if the priority parameter is &#34;1&#34;), the automatic collision prevention program automatically inserts a dwelling M code M201 after the block N102 of the machining program for the tool rest 1 and before the block N202 of the machining program for the tool rest 2, as shown in FIG. 7(a). When the machining programs thus corrected are executed again, the tool rest 2 is stopped during a period specified by the dwelling M code M201 while the tool rest 1 is moving under a numerical control command of the block N102. Therefore, the tool rests are prevented from colliding with each other. The dwelling M code is inserted after the block N102 of the machining program for the tool rest 1 because synchronism should be kept between the block N103 of the machining program for the tool rest 1 and the block N202 of the machining program for the tool rest 2. 
     Conversely, when the tool rest 2 has higher priority than the tool rest 1, (i.e., when the priority parameter is &#34;2&#34;), a dwelling M code M201 is automatically inserted before the block N102 of the machining program for the tool rest 1 and after the block N202 of the machining program for the tool rest 2, as shown in FIG. 7(b). 
     If a dwelling M code M201 is inserted when the priority parameter is &#34;1&#34; as shown in FIG. 7(a), and if, after the machining programs are executed from their first addresses, there is an interference occurring in the block N103 of the machining program for the tool rest 1 and the block N202 of the machining program for the tool rest 2, then, as shown in FIG. 7(c), a dwelling M code having a different period than that of the dwelling M code N201, e.g., a dwelling M code M202, is inserted after the block N103 and before the block N202, and the dwelling M code M201 is deleted. With this modification, while the blocks N102, N103 are being executed, the tool rest 1 is stopped during the period specified by the different dwelling M code M202 for avoiding collision between the tool rests. 
     Where a dwelling M code M201 is inserted when the priority parameter is &#34;1&#34; and the machining programs are executed again from their first addresses, if an interference occurs between the tool rest 2 stopped after the execution of the block N201 and the tool rest 1 moved by the execution of the block N102, as shown in FIG. 8, then the inserted dwelling M code M201 is deleted, and a dwelling M code having a different period than that of the dwelling M code M201, e.g., a dwelling M code M202, is inserted after the block N102 and before the block N201. While the tool rest 1 is moving according to the blocks N101 and N102, the tool rest 2 is stopped in its initial position and hence prevented from interfering with the tool rest 1. 
     Therefore, the automatic collision prevention program can automatically prepare a machining program which is free from the danger of interference during an actual machining process by automatically inserting a dwelling M code into prescribed positions in machining programs, through the use of a tool interference checking process utilizing an animated screen. 
     The present invention is also effective in preparing a machining program which prevents collision between movable members of a general NC machine tool in addition to a four-axis lathe as described above. Many changes and modifications may be made in the present invention without departing from the scope of thereof. 
     According to the present invention, as described above, the paths of movement of movable members such as a plurality of tool rests are displayed on an animated screen for simulating an actual machining process and checking the tool rests for their mutual interference. If an interference occurs on the screen, then the machining programs are automatically altered to avoid any interference in the actual machining process. Therefore, the machining programs can be rewritten with utmost ease, and tools can relially be prevented from damage.