CHAPTER 7 Basic Codes to Control Machine Functions

CHAPTER 7 Basic Codes to Control Machine Functions Prepared by: Ahmad Fairuz Bin Mansor Universiti Malaysia Perlis (Uni. MAP) 2017

Course Outcome 2 (CO 2) Ability to develop G and M code programs and documentation for machining operation on CNC machine tools.

Essential Questions • What are the more common M-codes used today? • How are automatic tool changers limited in usage?

Understanding M-Codes • Miscellaneous codes a. k. a machine codes – Control various machine functions ranging from tool change to coolant control. • M Address + Number = M-Word – Can be alone or in a block – Little consistency when M-code is executed • Assume M-code will be executed after other instructions are finished. Eg: N 90 M 08 (Coolant On) N 100 G 01 X 2. 0 Y 2. 0 F 10. 0

Table 8. 1 Common M-code Functions

M 06 – Tool Changes • Because each machine tool behaves a little bit different, it is extremely important to understand the particular control you are working with or damage may result. • Several possibilities for the type of tool change that a particular machine will require. The common configurations are: – Manual tool change – Automatic tool changer with absolute locations (recent modern machine) – Automatic tool changer with incremental locations (less modern machine)

Figure 8. 1 Automatic tool changers (left to right): Side Mount, Belt, Turret (lathe).

M 06 – Tool Changes (cont’d. ) • Be aware of how the machine will behave when M 06 code is encountered. – Two common configurations: • Storage device travels with spindle (or tool post) • Storage device is stationary • Immediate after the tool change, we will need to specify the length offset for the tool. The method varies, but it is common to use the G 43 code followed by an H-word. Eg: N 40 G 43 H 01

M 06 – Tool Changes (cont’d. ) • To change tools within a program, it is good habit to always move the tool to a safe position whether it is required or not. Use G 91 G 28 Z 0 or G 91 G 28 X 0 Y 0 Z 0. • You also need to put G 49 to cancel tool length offset for tool before. Eg: N 90 G 01 Z 0. 2 N 100 M 05 N 110 G 49 N 120 G 91 G 28 Z 0 (return to z-axis home position) N 130 M 06 T 02 N 140 G 43 H 02 N 150 M 03 S 1500

Figure 8. 2 Care must be taken to fully understand the movements of the headstock and Automatic Tool Changer (ATC) before use. Some configurations will allow a crash if positioned too close to the table or fixture when a tool change is called.

M 03, M 04, and M 05 – Turning the Spindle On or Off • M 03 and M 04: turns spindle on after tool change before attempting to perform any metal cutting. • M 03 forward rotation; M 04 reverse rotation • M 03 is most common used for end mills and drills. • Some turning machines has gear selection that must be selected for machining. The codes are M 41 and M 42: – Usual codes for gear selection: • M 41 low gear; M 42 high gear

Figure 8. 3 M 03 is the most common direction of rotation for end mills and drills. Occasionally, left-handed cutting tools are encountered and they will require M 04.

M 07, M 08, M 09 – Coolant Control • Coolant are often used in machining operation to extend the tool life, flush chips away and improve the surface finish. • M 08: – Code for turning on coolant system • M 07: – Differentiates between flood and mist systems on machine tools equipped with both. • M 09: – Turns off coolant

M 30 and M 02 – Ending a Program • M 30: – Most common code to signify to the control that the program has ended. – This code will stop the machine and reset the memory to the top of the program. – Can be used anywhere in the program. – It is alternatively to move the machine to intermediate position to ease operator to access the fixture. Eg: N 210 M 05 N 220 G 49 N 230 M 09 N 240 G 91 G 28 Z 0 N 250 G 90 G 00 X 4. 0 Y 8. 0 N 260 M 30 %

M 30 and M 02 – Ending a Program (cont’d) • M 02: – Mostly superseded by M 30. – Can only be used at end of program. – Does not reset memory. The operator must manually press the reset button.

M 00 and M 01 – Interrupting the Program Execution • Causes program execution to pause. For example in order to clean chips out or to combine program such turning the part over or moving clamps to new position. Two codes to execute pause: – M 00 is unconditional program stop. § Stop all axis motion (spindle still revolve) until operator press the cycle start (continue the program). – M 01 is optional program stop § Only functions when operator has enabled the optional stop button at the control. § Occasionally use such as to check tools for damage before continuing. Table 8. 2 Behavior of Optional Stop (use M 01 code)

M 00 and M 01 – Interrupting the Program Execution. . cont’d • Example of using M 00: N 240 G 00 Z 8. 0 M 09 N 250 M 05 (spindle stop) N 260 M 00 (Stop to clean out chips) N 270 M 03 S 1500 (Restart Spindle) G 00 Z 0. 2 M 08 • Example of using M 01: N 150 M 06 T 02 N 160 G 43 H 02 N 170 M 01 (Check the tool for damage) N 180 M 03 S 1500

Block Delete ( / ) • Allows operator to completely skip certain blocks within the program. Table 8. 3 Behavior of Block Delete(/)

Block Delete ( / ) Example: N 80 G 81 X 0. 0 Y 1. 0 Z-1. 0 R 0. 2 F 5. 0 (Drill row one) N 90 X 0. 0 Y 2. 0 N 100 X 0. 0 Y 3. 0 /N 110 X 1. 0 Y 1. 0 (Drill row two, only used for part B) /N 120 X 1. 0 Y 2. 0 /N 130 X 1. 0 Y 3. 0 N 130 M 05

Miscellaneous Functions • M 19: – Causes spindle to rotate to a reference position and lock. – There is a small notch or divot on the tool holder that is used to align the tool with the oriented position. • M 97, M 98, and M 99: – Subroutines and subprograms. – Method of modularizing an NC program to make it more portable and easier to modify.

The End Q&A
- Slides: 21