Share this

Usage of the M99 command on a CNC lathe

2026-04-06 05:29:09 · · #1

CNC lathes are highly automated machine tools widely used in the field of machining. In CNC lathe programming, M-codes (auxiliary function codes) play a crucial role. The M99 instruction is an auxiliary function code used in CNC lathe programming to implement cyclic calls in the program. Below, we will explain the usage of the M99 instruction in detail.

I. Basic meaning of M99 instructions

The M99 instruction is an auxiliary function code in CNC lathe programming. Its basic meaning is "program ends and returns to the beginning of the program". In CNC lathe programs, the M99 instruction is usually used to implement program looping. That is, when the program executes the M99 instruction, the CNC system will automatically return to the beginning of the program and re-execute the program until the set number of loops is reached or other conditions are met.

II. Format of M99 Command

The M99 instruction format is very simple; you only need to add the M99 code to the program. For example:

N10 G00 X50 Z0

N20 G01 X20 F100

N30 M99

In this example, the M99 instruction is located on line 30 of the program, which means that when the program reaches this line, the CNC system will automatically return to the beginning of the program and re-execute the program.

III. The principle of cyclic calling of M99 instructions

The principle behind the M99 instruction's cyclic program execution is based on the CNC system's internal counter. When the program executes the M99 instruction, the CNC system checks the value of the internal counter. If the counter value is less than the set number of loops, the CNC system automatically increments the counter by 1 and returns to the beginning of the program to re-execute it. If the counter value has reached the set number of loops, the CNC system stops program execution.

IV. Setting the Loop Count for the M99 Instruction

The number of cycles for the M99 instruction can be set through parameter settings in the CNC system or by using other M-codes in the program. Common methods for setting this number include:

Use the parameters of the CNC system to set the number of cycles.

In the parameter settings of the CNC system, you can set the parameter for the number of program loops. For example, setting the parameter to 10 means that the program needs to be executed 10 times.

Use M-code to set the number of loops

In the program, M codes such as M20 and M30 can be used to set the number of loop iterations. For example:

N10 M20 P10

N20 G00 X50 Z0

N30 G01 X20 F100

N40 M99

In this example, the M20 instruction is used to set the number of loops to 10, and the P parameter represents the value of the number of loops. When the program executes the M99 instruction, the CNC system will automatically check the number of loops set by the M20 instruction and perform the loop call according to the number of loops.

V. Application Scenarios of M99 Instructions

The M99 command is widely used in CNC lathe programming, and common application scenarios include the following:

Batch processing

In batch processing, it is necessary to process multiple identical parts. By using the M99 instruction, the program can be called cyclically, thereby improving processing efficiency.

Circular processing

In some machining processes, it is necessary to perform the same machining operations on a part multiple times. By using the M99 instruction, the program can be called cyclically, thus simplifying the programming work.

Loop detection

During the machining process, the dimensions of the part may need to be checked multiple times. By using the M99 instruction, the program can be called cyclically, thus achieving cyclical checks.

VI. Notes on M99 Instructions

When using the M99 command, please note the following:

Ensure the loop count is set correctly.

When using the M99 instruction, you need to ensure that the loop count is set correctly to avoid infinite loops or insufficient loop counts.

Avoid infinite loops in the program

When using the M99 instruction, it is necessary to avoid infinite loops in the program. Infinite loops will cause the CNC system to be unable to stop program execution for a long time, affecting machining efficiency.

Pay attention to the logical structure of the program.

When using the M99 instruction, attention should be paid to the logical structure of the program to ensure that the program can execute correctly during the loop call process.

VII. Programming Examples of M99 Instructions

Below is a programming example using M99 instructions:

N010 G21 (Unit set to millimeters)

N020 G97 S500 M03 (Set the spindle speed to 500 rpm and enable forward spindle rotation)

N030 T0101 (Select tool #1, tool compensation)

N040 G00 X40 Z2 (Quickly locate the position of X40 Z2)

N050 G96 S120 M08 (Set constant surface velocity to 120 m/min, turn on coolant)

N060 G01 X0 F0.2 (turning at a feed rate of 0.2 mm/revolution)

N070 G00 X40 (Quickly retract the tool to the X40 position)

N080 G00 Z0 (Quickly retract the tool to position Z0)

N090 M09 (Cooler off)

N100 M05 (Stop spindle rotation)

N110 T0000 (Tool compensation cancelled)

N120 G00 X100 Z100 (Quickly locate the position of X100 Z100)

N130 M30 (Program ends and returns to the beginning of the program)

Read next

CATDOLL 146CM Ya TPE (Customer Photos)

Height: 146cm A-cup Weight: 26kg Shoulder Width: 32cm Bust/Waist/Hip: 64/54/74cm Oral Depth: 3-5cm Vaginal Depth: 3-15c...

Articles 2026-02-22