Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

M CODES

/ MSTF
Command
TABLE OF CONTENTS
I. Introduction
II. Contents
III. Summary
IV. Group Members
V. References
I. Introduction
What Is CNC M Code?
◦ M code is a part of the overall program, often called G code. While
G commands describe positions, M code directs the machine's
actions. While M represents miscellaneous codes, some refer to it
as machine code because it controls particular operations of the
equipment.
◦ Both G and M codes have specialized uses in programming a CNC
machine.
Without M codes, you may direct tools to a spot and tell them to
move in a line or arc, but you won't have any success giving more
direct commands, like to stop programs, change tools, flood the
system with coolant or other actions beyond the three main
movements G codes control. That's why you can think of M codes as
directing non-cutting operations.
II. Contents
1.0 M Command (Miscellaneous Function)

1.1 EP (End of program) MO2

1.2M30 (Program End with program reset)

1.3 Subprogram call m98

1.4 M99 (RETURN FROM SUBPROGRAM)

1.5 MACRO PROGRAM M9000-M9999

1.6 Command Defined by Standard PLC Ladder Diagram

1.7PROGRAM STOP M00

1.8 Program optional stop M01


1.9 Spindle CCW, CW, stop control

1.10 Coolant control M08, M09

1.11 Tailstock control M10, M11

1.12Chuck control M12, M13

1.13 Spindle position/speed control switch M14, M15

1.14 Lubricating control M32, M33

1.15 Spindle automatic gear shifting M41, M42, M43, M44


1.0 M Command (Miscellaneous Function)
The M command word composed by command address M and 1~2 or 4 digits after the command M is used for
controlling the program execution or outputting M code to PLC.

M □□□□□□□□ Command value (00~99 、 9000~9999 , leading zero can be omitted) M Command
address M98, M99 and M9000~M9999 are independently processed by NC, and the M code is not output to
PLC. The M02 and M03 are defined as program END command by NC, at the same time it also gives the M
code to PLC for using the I/O control (close spindle, close cooling etc.). The PLC program can not change the
meaning of the above-mentioned commands when the M98, M99 and M9000~M9999 are regarded as program
CALL commands and the M02 and M30 are regarded as program END commands. The codes of other M
commands are all given to PLC program for specifying the command function; please refer to the manual issued
by machine tool manufacturer. One block only has one M command. The CNC alarm occurs when two or more
M commands are displayed in one block.
1.1 EP (End of program) MO2
Command function: The MO2 command is executed in the Auto mode. The automatic run is
ended when the other commands of current block are executed; now in order to not return to
the program beginning, the cursor is stop at block which the MO2 located. If the program is
executed again the cursor should be stopped at the beginning of the program.
The function of command M02 also can be defined by the PLC ladder diagram other than
the abovementioned functions which are processed by NC. The standard ladder diagram can
be defined as: the current input state of CNC is not change after the command MO2 is
executed.
1.2M30 (Program End with
program reset)
M30 (Program End with program reset) The most common way of
ending a program is with an M30. The program will automatically reset
to begin of the program which will give access to the operator to run the
next cycle. Using M30 will help operator to save time during mass
production. As soon as the program ends he can place the next
component and start the next cycle.
1.3 Subprogram call m98

Format : M98 P○○○○ □□□□

The called subprogram No. ( 0000 ~ 9999). The leading zero of subprogram can be omitted when the call
frequency are not given; the subprogram

□□□□ - No. should be 4 digits when the calling frequency is given;

P○○○○ - Calling frequency ( 1-9999) , calling for once, the input can be omitted

Command function: when the M98 command is executed in the Auto mode, CNC calls and executes the
subprogram specified by P, which can be performed 9999 times at most, when the other commands of current
block are executed. The M98 command is disabled in MDI.
1.4 M99 (RETURN FROM SUBPROGRAM)
Format : M99 P○○○○ The block No. (0000 ~ 9999) to be executed when a main program is returned, the
leading zero can be omitted.

Command function: (in subprogram) as the other commands of current block are executed, the block specified by
P is performed continuously when the main program is returned. The next block is performed continuously by
calling current subprogram of M98 command when returning to the main program; because of the P is not given.
If the main program is ended by using the M99 (namely, the current program is not called by other programs for
execution), the current program will be run circularly. So, the M99 command is disabled in MDI.
1.5 MACRO PROGRAM M9000-M9999
•Macro program: Program 09000~09999 is special space obligated
for the machine tool manufacturer for using editing and achieving
special function subprogram, which is called macro program.

•Macro programs can affect the motions of the machine tool. They
can also be used to change coordinate data and parameter settings.
Command function: Call the macro program which is corresponded
by the command value (O9000 ~ O9999).
1.6 Command Defined by Standard PLC
Ladder Diagram
Ladder logic (also known as ladder diagram or LD) is a programming language used to program a PLC
(Programmable Logic Controller). It is a graphical PLC programming language which expresses logic
operations with symbolic notation. Ladder logic is made out of rungs of logic, forming what looks like a
ladder – hence the name ‘Ladder Logic’.
It is mainly for bit logic operations, although it is possible to scale a PLC analog input. Even simple bit
logic operations can be beneficial in more advanced PLC programs and SCADA system programming.
The people or the organization that sets the standards for ladder logic is PLC Open. Ladder logic is not
only a programming language for PLC’s. It is one of the standardized PLC programming languages. This
simply means that ladder logic is described in a standard. That standard is called IEC 61131-3. But for
now, the only thing you need to know is that there is a standard describing this programming language.
In these rungs, you can put any of the ladder logic symbols to create the logic you
want. As you can see above, I have put numbers on each rung. This is to understand
how the PLC hardware will execute the ladder logic. You may be familiar with the
PLC scan time or scan cycle. Roughly said, the PLC will first scan all its inputs, then
execute the program to set outputs.
But how does the PLC execute our ladder logic?
One rung at a time.
This might be one of the most important rules of ladder logic. The PLC only
executes one rung at a time, then executes the next. In fact, the PLC only executes
one symbol at a time.
Examine if Closed Output Coil

Output Latch

Examine if Open
1.7 PROGRAM STOP M00
Command format: M00 or M0
•Command function: After M00 is executed, the program stops and the system displays
“Pause”, and then the program continuously runs after the cycle start key is pressed.
1.8 Program Optional Stop
Command format: M01 or M1
Command function: in AUTO, MDI mode, it is valid. Press (optional stop) and
its indicator lights and the system enters the optional stop state, at the moment,
the program stops run and the system displays “PAUSE” after M01 is executed,
after the cycle start key is pressed, the program continuously runs. When the
program optional stop switch is not open, the program does not pause even if
M01 runs.
1.9 Spindle CCW, CW, stop control
M03, M04 and M05
Command function:
M03: spindle forward rotation (CCW);
M04: spindle reverse rotation (CW);
M05: spindle stop
1.10 Coolant control M08, M09
Format:
•M08;
•M09;
Command function:
M08: cooling on;
M09: cooling off.
Coolants are an instrumental part of machining, including grinding,
milling, and turning. They help extend tool life and provide an
improved surface finish of the parts being machined. Understanding
the role and types of coolant help you select a coolant that is the right
fit for your machine and operation. By properly maintaining the
concentration levels of your coolant, you extend not only the life of
the coolant but also your tools and machine.
1.11 Tailstock control M10, M11
Command format:
◦ M10;
◦ M11;

Command function:
◦ M10: tailstock going forward;
◦ M11: tailstock going backward.
1.12 Chuck control M12, M13
Command format:
◦ M12;
◦ M13;

Command function:
◦ M12: chuck clamping;
◦ M13: chuck releasing.
1.13 Spindle position/speed control
switch M14, M15
Command format :
◦ M14 ;
◦ M15 ;

Command function :
◦ M14 : spindle is in the position control mode from speed control mode;
◦ M15 : spindle is in speed control mode from the position control mode.
1.14Lubricant Control (M32,M33)
Command format:
M32;
M33;
Command function:
M32: lubrication on;
M33: lubrication off.

Note: The control time sequence and logic of M08 and M09 are specified by standard PLC
1.15 Spindle automatic gear shifting M41,
M42, M43, M44
Command format: M4n;
◦ (n=1, 2, 3, 4)

Command function:
◦ the spindle automatically gears to No. n gear when M4n is
executed.
III. Summary
M-code (for “miscellaneous function”) is an auxiliary command.

CNC Macro programming is sometimes thought of as a bit of a black art in CNC


programming.

Macro programming is sometimes known as parametric programming. It means you are


controlling a program by external parameters.

Cooling control M08, M09 - This codes/process use to help the tool to cooldown or lessen the
tools temperature which heated by the material.

Spindle automatic gear shifting M41, M42, M43, M44 - This codes use to make the spindle
move by inputting rpm depends on the material the user will work.
V. References
https://boltontool.com/pdf/GSK980TDb.pdf

http://www.gskcnc.cz/static/userfiles/File/mill/980MD/3.24%20980MD%20English.pdf?fbclid=IwA
R0q7diRApl1y8yPlyiIXLBq5wVS6Ob6s2ahirHczxMdqIT28pkgZsI2Elo
https://www.cnc.com/m00-m01-optional-stop/mcodes/#:~:text=What%20is%20optional%20stop
%20in,includes%20the%20through%20spindle%20coolant

You might also like