Next: 11. Canned Cycles Up: 10.7 Basic Motion and Previous: Miscellaneous words Contents Index

## Modal Codes

Many G codes and M codes cause the machine to change from one mode to another, and the mode stays active until some other command changes it implicitly or explicitly . Such commands are called "modal".

Modal codes are like a light switch. Flip it on and the lamp stays lit until someone turns it off. For example, the coolant commands are modal. If coolant is turned on, it stays on until it is explicitly turned off. The G codes for motion are also modal. If a G1 (straight move) command is given on one line, it will be executed again on the next line unless a command is given specifying a different motion (or some other command which implicitly cancels G1 is given).

"Non-modal" codes effect only the lines on which they occur. For example, G4 (dwell) is non-modal.

Modal commands are arranged in sets called "modal groups". Only one member of a modal group may be in force at any given time. In general, a modal group contains commands for which it is logically impossible for two members to be in effect at the same time. Measurement in inches vs. measure in millimeters are modal. A machine tool may be in many modes at the same time, with one mode from each group being in effect. The modal groups used in the interpreter are shown in Table 6.

Group 1 | {G0, G1, G2, G3, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89} - motion
Group 2 | {G17, G18, G19} - plane selection
Group 3 | {G90, G91} - distance mode
Group 5 | {G93, G94} - spindle speed mode
Group 6 | {G20, G21} - units
Group 7 | {G40, G41, G42} - cutter diameter compensation
Group 8 | {G43, G49} - tool length offset
Group 10 | {G98, G99} - return mode in canned cycles
Group 12 | {G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3} coordinate system selection
Group 2 | {M26, M27} - axis clamping
Group 4 | {M0, M1, M2, M30, M60} - stopping
Group 6 | {M6} - tool change
Group 7 | {M3, M4, M5} - spindle turning
Group 8 | {M7, M8, M9} - coolant
Group 9 | {M48, M49} - feed and speed override bypass

Table 6 G and M Code Modal Groups

There is some question about the reasons why some codes are included in the modal group that surrounds them. But most of the modal groupings make sense in that only one state can be active at a time.

Next: 11. Canned Cycles Up: 10.7 Basic Motion and Previous: Miscellaneous words Contents Index