NEWS CENTER
Introduction to Common Instructions for CNC Lathe Programming
Memo:1. F function The F function command is used to control the cutting feed rate. In the program, there are two ways to use it. (1) Feed rate per revolution Programming format G95 F~
1. F function
The F function command is used to control the cutting feed rate. In the program, there are two ways to use it.
(1) Feed rate per revolution
Programming format G95 F~
The number after F represents the feed rate per revolution of the spindle, in mm/r.
Example: G95 F0.2 represents a feed rate of 0.2 mm/r.
(2) Feed rate per minute
Programming format G94 F~
The number after F represents the feed rate per minute, in mm/min.
Example: G94 F100 represents a feed rate of 100mm/min.
2. S function
The S function command is used to control the spindle speed.
Programming format S~
The number after S represents the spindle speed in r/min. On machine tools with constant linear speed function, the S function command also has the following functions.
(1) Good high speed limit
Programming format G50 S~
The number after S represents good high speed: r/min.
Example: G50 S3000 indicates that the high speed limit is 3000r/min.
(2) Constant line speed control
Programming format G96 S~
The number after S represents a constant linear speed of m/min.
Example: G96 S150 indicates that the linear speed of the cutting point is controlled at 150 m/min.
(3) Constant line speed cancellation
Programming format G97 S~
The number after S represents the spindle speed after the cancellation of constant linear speed control. If S is not specified, the good final value of G96 will be retained.
Example: G97 S3000 represents the spindle speed of 3000 r/min after the constant linear speed control is cancelled.
3. T function
The T function command is used to select the tool used for processing.
Programming format T~
There are usually two digits after T to indicate the selected tool number. But there are also four digits after T, with the first two digits being the tool number, the last two digits being the tool length compensation number, and the tool tip arc radius compensation number.
Example: T0303 represents the selection of tool 3 and the compensation values for tool length and tool tip arc radius.
T0300 indicates canceling tool compensation.
4. M function
M00: The program is paused, and the NC start command (CYCLE START) can be used to continue the program;
M01: The plan is suspended, similar to M00, but M01 can use the machine tool's "optional stop button" to select whether it is valid;
M03: Spindle rotates clockwise;
M04: Spindle rotates counterclockwise;
M05: Spindle rotation stops;
M08: coolant on;
M09: coolant off;
M30: The program stops and resets to the starting position.
5. Machining coordinate system setting G50
Programming format G50 X~Z~
The values of X and Z in the equation represent the position of the starting point relative to the machining origin. The usage method of G50 is similar to G92.
When programming on a CNC lathe, all X coordinate values use diameter values, as shown in the figure.
Example: The program segment for setting machining coordinates according to the diagram is as follows:
G50 X128.7 Z375.1
Setting the machining coordinate system
6. Quick positioning instruction G00
The G00 command commands the machine tool to move at a fast speed to the next target position, with acceleration and deceleration during the movement process. This command has no requirements for the motion trajectory. Its instruction format:
G00 X (U)____ Z (W) ____;
When programming with good values, the values after X and Z are the coordinates of the target position in the workpiece coordinate system. When programming with relative values, the values after U and W represent the distance and direction between the current point and the target point. The positioning instructions shown in the figure are as follows:
G50 X200.0 Z263.0; Set the workpiece coordinate system
G00 X40.0 Z212.0; Good value instruction programming A → C
Or G00 U-160.0 W-51.0; Relative value instruction programming A → C
Because the feed rates of the X-axis and Z-axis are different, the synthesized motion trajectory of the two axes when the machine tool executes fast motion commands may not necessarily be straight. Therefore, when using the G00 command, it is necessary to pay attention to avoiding collisions between the tool, workpiece, and fixture. If this is ignored, collisions are more likely to occur, and collisions in rapid motion are even more dangerous
7. Linear interpolation instruction G01
The G01 command commands the machine tool to move from its current position in a straight line at a certain feed rate to the target position given by the command.
Command format: G01 X (U)____ Z (W)____ F;
Where F is the cutting feed rate or feed rate, in mm/r or mm/min, depending on the setting of the previous program segment of the command. When using the G01 command, you can use good coordinate programming or relative coordinate programming. When using good seating programming, the CNC system will move the tool to a point with coordinate values X and Z after receiving G01 command; When using relative positioning programming, the tool moves to a point with a distance of U and W values from the current point. The linear motion command shown in the figure is as follows:
G01 X40.0 Z20 F0.2; Good value instruction programming
G01 U20.0 W-25.9 F0.2; Relative value instruction programming
8. Circular interpolation commands G02 and G03
The arc interpolation command commands the tool to perform arc interpolation motion within a specified plane at a given feed rate of F, used for machining arc contours. The arc interpolation commands are divided into two types: clockwise arc interpolation command G02 and counterclockwise arc interpolation command G03. The instruction format is as follows:
Command format for clockwise arc interpolation: G02 X (U)____ Z (W)____ I____ K____ F____;
G02 X (U)____ Z (W)___ R___ F____;
Command format for counterclockwise arc interpolation: G03 X (U)____ Z (W)____ I____ K____ F____;;
G03 X (U)____ Z (W)___ R___ F____;
By using arc interpolation commands, coordinate programming can be done well, as well as relative coordinate programming. When programming with good coordinates, X and Z are the coordinates of the endpoint of the arc; When incremental programming, U and W are the distance between the endpoint and the starting point. The position of the center of the circle can be specified using R, I, K, and R is the value of the arc radius; I. K is the coordinate increment of the center of the circle relative to the starting point of the arc on the X and Z axes; F is the feed rate or feed speed along the tangent direction of the arc.
When using radius R to specify the position of the center of a circle, there are two possibilities of arcs from the start to the end of the arc, greater than 180 ° and less than 180 °, due to the same radius R. For the sake of distinction, the center angle of the circle is specially specified α≤ At 180 °, denoted by "+R"; α> At 180 °, use "- R". Note: R programming is only suitable for non circular arc interpolation and is not suitable for circular machining. For example, the arc shown in Figures 3-13 is in a clockwise direction from the starting point to the endpoint, and its cutting command can be written as follows:
G02 X50.0 Z30.0 I25.0 F0.3; Good coordinates, diameter programming, cutting feed rate of 0.3mm/r
G02 U20.0 W-20.0 I25.0 F0.3; Relative coordinates, diameter programming, cutting feed rate of 0.3mm/r
G02 X 50 0 Z30.0 R25.0 F0.3; Good coordinates, diameter programming, cutting feed rate of 0.3mm/r
G02 U20.0 W-20.0 R25.0 F0.3; Relative coordinates, diameter programming, cutting feed rate of 0.3mm/r
9. Pause instruction G04
The G04 command is used to pause feed, and its command format is:
G04 P____
Or G04 X (U)____
The length of pause time can be specified by address X (U) or P. The number after P is an integer, in ms; The number after X (U) is a number with a decimal point, in seconds. In some machine tools, the number after X (U) indicates the number of idle turns of the tool or workpiece.
This command can enable the tool to perform short-term non feed finishing, which can be used for slot turning, drilling and boring, as well as for corner trajectory control. For example, when turning the ring groove, if the feed ends and the tool is immediately retracted, the shape of the ring groove is a helical surface. Using the pause command G04 can make the workpiece idle for a few seconds, which can smooth the shape of the ring groove. For example, if you want to idle for 2.5 seconds, the program segment is:
G04 X2.5 or G04 U2.5 or G04 P2500;
G04 is a non modal instruction and is only valid in this program segment.
10. English and Metric Input Instructions G20, G21
G20 represents imperial input, G21 represents metric input. G20 and G21 are two codes that can replace each other. Before leaving the factory, the machine tool is generally set to G21 state, and all parameters of the machine tool are set in metric units. Therefore, CNC lathes are generally suitable for processing metric sized workpieces. If a program starts using G20 instructions, it means that some relevant data in the program is in English (in English inches); If the program uses the G21 instruction, it means that some of the relevant data in the program is in metric (unit: mm). Within a program, the G20 or G21 instructions cannot be used simultaneously and must be specified before the coordinate system is determined. The G20 or G21 command is consistent before and after the power outage, that is, using the G20 or G21 command before the power outage remains valid after the next time, unless reset.
11. Feed rate dimensional control commands G98 and G99
There are two methods for setting the cutting feed mode in CNC turning, namely feed rate (feed per revolution mode) and feed rate (feed per minute mode).
(1) Feed rate, in mm/r, with instructions as follows:
G99; Feed rate conversion command
G01X____ Z____ F____; The unit of F is mm/r
(2) The feed speed, in mm/min, is commanded as:
G98; Feed rate conversion command
G01X____ Z____ F____; The unit of F is mm/min
G98 and G99 are both modal instructions that remain valid once specified until another method is specified. The default feed mode of the CNC system for turning is the feed rate, which is the feed per revolution mode. The feed per minute mode is only used when milling with power tools.
12. Reference point return instructions G27, G28, G30
The reference point is a fixed point on the CNC machine tool, and the tool holder can be moved to this point using the reference point return command. Multiple four reference points can be set, and the positions of each reference point can be set in advance using parameters. After connecting the power supply, the reference point must be returned first, otherwise no other operations can be carried out. There are two methods for returning reference points:
(1) Manual reference point return.
(2) Automatic reference point return. This function is used for automatic reference point return function when returning to the reference point for tool change in the program after manually returning the reference point after turning on the power.
The following commands are required for automatic reference point return:
(1) Return to reference point check G27
G27 is used to verify whether the X-axis and Z-axis return to the reference point correctly. The instruction format is:
G27 X (U)____ Z (W)____
X (U), Z (W) are the coordinates of the reference point. The prerequisite for executing the G27 command is that the machine tool must manually return to the reference point once after being powered on.
When executing this command, each axis is quickly positioned according to the given coordinate value in the command, and the system checks and verifies the travel switch signal of the reference point internally. If the switch signal is detected to be correct after positioning, the indicator light of the reference point will light up, indicating that the sliding plate has returned to the reference point position correctly; If the detected signal is incorrect, the system will alarm, indicating that the reference point coordinate value of the instruction in the program is incorrect or the machine positioning error is too large.
(2) Reference point return instructions G28, G30
G28 X (U)____ Z (W) ____; Good reference point return, where X (U) and Z (W) are the intermediate points when the reference point is returned, X and Z are good coordinates, and U and W are relative coordinates. The process of returning the reference point is shown in Figure 3-14.
G30 P2 X (U)____ Z (W) ____; The second reference point returns, P2 can be omitted
G30 P3 X (U)____ Z (W) ____; Third reference point return
G30 P4 X (U)____ Z (W) ____; Fourth reference point return
The meanings of X (U), Z (W) in the second, third, and fourth reference point returns are the same as in G28.
As shown in Figure 3-14, the process of the tool returning to the reference point is as follows:
G30 X190 Z50;
G30 U100 W30;
As shown in the dashed path in Figure 3-14, if the reference point returns without passing through the intermediate point, the tool will collide with the workpiece, causing an accident.
The F function command is used to control the cutting feed rate. In the program, there are two ways to use it.
(1) Feed rate per revolution
Programming format G95 F~
The number after F represents the feed rate per revolution of the spindle, in mm/r.
Example: G95 F0.2 represents a feed rate of 0.2 mm/r.
(2) Feed rate per minute
Programming format G94 F~
The number after F represents the feed rate per minute, in mm/min.
Example: G94 F100 represents a feed rate of 100mm/min.
2. S function
The S function command is used to control the spindle speed.
Programming format S~
The number after S represents the spindle speed in r/min. On machine tools with constant linear speed function, the S function command also has the following functions.
(1) Good high speed limit
Programming format G50 S~
The number after S represents good high speed: r/min.
Example: G50 S3000 indicates that the high speed limit is 3000r/min.
(2) Constant line speed control
Programming format G96 S~
The number after S represents a constant linear speed of m/min.
Example: G96 S150 indicates that the linear speed of the cutting point is controlled at 150 m/min.
(3) Constant line speed cancellation
Programming format G97 S~
The number after S represents the spindle speed after the cancellation of constant linear speed control. If S is not specified, the good final value of G96 will be retained.
Example: G97 S3000 represents the spindle speed of 3000 r/min after the constant linear speed control is cancelled.
3. T function
The T function command is used to select the tool used for processing.
Programming format T~
There are usually two digits after T to indicate the selected tool number. But there are also four digits after T, with the first two digits being the tool number, the last two digits being the tool length compensation number, and the tool tip arc radius compensation number.
Example: T0303 represents the selection of tool 3 and the compensation values for tool length and tool tip arc radius.
T0300 indicates canceling tool compensation.
4. M function
M00: The program is paused, and the NC start command (CYCLE START) can be used to continue the program;
M01: The plan is suspended, similar to M00, but M01 can use the machine tool's "optional stop button" to select whether it is valid;
M03: Spindle rotates clockwise;
M04: Spindle rotates counterclockwise;
M05: Spindle rotation stops;
M08: coolant on;
M09: coolant off;
M30: The program stops and resets to the starting position.
5. Machining coordinate system setting G50
Programming format G50 X~Z~
The values of X and Z in the equation represent the position of the starting point relative to the machining origin. The usage method of G50 is similar to G92.
When programming on a CNC lathe, all X coordinate values use diameter values, as shown in the figure.
Example: The program segment for setting machining coordinates according to the diagram is as follows:
G50 X128.7 Z375.1
Setting the machining coordinate system
6. Quick positioning instruction G00
The G00 command commands the machine tool to move at a fast speed to the next target position, with acceleration and deceleration during the movement process. This command has no requirements for the motion trajectory. Its instruction format:
G00 X (U)____ Z (W) ____;
When programming with good values, the values after X and Z are the coordinates of the target position in the workpiece coordinate system. When programming with relative values, the values after U and W represent the distance and direction between the current point and the target point. The positioning instructions shown in the figure are as follows:
G50 X200.0 Z263.0; Set the workpiece coordinate system
G00 X40.0 Z212.0; Good value instruction programming A → C
Or G00 U-160.0 W-51.0; Relative value instruction programming A → C
Because the feed rates of the X-axis and Z-axis are different, the synthesized motion trajectory of the two axes when the machine tool executes fast motion commands may not necessarily be straight. Therefore, when using the G00 command, it is necessary to pay attention to avoiding collisions between the tool, workpiece, and fixture. If this is ignored, collisions are more likely to occur, and collisions in rapid motion are even more dangerous
7. Linear interpolation instruction G01
The G01 command commands the machine tool to move from its current position in a straight line at a certain feed rate to the target position given by the command.
Command format: G01 X (U)____ Z (W)____ F;
Where F is the cutting feed rate or feed rate, in mm/r or mm/min, depending on the setting of the previous program segment of the command. When using the G01 command, you can use good coordinate programming or relative coordinate programming. When using good seating programming, the CNC system will move the tool to a point with coordinate values X and Z after receiving G01 command; When using relative positioning programming, the tool moves to a point with a distance of U and W values from the current point. The linear motion command shown in the figure is as follows:
G01 X40.0 Z20 F0.2; Good value instruction programming
G01 U20.0 W-25.9 F0.2; Relative value instruction programming
8. Circular interpolation commands G02 and G03
The arc interpolation command commands the tool to perform arc interpolation motion within a specified plane at a given feed rate of F, used for machining arc contours. The arc interpolation commands are divided into two types: clockwise arc interpolation command G02 and counterclockwise arc interpolation command G03. The instruction format is as follows:
Command format for clockwise arc interpolation: G02 X (U)____ Z (W)____ I____ K____ F____;
G02 X (U)____ Z (W)___ R___ F____;
Command format for counterclockwise arc interpolation: G03 X (U)____ Z (W)____ I____ K____ F____;;
G03 X (U)____ Z (W)___ R___ F____;
By using arc interpolation commands, coordinate programming can be done well, as well as relative coordinate programming. When programming with good coordinates, X and Z are the coordinates of the endpoint of the arc; When incremental programming, U and W are the distance between the endpoint and the starting point. The position of the center of the circle can be specified using R, I, K, and R is the value of the arc radius; I. K is the coordinate increment of the center of the circle relative to the starting point of the arc on the X and Z axes; F is the feed rate or feed speed along the tangent direction of the arc.
When using radius R to specify the position of the center of a circle, there are two possibilities of arcs from the start to the end of the arc, greater than 180 ° and less than 180 °, due to the same radius R. For the sake of distinction, the center angle of the circle is specially specified α≤ At 180 °, denoted by "+R"; α> At 180 °, use "- R". Note: R programming is only suitable for non circular arc interpolation and is not suitable for circular machining. For example, the arc shown in Figures 3-13 is in a clockwise direction from the starting point to the endpoint, and its cutting command can be written as follows:
G02 X50.0 Z30.0 I25.0 F0.3; Good coordinates, diameter programming, cutting feed rate of 0.3mm/r
G02 U20.0 W-20.0 I25.0 F0.3; Relative coordinates, diameter programming, cutting feed rate of 0.3mm/r
G02 X 50 0 Z30.0 R25.0 F0.3; Good coordinates, diameter programming, cutting feed rate of 0.3mm/r
G02 U20.0 W-20.0 R25.0 F0.3; Relative coordinates, diameter programming, cutting feed rate of 0.3mm/r
9. Pause instruction G04
The G04 command is used to pause feed, and its command format is:
G04 P____
Or G04 X (U)____
The length of pause time can be specified by address X (U) or P. The number after P is an integer, in ms; The number after X (U) is a number with a decimal point, in seconds. In some machine tools, the number after X (U) indicates the number of idle turns of the tool or workpiece.
This command can enable the tool to perform short-term non feed finishing, which can be used for slot turning, drilling and boring, as well as for corner trajectory control. For example, when turning the ring groove, if the feed ends and the tool is immediately retracted, the shape of the ring groove is a helical surface. Using the pause command G04 can make the workpiece idle for a few seconds, which can smooth the shape of the ring groove. For example, if you want to idle for 2.5 seconds, the program segment is:
G04 X2.5 or G04 U2.5 or G04 P2500;
G04 is a non modal instruction and is only valid in this program segment.
10. English and Metric Input Instructions G20, G21
G20 represents imperial input, G21 represents metric input. G20 and G21 are two codes that can replace each other. Before leaving the factory, the machine tool is generally set to G21 state, and all parameters of the machine tool are set in metric units. Therefore, CNC lathes are generally suitable for processing metric sized workpieces. If a program starts using G20 instructions, it means that some relevant data in the program is in English (in English inches); If the program uses the G21 instruction, it means that some of the relevant data in the program is in metric (unit: mm). Within a program, the G20 or G21 instructions cannot be used simultaneously and must be specified before the coordinate system is determined. The G20 or G21 command is consistent before and after the power outage, that is, using the G20 or G21 command before the power outage remains valid after the next time, unless reset.
11. Feed rate dimensional control commands G98 and G99
There are two methods for setting the cutting feed mode in CNC turning, namely feed rate (feed per revolution mode) and feed rate (feed per minute mode).
(1) Feed rate, in mm/r, with instructions as follows:
G99; Feed rate conversion command
G01X____ Z____ F____; The unit of F is mm/r
(2) The feed speed, in mm/min, is commanded as:
G98; Feed rate conversion command
G01X____ Z____ F____; The unit of F is mm/min
G98 and G99 are both modal instructions that remain valid once specified until another method is specified. The default feed mode of the CNC system for turning is the feed rate, which is the feed per revolution mode. The feed per minute mode is only used when milling with power tools.
12. Reference point return instructions G27, G28, G30
The reference point is a fixed point on the CNC machine tool, and the tool holder can be moved to this point using the reference point return command. Multiple four reference points can be set, and the positions of each reference point can be set in advance using parameters. After connecting the power supply, the reference point must be returned first, otherwise no other operations can be carried out. There are two methods for returning reference points:
(1) Manual reference point return.
(2) Automatic reference point return. This function is used for automatic reference point return function when returning to the reference point for tool change in the program after manually returning the reference point after turning on the power.
The following commands are required for automatic reference point return:
(1) Return to reference point check G27
G27 is used to verify whether the X-axis and Z-axis return to the reference point correctly. The instruction format is:
G27 X (U)____ Z (W)____
X (U), Z (W) are the coordinates of the reference point. The prerequisite for executing the G27 command is that the machine tool must manually return to the reference point once after being powered on.
When executing this command, each axis is quickly positioned according to the given coordinate value in the command, and the system checks and verifies the travel switch signal of the reference point internally. If the switch signal is detected to be correct after positioning, the indicator light of the reference point will light up, indicating that the sliding plate has returned to the reference point position correctly; If the detected signal is incorrect, the system will alarm, indicating that the reference point coordinate value of the instruction in the program is incorrect or the machine positioning error is too large.
(2) Reference point return instructions G28, G30
G28 X (U)____ Z (W) ____; Good reference point return, where X (U) and Z (W) are the intermediate points when the reference point is returned, X and Z are good coordinates, and U and W are relative coordinates. The process of returning the reference point is shown in Figure 3-14.
G30 P2 X (U)____ Z (W) ____; The second reference point returns, P2 can be omitted
G30 P3 X (U)____ Z (W) ____; Third reference point return
G30 P4 X (U)____ Z (W) ____; Fourth reference point return
The meanings of X (U), Z (W) in the second, third, and fourth reference point returns are the same as in G28.
As shown in Figure 3-14, the process of the tool returning to the reference point is as follows:
G30 X190 Z50;
G30 U100 W30;
As shown in the dashed path in Figure 3-14, if the reference point returns without passing through the intermediate point, the tool will collide with the workpiece, causing an accident.