Common M-Codes for CNC Machine

Share:

Miscellaneous Function (M-Code)

The miscellaneous function word is used to specify certain miscellaneous or auxiliary functions which do not relate to the dimensional movements of the machine. The miscellaneous functions may be spindle start, spindle stop, coolant ON/OFF, etc. The list given below is a representative list. All of these may not be available on all the machines. On the other hand, some machines may use some extra codes also.

M-Codes
Code
Description
Code
Description
M00
Program stop
M 10
Chuck open
M01
Optional stop
M 11
Chuck close
M02
End of program execution
M25
Quill extend
M03
Spindle    forward     (CW,     as viewed towards the tail-stock)
M26
Quill retract
M04
Spindle   reverse    (CCW.    as viewed towards the tail-stock)
M30
Program reset and rewind
M05
Spindle stop
M38
Door open
M06
Auto tool change
M39
Door close
M08
Coolant on
M98
Subprogram call
M09
Coolant off
M99
Return to the calling program


Description of M Codes

As already mentioned M codes are instructions describing miscellaneous machine functions such as door opening/ closing, chuck opening/closing, tool changing, starting spindle rotation etc. An M code quite often requires other information also. e.g., spindle speed, tool number etc.

(a) M00 Program Stop. The execution stops and waits for the CYCLE START button on ' the control panel of the machine to be pressed for re-starting the execution. This facility is useful if an inspection check is necessary during an operation.
Example: M00

(b) M01 Optional Stop. It is same as M00, but is effective only when the optional stop switch on the machine control panel has been pressed.
Example: M01

(c) M02 Program End. Stops the spindle, turns the coolant off, and terminates the CNC program. To produce another part, the system must be reset.
Example: M02

(d) MO3 Spindle Forward. Starts the spindle spinning forward (CW. as viewed towards tailstock from the chuck) at the last specified spindle rate.
Examples:
M03 S1200 (CW rotation starts at 1 RPM)
M03 (CW rotation starts at previously specified RPM)

(e) M04 Spindle Reverse. Starts the  spindle spinning in reverse (CCW) at the last specified spindle rate.

Examples: M04 S1200 (CCW rotation starts at 1200 RPM) M04 (CCW rotation starts at previously specified RPM)

(f) M05 Stop Spindle. Stops the spindle rotation.
Example: M05

(g) M06 Tool Change. The M06, in conjunction with a T word, is used to orient the tool specified by the T word in the cutting position, and to activate its tool offsets. On some machines, simply a T word causes a tool change; it need not be paired with M06.
Example: M06 T2 (tool no. 2 comes in the cutting position)
Tool changes are normally performed with the tool turret at a safe position to avoid any inadvertent collision. So, the G28 code, which sends the tool turret to the home position of the machine, is often used before invoking a tool change command.

(h) M08 Coolant On. M08 turns the coolant on.
Example: M08

(i) M09 Coolant Off. M09 turns the coolant off Example: M09

(j) M10 Chuck Open. M 10 opens the chuck, if it is closed. Machining cannot start if the chuck is left open. Obviously, M 10 is not for a manual chuck.
Example: M10

(k) M11 Chuck Close. M11 closes the chuck.
Example: M11

(l) M25 Quill Extend. Extends the quill (tailstock).
Example: M25

(m) M26 Quill Retract. Retracts the quill (tailstock).
Example: M26

(n) M30 Program End. Stops the spindle, turns the coolant off, terminates the CNC program and resets it.
Example: M30

(o) M38 Door Open.
Example: M38 Opens the door

(p) M39 Door Close. Closes the door.
Example: M39

Note.   Machining cannot start unless the door is closed. Usually, a low RPM (e.g. 100) is permitted even if the door is open. This helps in setting the tool offsets because, unless the job rotates, it is very difficult to judge whether the tool has touched it. When the job rotates, the tool leaves a light mark on it, the moment it just touches it.

(q) M98 Subprogram Call. When a program contains certain fixed sequences or frequently repeated patterns, these sequences or patterns may be stored as separate subprograms (or subroutines) to simplify programming. M98 causes a different program to be executed as a subroutine inside the program which calls it by M98. It is equivalent to the CALL statement of FORTRAN.

(i)         Nesting of subprograms is permitted. i.e., a subprogram may call another subprogram also. The P value specifies the subprogram number. Example: M98 P12 (program no. 12 is executed once immediately after this statement)

(ii)        It is also possible to specify the number of repetitions of a subprogram through a single M98 statement. The respective machine manuals may be referred to for this, as the statement may be machine- specific. Usually, the last four digits of the P-word specify the subprogram number, and the digits left to it are the number of repetitions (maximum 999 repetitions). For example, M98 P50012 calls subprogram number 12 five times.

(r) M99 Subprogram Exit. M99 is equivalent to the RETURN statement of FORTRAN. It returns to the program that called the current program (sub-routine) by M98. If a P value is specified then the execution begins from the block with the specified line number in P. otherwise it is from the block after the subprogram call (i.e., after M98 block).

Examples: M99 (returns to the block following M98) M99 P10 (returns to the block at line no. 10)

Note.
(a) Nesting of subroutines is permissible.

(b) If an M99 is specified in the main program then the program is repeated endlessly. The subsequent executions are from the start of the program or from the line number defined in P. This feature is useful for producing a number of parts from the same program. M00 may be used for loading new jobs.

(c) The first block of the subroutine may contain a program number which is defined by an O word (e.g. O12 defines program number 12).

1 comment:

  1. You have shared such a great article in this post. I got some useful knowledge from this post. Thanks for posting it. Keep it up. Downtime Tracking Software

    ReplyDelete