Tuesday, June 27, 2023

Different programming instructions

CNC programming involves various instructions and techniques to define and control the movements and operations of the CNC machine. Here are some commonly used programming techniques and instructions in CNC programming:

Axis movement command

The axis movement command is completed by addressing the axis name followed by a numeric value that defines the destination of the axis. It includes a feed command, which determines the speed at which the axis will move. Additionally, a Preparatory function code or G-code is always included to specify the type of movement to be carried out. There are two common types of movement for axis positioning: linear and circular interpolation. The G01 command is used for a linear drive, while G02 or G03 commands are used for circular interpolation movements.

Linear interpolation movement - The following picture illustrates the linear interpolation movement for the X and Y axes from point O to point P.

 

Here, point O is located at coordinates 0,0, and point P will have coordinates 100,50. Both the X and Y axes will move simultaneously to execute this action. The final position of the X-axis will be 100 mm, and the Y-axis will move up to 50 mm. The programming command for this movement is as follows:


N5 G21 G90 G94 ;

N10 G00 G53 X0.000 Y0.000 ;

N15 G01 X100.000 Y50.000 F300 ;


Inside the first block (N5), some Preparatory functions or G-codes are defined. G21 specifies that all measurements will be in millimeters, G90 confirms the use of absolute measurement criteria, and G94 indicates that feed movements will be in millimeters/minute for all axes. In the second block (N10), the X and Y axes will move to the zero position (X0.000 Y0.000) while ignoring the work offset (G53). This movement will be executed with rapid feed (G00). The third block (N15) represents a movement of 100.000 mm for the X-axis and 50.000 mm for the Y-axis, with a program feed of 300 mm/min (F300). Both axes will move together with linear interpolation (G01) and reach position P (100,50). The same command is applicable for horizontal and vertical axes individually.

 

 

Circular Interpolation - Programming circular interpolation movements can be described in two different ways. The first method considers the 'Arc starting and endpoint associated with arc radius,' while the second method considers the 'Starting and endpoint of the arc with the position of the arc center point.' The first method is generally more convenient for programming movements of less than 180º, while the second method is preferable for movements exceeding 180º due to its accuracy. However, most programmers follow the second method for all types of circular interpolation movements.


Programming with Arc radius (first method) - The following diagram illustrates the circular interpolation movement for the X and Y axes from point P to point Q with a clockwise direction and a radius of 20 millimeters. Point P is located at coordinates 40,20, and point Q is at coordinates 60,40. Both the X and Y axes will move together to complete the circular path.


The programming command for this movement is as follows:

N5 G21 G90 G94 ;

N10 G00 G53 X0.000 Y0.000 ;

N15 G01 X40.000 Y20.000 F300 ;

N20 G02 X60.000 Y40.000 R20 F100 ; 

The first three blocks of the program are the same as the preceding linear interpolation program. In the third block, the X and Y axes move from the starting position (X0.000, Y0.000) to the position (X40.000, Y20.000) using linear interpolation. From there, the circular interpolation movement begins. The fourth block (N20) positions the X and Y axes at (X60.000, Y40.000) using clockwise circular interpolation (G02). During the movement, the feed rate of the axes will be 100 millimeters/minute (F100), and the radius of the circular path will be 20 millimeters (R20).

Programming with the position of arc center point (second method) - The following picture illustrates the circular interpolation movement for the X and Y axes from point P to point Q with an anti-clockwise direction and a radius of 20 millimeters. Point P is located at coordinates 20,40, and the X-axis position for point Q (58.730) is calculated as explained in the picture. Both the X and Y axes will move together to execute this movement, and the transition path will be circular.

  


The programming command for this movement is as follows:

N5 G21 G90 G94 ;

N10 G00 G53 X0.000 Y0.000 ;

N15 G01 X20.000 Y40.000 F300 ;

N20 G03 X58.730 Y40.000 I19.365 J-5 F100 ;


The first three blocks are the same as the previous program. In the third block, the X and Y axes are positioned at (X20.000, Y40.000) representing point P. The fourth block (N20) positions the X and Y axes at (X58.730, Y40.000) representing point Q using anti-clockwise circular interpolation (G03). The feed rate of the axes will be 100 mm/minute (F100), and the circular path will have a radius of 20 millimeters (R20). The value of I (19.365) is determined based on the previous picture. The X-axis final position (X58.730) is obtained by adding twice the value of I to the X-axis starting position (20.000 + 2 * 19.365 = 58.730). The I value will be positive as the arc center point is in the positive direction compared to the X-axis position at P. Similarly, the J value will be negative as the arc center point is in the negative direction compared to the Y-axis position at point P.

 


Spindle rotation command


N5 M03 S2000 ;

The following program commands the spindle to rotate in a clockwise direction (M03) at 2000 rpm (S2000). Alternatively, the M04 code can be used to run the spindle in an anti-clockwise rotation, and the M05 code is applicable to stop the spindle.

Automatic Tool Change command


N5 T01 D01 M06 ;


The following program assigns cutting tool number T01 for automatic changes (M06). The offset value of the D01 offset data page for the T01 cutting tool will be considered to compensate for the effective length and diameter of the tool, accounting for further axis movements.


Automatic palette change command


N5 L99 ;

The following program uses the L99 sub-program, which includes a specific M code command and specific positions for different axes to perform an automatic and smooth palette changing operation.

Interim stoppage command

 

N5 G4 F5 ;


Sometimes it is necessary to stop the program temporarily during its execution. The G4 command represents a stopping mode or dwell time, and F5 defines a five-second delay or suspension in program execution. Please note that the command format may vary depending on the CNC controller.

 


Coolant ON/OFF command


N5 M07 M08 ;


The M07 command is used for Spray coolant, while the M08 command activates the Through tool coolant. Typically, the M09 code is used to stop both coolant systems.

No comments:

Post a Comment

Popular Posts