|
M & G Code Sample Files
Sample File
1
The following is a 5" square.
Rapid level .5 inches above material, feed down 60 IPM, cut feed 200 IPM, rapid
down to .1 above material, depth .25 inches.
This is for a single head system with manual tool change (The manual
tool change is highlighted in Gray below and is optional.)
| Machine
Code |
Description
of Machine Code |
| M90 |
Program Start |
| G90 |
Absolute Coordinate
Mode |
| G75 |
Follow the XY coordinate
Arc Mode (Standard) |
| G97
S18000 |
Spindle Speed Set
to 18,000 RPM |
| // This file
is for a non atc system |
A line that begins with // is
a comment line. |
| G00
T1 |
Tool 1 call. Following
moves will use tool one. |
| G00
CE-MILL .2500 2FL. |
"E-MILL
.2500 2FL." will displayed on the keypad. The user will now be able
to load the tool manually and Z reference the tool. This line can be
sent multiple times in the same file to support manual tool changes. |
| G00
Z-0.5 |
Position the Z axis
.5 inches above Z=0 or above the Material. |
| G00
X0. Y0. |
Position X=0.0 and
Y=0.0 |
| M12 |
The M12 command should
be called before the Z axis is lows the tool into the Material or at
the start of a new contour.
- The Auxiliary output for the selected tool is turned on. (This output
can be wired to operate a tool misting or cooling unit.)
- The Motion will change from Slew mode (high speed rapid) to Machine mode
(Cutting Mode)
- If this is the first M12 called in the program the spindle output will
come on for the current selected tool. |
| G00
Z-0.1 |
Position the Z axis
0.1 inches above Z=0.0 or above the Material. |
| G01
Z0.25 F1. |
Position the Z axis
0.25 inches below Z=0.0 or into the Material at the feed rate of 1 inch/second
(60 inches/minute). |
| G01
X5. F3.333 |
Position the X=5.0
inches at the feed rate of 3.333 inch/second (200 inches/minute). |
| G01
Y5. |
Position the Y=5.0
inches (feed rate will continue at last set speed) |
| G01
X0. |
Position the X=0.0
inches |
| G01
Y0. |
Position the Y=0.0
inches |
| G00
Z-0.5 |
Position the Z axis
0.5 inches above Z=0.0 or above the Material. |
| M22 |
The M22 command should
be called after the Z axis lifts the tool out of the Material. Completing
the current contour.
- The Auxiliary output for the selected tool is turned off..
- The Motion will change from Machine mode (Cutting Mode) to Slew mode
(high speed rapid) |
| G00
X0. Y0. |
Position X=0.0 and
Y=0.0 |
| M02 |
End of Program
Spindle is turned off. |
More Sample Files
| Sample File
2 (ATC or Single Tool) |
Sample File
3 (ATC Tool 3) |
Sample File
4 (Samples 2 and 3 together) |
This
is the same file for an ATC system with the ATC tool change command.
Notice That there is no "G00 C" command. |
The following
is a 5" circle clockwise, center at 2.5,2.5, .5 rapid level, feed
down 60 IPM, cut feed 120 IPM, rapid down to .1, depth of .4". ATC
system using tool #3. |
|
M90
G90
G75
G97 S18000
G00 T1
G00 Z-0.5
G00 X0. Y0.
M12
G00 Z-0.1
G01 Z0.25 F1.
G01 X5. F3.333
G01 Y5.
G01 X0.
G01 Y0.
G00 Z-0.5
M22
G00 X0. Y0.
M02 |
M90
G90
G75
G97 S18000
G00 T3
G00 Z-0.5
G00 X2.5 Y5.
M12
G00 Z-0.1
G01 Z0.4 F1.
G02 I2.5 J2.5 F2.
G00 Z-0.5
M22
G00 X0. Y0.
M02 |
M90
G90
G75
G97 S18000
G00 T1
G00 Z-0.5
G00 X0. Y0.
M12
G00 Z-0.1
G01 Z0.25 F1.
G01 X5. F3.333
G01 Y5.
G01 X0.
G01 Y0.
G00 Z-0.5
M22
G97 S18000
G00 T3
G00 Z-0.5
G00 X2.5 Y5.
M12
G00 Z-0.1
G01 Z0.4 F1.
G02 I2.5 J2.5 F2.
G00 Z-0.5
M22
G00 X0. Y0.
M02 |
Sample Boring File
Comments in Red
M90
G90
G75
G00 X6.0394 Y6.0394
M38 Lowers the drill bank into place
and turns on the drill motor
G00 X6.0394 Y6.0394 Z-0.5 Moves
X and Y so that boring drill one is centered at X = 6.0394 Y = 6.0394 and Z
is 0.5 inches above the materials surface.
G98 P300 D496 Engages
drills 5, 6, 7, 8, and 9.
G00 Z-0.1 Slew
Move in Z to .1 inches above the material
G01 Z0.4 F1.333 Plunge
the Z axis .4 inches into the material at 80 IPM
G00 Z-0.5 Slew
Move in Z to .5 inches above the material
G00 X6.0394 Y8.5591 Move
X and Y and continue to drill more holes with the same engaged drills
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y11.0787
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y12.3386
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y13.5984
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y14.8583 Z-0.5
G98 P300 D480 Engages
drills 6, 7, 8, and 9.
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y16.1181 Z-0.5
G98 P300 D448 Engages
drills 7, 8, and 9.
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y17.378 Z-0.5
G98 P300 D384 Engages
drills 8 and 9.
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X6.0394 Y18.6378 Z-0.5
G98 P300 D256 Engages
drill 9.
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X12.3386 Y12.3386 Z-0.5
G98 P300 D31 Engages
drills 1, 2, 3, 4, and 5.
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X12.3386 Y6.0394
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X13.5984 Y6.0394
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X14.8583 Y6.0394
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X16.1181 Y6.0394
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X17.378 Y6.0394
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
G00 X18.6378 Y6.0394
G00 Z-0.1
G01 Z0.4 F1.333
G00 Z-0.5
M48 Retract all boring drills, Retract
Drill Bank, turn off drill bank
G97 S24000
G00 T3
G00 X18. Y12.875 Z-0.5
M12
G00 Z-0.1
G01 Z0.5 F1.667
G02 I18. J12. F3.333
G00 Z-0.5
M22
G00 X22. Y8.375 Z-0.5
M12
G00 Z-0.1
G01 Z0.5 F1.667
G02 I22. J7. F3.333
G00 Z-0.5
M22
G97 S18000
G00 T1
G00 X0. Y-0.25 Z-0.5
M12
G00 Z-0.1
G01 Z0.77 F1.667
G01 X25. F13.333
G03 X25.25 Y0. I25. J0.
G01 Y15.
G03 X25. Y15.25 I25. J15.
G01 X0.
G03 X-0.25 Y15. I0. J15.
G01 Y0.
G03 X0. Y-0.25 I0. J0.
G00 Z-0.5
M22
G00 X35.0 Y0.0
M02
Cutter Comp G40\G41\G42 examples
Note that before all Cutter Compensation, G41\G42,
will work the cut MUST start with a lead in and end with a lead out. The
type of compensation that is applied depends on the direction you have selected.
If the cut is going clockwise in the inside of a pocket, then the machine
should be compensated to the RIGHT (G42), if it is going clockwise on the
outside of a contour, then it should be set to LEFT (G41), and so on.
| N10 M90 |
Program Start |
| N20 G90 |
Absolute coordinate
system |
| N40 G75 |
Use absolute mode
(G90 from above) for arcs |
| N50 G97 S24000 |
Set spindle speed
to 24000 RPM |
| N60 G00 T1 |
Select Tool #1 |
| N70 G00 Z-0.5 |
Rapid move to safe
rapid level |
| N80 G00 X-0.25
Y-0.25 |
Rapid move |
| N90 M12 |
Device on code |
| N100 G00 Z-0.1 |
rapid move |
| N110 G01 Z0.5
F1. |
feed move to final
depth, feedrate 1 inch per second |
| N120 G42 |
set cutter comp
right ON |
| N130 G02 X-0.125
Y-0.125 I-0.125 J-0.25 F3.333 |
lead in arc |
| N140 G01 X10.125 |
feed move |
| N150 G01 Y10.125 |
feed move |
| N160 G01 X-0.125 |
feed move |
| N170 G01 Y-0.125 |
feed move |
| N180 G02 X-0.25
Y-0.25 I-0.25 J-0.125 |
lead out
arc |
| N190 G40 |
set cutter comp
OFF |
| N200 G00 Z-0.5 |
retract to safe
rapid level |
| N210 M22 |
device off code |
| N220 G00 X0.
Y0. |
move to home position |
| N230 M02 |
end of job code |
| N10
M90 |
Program
Start |
| N20 G90 |
Absolute coordinate
system |
| N30 G75 |
Use absolute mode
(G90 from above) for arcs |
| N40 G97
S18000 |
Set spindle speed
to 18000 RPM |
| N50 G00
T2 |
Select Tool #2 |
| N60 G00
Z-0.5 |
Rapid move to safe
Z level |
| N70 G00
X5.125 Y10.25 |
rapid move |
| N80 M12 |
device on |
| N90 G00
Z-0.1 |
rapid move |
| N100 G01
Z0.5 F1. |
feed move to final
depth, feedrate 1 inch per second |
| N110 G42 |
set cutter comp
right ON |
| N120 G02
X5. Y10. I5. J10.25 F3.333 |
lead in arc |
| N130 G03
I5. J5. |
feed move circle |
| N140 G02
X4.75 Y10.25 I5. J10.25 |
lead out arc |
| N150 G40 |
set cutter comp
OFF |
| N160 G00
Z-0.5 |
retract to safe
rapid level |
| N170 M22 |
device off code |
| N180 G00
X0. Y0. |
move to home position |
| N190 M02 |
end of job code |
| N10 M90 |
Program Start |
| N20 G90 |
Absolute coordinate
system |
| N30 G75 |
Use absolute mode
(G90 from above) for arcs |
| N40 G97
S24000 |
Set spindle speed
to 24000 RPM |
| N50 G00
T2 |
Select Tool #2 |
| N60 G00
Z-0.5 |
Rapid move to safe
Z level |
| N70 G00
X5.125 Y7.75 |
rapid move |
| N80 M12 |
device on |
| N90 G00
Z-0.1 |
rapid move |
| N100 G01
Z0.5 F1. |
feed move to final
depth, feedrate 1 inch per second |
| N110 G41 |
set cutter comp
left ON |
| N120 G03
X5. Y7.875 I5. J7.75 F6.667 |
lead in arc |
| N130 G03
I5. J5. |
feed move |
| N140 G03
X4.875 Y7.75 I5. J7.75 |
lead out arc |
| N150 G40 |
set cutter comp
OFF |
| N160 G00
Z-0.5 |
retract to safe
rapid level |
| N170 M22 |
device off code |
| N180 G97
S18000 |
Set spindle speed
to 18000 RPM |
| N190 G00
T1 |
select tool #1 |
| N200 G00
Z-0.5 |
Rapid move to safe
Z level |
| N210 G00
X-0.375 Y-0.125 |
rapid move |
| N220 M12 |
device on |
| N230 G00
Z-0.1 |
rapid move |
| N240 G01
Z0.5 F1. |
feed move to final
depth, feedrate 1 inch per second |
| N250 G42 |
set cutter comp
right ON |
| N260 G01
X0. F3.333 |
lead in line feedrate
200 inched per minute |
| N270 G01
X10. |
feed move line |
| N280 G03
X10.125 Y0. I10. J0. |
feed move arc |
| N290 G01
Y10. |
feed move line |
| N300 G03
X10. Y10.125 I10. J10. |
feed move arc |
| N310 G01
X0. |
feed move line |
| N320 G03
X-0.125 Y10. I0. J10. |
feed move arc |
| N330 G01
Y0. |
feed move line |
| N340 G03
X0. Y-0.125 I0. J0. |
feed move arc |
| N350 G02
X0.125 Y-0.25 I0. J-0.25 |
lead out arc |
| N360 G40 |
set cutter comp
OFF |
| N370 G00
Z-0.5 |
Rapid move to safe
Z level |
| N380 M22 |
device off code |
| N390 G00
X0. Y0. |
move to home position |
| N400 M02 |
end of job code |
Sample GCode File
Drilling, Peck drilling, cutter comp, no cutter
comp
| N10 M90 |
program start |
| N20 G90 |
absolute coordinate
system |
| N30 G75 |
use absolute coordinates
for arc |
| N40 G97 S10000 |
set spindle speed
to 10000 RPM |
| N50 G00 T1 |
select tool # 1 |
| N60 G00 Z-0.5 |
rapid Z move (note
Z negative is UP) |
| N70 G00 X1. Y1. |
rapid XY move |
| N80 M12 |
device on |
| N90 G83 R0.1
Z0.75 D0.2 F1.667 |
peck drill |
| N100 G00 Z-0.5 |
rapid Z move |
| N110 M22 |
device off |
| N120 G00 X2.
Y1. |
rapid XY move |
| N130 M12 |
device on |
| N140 G83 R0.1
Z0.75 D0.2 F1.667 |
peck drill |
| N150 G00 Z-0.5 |
rapid Z move |
| N160 M22 |
device off |
| N170 G00 X3.
Y1. |
rapid XY move |
| N180 M12 |
device on |
| N190 G83 R0.1
Z0.75 D0.2 F1.667 |
peck drill |
| N200 G00 Z-0.5 |
rapid Z move |
| N210 M22 |
device off |
| N220 G00 X4.
Y1. |
rapid XY move |
| N230 M12 |
device on |
| N240 G83 R0.1
Z0.75 D0.2 F1.667 |
peck drill |
| N250 G00 Z-0.5 |
rapid Z move |
| N260 M22 |
device off |
| N270 G00 X5.
Y1. |
rapid XY move |
| N280 M12 |
device on |
| N290 G83 R0.1
Z0.75 D0.2 F1.667 |
peck drill |
| N300 G00 Z-0.5 |
rapid Z move |
| N310 M22 |
device off |
| N320 G97 S12000 |
set spindle speed
to 12000 RPM |
| N330 G00 T11 |
select tool # 11
(a pneumatic drill) |
| N340 G00 Z-0.5 |
rapid Z move |
| N350 G00 X1.
Y4. |
rapid XY move |
| N360 M11 |
fire drill |
| N370 M21 |
retract drill |
| N380 G00 X2.
Y4. |
rapid XY move |
| N390 M11 |
fire drill |
| N400 M21 |
retract drill |
| N410 G00 X3.
Y4. |
rapid XY move |
| N420 M11 |
fire drill |
| N430 M21 |
retract drill |
| N440 G00 X4.
Y4. |
rapid XY move |
| N450 M11 |
fire drill |
| N460 M21 |
retract drill |
| N470 G00 X5.
Y4. |
rapid XY move |
| N480 M11 |
fire drill |
| N490 M21 |
retract drill |
| N500 G97 S18000 |
set spindle speed
to 18000 RPM |
| N510 G00 T2 |
select tool # 2 |
| N520 G00 Z-0.5 |
rapid Z move |
| N530 G00 X-0.5
Y3. |
rapid XY move |
| N540 M12 |
device on |
| N550 G00 Z-0.1 |
rapid Z move |
| N560 G01 Z0.375
F1. |
feed Z move |
| N570 G01 X0.
F6.667 |
linear feed XY move |
| N580 G01 X12. |
linear feed XY move |
| N590 G01 X12.5 |
linear feed XY move |
| N600 G00 Z-0.5 |
rapid Z move |
| N610 M22 |
device off |
| N620 G97 S24000 |
set spindle speed
to 24000 RPM |
| N630 G00 T5 |
select tool # 5 |
| N640 G00 Z-0.5 |
rapid Z move |
| N650 G00 X-0.563
Y-0.187 |
rapid XY move |
| N660 M12 |
device on |
| N670 G00 Z-0.1 |
rapid Z move |
| N680 G01 Z0.75
F1. |
feed down Z move |
| N690 G42 |
turn on cutter comp
right |
| N700 G01 X0.
Y-0.188 F8.333 |
linear feed XY move |
| N710 G01 X12. |
linear feed XY move |
| N720 G03 X12.188
Y0. I12. J0. |
arc feed XY move |
| N730 G01 Y6. |
linear feed XY move |
| N740 G03 X12.
Y6.188 I12. J6. |
arc feed XY move |
| N750 G01 X0. |
linear feed XY move |
| N760 G03 X-0.188
Y6. I0. J6. |
arc feed XY move |
| N770 G01 Y0. |
linear feed XY move |
| N780 G03 X0.
Y-0.188 I0. J0. |
arc feed XY move |
| N790 G02 X0.188
Y-0.375 I0. J-0.375 |
lead out arc |
| N800 G40 |
cutter comp off |
| N810 G00 Z-0.5 |
rapid Z move |
| N820 M22 |
device off |
| N830 G00 X0.
Y0. |
rapid XY move |
| N840 M02 |
End of Job |
|
|