0
0
Ev-technologyHow-ToBeginner · 3 min read

CNC Project for Engraving: Basic G-Code Guide

A CNC project for engraving uses G-code to control the machine's movements and tool actions precisely. The basic commands include G0 for rapid moves, G1 for controlled cutting moves, and M3/M5 to start and stop the spindle. Writing a simple engraving project involves defining the tool path and spindle control in a text file that the CNC machine reads.
📐

Syntax

The basic syntax for a CNC engraving project uses G-code commands:

  • G0 X... Y...: Move the tool quickly to a position without cutting.
  • G1 X... Y... F...: Move the tool slowly to cut along a path at feed rate F.
  • M3: Turn the spindle on (start engraving tool).
  • M5: Turn the spindle off (stop engraving tool).
  • G90: Use absolute positioning for coordinates.
  • G21: Set units to millimeters.

Each line is a command the CNC machine executes in order.

gcode
G21 ; Set units to millimeters
G90 ; Use absolute positioning
M3 ; Spindle on
G0 X0 Y0 ; Move to start
G1 X10 Y0 F100 ; Engrave line
G1 X10 Y10 F100 ; Engrave line
G1 X0 Y10 F100 ; Engrave line
G1 X0 Y0 F100 ; Engrave line
M5 ; Spindle off
G0 X0 Y0 ; Return to start
💻

Example

This example engraves a square path 10mm on each side. It starts the spindle, moves the tool to the start, engraves the square, then stops the spindle and returns to start.

gcode
G21 ; Set units to millimeters
G90 ; Absolute positioning
M3 ; Spindle on
G0 X0 Y0 ; Move to start
G1 X10 Y0 F150 ; Engrave bottom edge
G1 X10 Y10 F150 ; Engrave right edge
G1 X0 Y10 F150 ; Engrave top edge
G1 X0 Y0 F150 ; Engrave left edge
M5 ; Spindle off
G0 X0 Y0 ; Return to home
⚠️

Common Pitfalls

Common mistakes in CNC engraving projects include:

  • Forgetting to turn the spindle on with M3, so no engraving happens.
  • Using rapid moves G0 while the spindle is on, which can damage the tool or material.
  • Not setting units (G21 for mm or G20 for inches), causing wrong scale engraving.
  • Using relative positioning (G91) unintentionally, which can cause unexpected tool paths.

Correct usage example:

G21 ; Set units to mm
G90 ; Absolute positioning
M3 ; Spindle on
G1 X10 Y0 F100 ; Engrave line
M5 ; Spindle off

Wrong usage example (spindle off during engraving):

G1 X10 Y0 F100 ; Engrave line without spindle on
📊

Quick Reference

CommandDescription
G21Set units to millimeters
G90Use absolute positioning
G0Rapid move (no cutting)
G1Controlled move (cutting) with feed rate
M3Spindle on (start engraving)
M5Spindle off (stop engraving)

Key Takeaways

Always start your engraving project by setting units and positioning mode with G21 and G90.
Use M3 to turn the spindle on before cutting and M5 to turn it off after.
Use G0 for fast moves without cutting and G1 with feed rate for engraving paths.
Avoid moving rapidly (G0) while the spindle is on to prevent damage.
Check your coordinate system and units to ensure accurate engraving size.