G Code for Milling Slot: Syntax, Example & Tips
To mill a slot using
G-code, use G1 for linear cutting moves combined with X, Y, and Z coordinates to define the slot path and depth. Typically, you start with a rapid move (G0) to the slot start, then use G1 to cut along the slot length and width at the desired feed rate.Syntax
The basic G-code commands for milling a slot include:
G0: Rapid move to position without cutting.G1: Linear move with cutting at a set feed rate.X, Y: Coordinates for horizontal movement.Z: Coordinate for vertical movement (depth).F: Feed rate (speed of cutting).
Use G0 to position the tool above the slot start, then G1 to plunge into the material and move along the slot path.
gcode
G0 X10 Y10 Z5 ; Rapid move above slot start G1 Z-2 F100 ; Plunge into material 2mm deep at feed rate 100 G1 X50 Y10 F200 ; Cut slot length G1 X50 Y20 ; Cut slot width G1 X10 Y20 ; Cut back along width G1 X10 Y10 ; Complete slot rectangle G0 Z5 ; Retract tool
Example
This example mills a rectangular slot 40mm long, 10mm wide, and 2mm deep. It starts by moving the tool above the slot, plunges into the material, cuts the slot perimeter, and then retracts.
gcode
G21 ; Set units to millimeters G90 ; Absolute positioning G0 X10 Y10 Z5 ; Move above slot start G1 Z-2 F100 ; Plunge 2mm deep G1 X50 Y10 F200 ; Cut slot length G1 X50 Y20 ; Cut slot width G1 X10 Y20 ; Cut back width G1 X10 Y10 ; Close slot G0 Z5 ; Retract tool M30 ; Program end
Common Pitfalls
Common mistakes when milling slots include:
- Not setting the correct
Zdepth, causing incomplete cuts or tool damage. - Using
G0(rapid move) for cutting moves, which can damage the tool or material. - Forgetting to set the feed rate
Fduring cutting moves. - Not retracting the tool safely after cutting.
Always use G1 for cutting moves with a proper feed rate and confirm the depth is safe for your tool and material.
gcode
Wrong: G0 Z-2 ; Rapid plunge (dangerous) Right: G1 Z-2 F100 ; Controlled plunge
Quick Reference
| Command | Description |
|---|---|
| G0 | Rapid move (no cutting) |
| G1 | Linear cutting move with feed rate |
| X, Y | Horizontal coordinates |
| Z | Vertical coordinate (depth) |
| F | Feed rate (cutting speed) |
| G21 | Set units to millimeters |
| G90 | Absolute positioning mode |
| M30 | End of program |
Key Takeaways
Use G1 with feed rate for all cutting moves to mill slots safely.
Start with G0 to position the tool above the slot before plunging.
Set the correct Z depth to avoid tool damage or incomplete cuts.
Always retract the tool with G0 after finishing the slot.
Use absolute positioning (G90) and millimeter units (G21) for clarity.