Numerical control apparatus with programmable mirror image function
BACKGROUND OF THE INVENTION 
     The present invention relates to a numerical control apparatus and, more particularly, to a numerical control apparatus which can easily control a mirror image function from a program. 
     A conventional numerical control apparatus is known which has a mirror image function for inverting a shift amount instruction code of a machining program using switches on an operation panel of the numerical control apparatus, or using the program itself. In a conventional numerical control apparatus of this type, as shown in FIG. 1, a workpiece is machined to a shape AX derived from a shape A defined by points P1, P2 and P3 when a mirror is placed at a position XM along the X axis, a shape AY derived from the shape A when the mirror is placed at a position YM along the Y axis, or a shape AXY when mirrors are placed at the positions XM and XY along the X- and Y-axes. Such machining can be performed using a mirror image function without entering a shape AX, AY, or AXY instruction. 
     The conventional mirror image function, however, can only be turned on or off by a switch or a program; mirror position cannot be designated. For this reason, a shape to be subjected to mirror image processing must be shifted to a position where a mirror has been placed. 
     SUMMARY OF THE INVENTION 
     It is an object of the present invention to provide a numerical control apparatus with a programmable mirror image function, wherein the conventional drawbacks can be eliminated, and the mirror ON/OFF operation and mirror position can be controlled by a program. 
     In order to achieve the above object of the present invention, an NC processing program is read by a program reading means, and a mirror image discriminating means discriminates whether a mirror image code and at least one coordinate axis along which a mirror is placed, are set in the read program. There are also provided: a mirror image instruction storage means for storing execution data for the at least one coordinate axis with the mirror, the execution data representing that the mirror image instruction is being executed, and for clearing the execution data for the other coordinate axis; and a storage means for storing a mirror position designated by a program for each coordinate axis. For the coordinate axis corresponding to the data stored in the mirror image instruction storage means, a shift instruction value fetched from the program is converted, in accordance with the mirror position stored in the mirror position storage means, by a shift instruction value converting means, to a new shift instruction value representing a position given upon reflection of the shift instruction value by a mirror. If a mirror position for a coordinate axis is not designated, the shift instruction value derived from the program is generated without processing. Mirror image processing is thus performed. When the mirror image operation is to be cancelled, only the mirror image code is programmed, thereby clearing the data stored in the mirror image instruction storage means for each axis. 
     According to the present invention, the mirror image function can be set and cancelled and the mirror position can be designated by the program. The program is simple, and unnecessary shifting of the shape to be processed can be eliminated. The mirror image function is thus utilized without program limitations. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a diagram for explaining a mirror image function; 
     FIG. 2 is a block diagram of a numerical control apparatus with a programmable mirror image function according to an embodiment of the present invention; and 
     FIG. 3 is a flow chart for explaining the operation of the apparatus in FIG. 2. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT 
     FIG. 2 is a block diagram of a numerical control apparatus with a programmable mirror image function according to an embodiment of the present invention. Reference numeral 1 denotes a central processing unit (CPU); 2, a ROM for storing the program which controls the overall system of the numerical control apparatus; 3, a RAM for temporarily storing processed data; 4, an I/O port connected to a servo motor (not shown) or the like of a machine tool 10 or the like; 5, a manual input unit; 6, a tape reader for reading a program from an NC program tape 7; and 8, a bus. 
     The operation of the numerical control apparatus with a programmable mirror image function will now be described. 
     In this embodiment, the mirror image function and mirror coordinate position are designated by the following statement (1): 
     
         G51.1X.sub.------ Y.sub.------ ;                           (1) 
    
     In order to cancel the mirror image function, the mirror image instruction code G51.1 is programmed: 
     
         G51.1;                                                     (2) 
    
     When a statement (3) below is programmed: 
     
         G51.1X1000;                                                (3) 
    
     the operation is performed with the mirror placed at position 1000 along the X-axis. The shape AX machining instruction shown in FIG. 1 is thus executed. 
     When the following statement (4) is programmed: 
     
         G51.1X1000 Y500                                            (4) 
    
     the operation is performed with the mirrors respectively located at position 1000 along the X-axis and position 500 along the Y-axis. In other words, the shape AXY machining instruction shown in FIG. 1 is generated. 
     The NC program tape 7 containing the programmed mirror image function is then placed in the tape reader 6. The tape is started, the numerical control apparatus performs processing in accordance with the flow of FIG. 3, and the processed data is supplied to a machine tool or the like. 
     The CPU 1 fetches the program from the NC program tape 7 through the tape reader 6 in units of blocks (step S1). In step S2, the CPU 1 checks whether or not the mirror image instruction code G51.1 has been entered. If NO in step S2, the CPU 1 jumps to step 10 and checks whether or not a shift instruction Xi for the X-axis has been entered. If NO in step S10, or if a flag FX is not set at logic &#34;1&#34; (step S11) even if YES in step S10 (the flag FX is set at logic &#34;1&#34; representing that the mirror image instruction is being executed upon generation of the mirror image function instruction to be described later), the CPU 1 supplies a normal NC instruction to the machine tool or the like. In step 13, the CPU 1 checks whether or not a shift instruction Yi for the Y-axis has been entered. If NO in step S13, or if a flag FY is not set at logic &#34;1&#34; (step S14) even if YES in step S13, a normal NC instruction is supplied to the machine tool or the like. When the workpiece is machined to obtain shape A defined by P1, P2, and P3 as shown in FIG. 1, the operations in steps S1, S2, S10, S11, S13, S14 and S16 in FIG. 3 are performed to generate the normal shift instructions Xi and Yi. However, when the read program does not contain the shift instructions Xi or Yi, processing is executed through steps S1, S2, S10, and S13, and the read instruction outputs are generated in step S16. 
     If the mirror image instruction code G51.1 is read in step S2, the X and Y flags FX and FY are cleared to zero (step S3). The CPU 1 then checks in step S4 whether or not the mirror image instruction code G51.1 and the mirror position have been entered. If NO in step S4, the flow jumps to step S7. However, if YES in step S4, the X flag FX is set at logic &#34;1&#34; (step S5), and the input X-axis mirror position X is stored (step S6). Similarly, the CPU 1 checks in step S7 whether or not a Y-axis mirror position has been entered. If NO in step S7, the flow returns to step S1. However, if YES in step S7, the Y flag FY is set at logic &#34;1&#34; and the Y-axis mirror position is stored (steps S8 and S9). Thereafter, the flow returns to step S1. The operations in steps S3 to S9 set the mirror image function and the correponding mirror positions. 
     The next program block is read (step S1), and the shift instruction Xi for the X-axis is read (steps S2 and S10). When the X flag FX is set at logic &#34;1&#34; (step S11), the mirror is located on the X-axis. The CPU 1 then performs the following processing in accordance with the X mirror position X and the instruction value Xi read from the program (step S12). 
     
         XM-(Xi-XM)=2XM-Xi                                          (5) 
    
     The new instruction value Xi is then stored. 
     
         Xi=2XM-Xi                                                  (6) 
    
     The above relationship will be described with reference to FIG. 1. For example, if the X-axis position P1 is given as Xi, a difference (Xi-XM) indicates a distance between the X mirror coordinate and P1. When this distance is subtracted from the X mirror position XM, the X coordinate position P1X is calculated as follows: ##EQU1## 
     In this manner, the new instruction value Xi represents X coordinate position P1X in FIG. 1. Similarly, X coordinate positions P2 and P3 are converted and X coordinate positions P2X and P3X are stored. 
     When the shift instruction Yi for the Y-axis is designated (step S13) and the Y flag FY is set at logic &#34;1&#34; (step S14), that is, when the mirror is located along the Y-axis, the same processing as for the X-axis is performed to derive a new Y-axis instruction value Yi using equation (8): 
     
         Yi=2YM-Yi                                                  (8) 
    
     Using these new values Xi and Yi (generated in step S16), a mirror processing instruction is generated such that the mirror(s) is (are) located along one or both of the X- and Y-axes. 
     When the X flag FX is set at logic &#34;1&#34; and the mirror is located at the X position X, the new shift instruction Xi (=2XM-Xi) is calculated in step S12 in accordance with the X shift instruction value Xi read from the program. The calculated value is generated as Xi in step S16. Since the Y flag FY is not set at logic &#34;1&#34;, the shift instruction value Yi read from the program is generated without processing. The workpiece is thus machined to obtain the shape AX derived from the shape A when the mirror is placed at the mirror position X as shown in FIG. 1. Similarly, when only the Y flag FY is set at logic &#34;1&#34;, the machining instruction for the shape AY formed when the mirror is located at the mirror position YM is generated. When both the flags FX and FY are set at logic &#34;1&#34;, the shape AXY machining instruction is generated. The operations after step S1 are performed until the program completes execution. 
     In order to interrupt the mirror image function, only the statement G51.1 is necessary. When the CPU 1 fetches this statement, the flags FX and FY are cleared in step S3. Since the X and Y shift instruction values Xi and Yi are not programmed, the flags FX and FY are not set at logic &#34;1&#34;, and the operations in step S12 and S15 are not performed. In the next cycle, the shift instruction value read from the program is generated without processing in step S16. As a result, mirror image output will not be generated. 
     In the above embodiment, an X- and Y-axis mirror image function is exemplified. However, an X-, Y-, and Z-axis mirror image function can be used equally effectively in the same manner as described above.