Beginner-Friendly CNC Program Example Library

Beginner-Friendly CNC Program Example Library

Simple G-Code Examples with Easy Explanations

Before running any CNC program, it’s important to understand machine coordinates, tool direction, and safe movements. The examples below are written in simple, industry-standard G-code, suitable for beginners.

Example 1: CNC Program to Move Tool in a Square (Basic Milling)

Purpose

This program helps beginners understand:

  • X and Y axis movement
  • G00 (rapid move)
  • G01 (cutting move)

Program Code

%
O1001 (SQUARE CUT PROGRAM)
G21         (Metric units)
G90         (Absolute positioning)
G17         (XY plane selection)

G00 X0 Y0   (Move to start point)
G00 Z5      (Tool above workpiece)

G01 Z-2 F100 (Cutting depth)
G01 X50 Y0 F200
G01 X50 Y50
G01 X0 Y50
G01 X0 Y0

G00 Z5
M30
%

Explanation

  • G21 → Sets units to millimeters
  • G90 → Absolute positioning (coordinates from zero point)
  • G01 Z-2 → Tool cuts 2mm deep
  • The tool moves in a square of 50 × 50 mm

Best for: First CNC milling practice

Example 2: CNC Drilling Program (Single Hole)

Purpose

Learn how to drill a hole using CNC safely.

Program Code

%
O1002 (DRILLING PROGRAM)
G21
G90
G00 X25 Y25
G00 Z5

G01 Z-10 F80
G00 Z5

M30
%

Explanation

  • Hole position: X25 Y25
  • Hole depth: 10 mm
  • F80 → Slow feed for drilling

📌 Tip: Always use slow feed rates for drilling to protect the tool.

Example 3: CNC Linear Cutting (Straight Slot)

Purpose

Understanding straight-line cutting in CNC machining.

Program Code

%
O1003 (STRAIGHT SLOT)
G21
G90

G00 X10 Y10
G00 Z5

G01 Z-3 F100
G01 X80 Y10 F250

G00 Z5
M30
%

Explanation

  • Cuts a straight slot from X10 to X80
  • Depth of cut = 3 mm
  • Good example for learning feed control

Example 4: CNC Circular Motion (G02 / G03)

Purpose

Learn circular cutting (very important skill).

Program Code (Clockwise Circle)

%
O1004 (CIRCULAR CUT)
G21
G90

G00 X50 Y25
G00 Z5

G01 Z-2 F100
G02 X50 Y25 I-25 J0 F200

G00 Z5
M30
%

Explanation

  • G02 → Clockwise circular movement
  • I & J → Distance from center point
  • Used for round pockets and profiles

⚠️ Practice this in simulation first!

Example 5: Simple CNC Lathe Facing Program

Purpose

Basic CNC turning operation (Facing).

Program Code

%
O2001 (LATHE FACING)
G21
G90

G00 X50 Z5
G01 Z0 F150
G01 X0

G00 X60 Z10
M30
%

Explanation

  • Removes material from the front face
  • X-axis → Diameter
  • Z-axis → Length

✅ Best for CNC lathe beginners

Example 6: Safe CNC Program Structure (Best Practice)

Always Follow This Order

1. Units (G20 / G21)
2. Positioning (G90 / G91)
3. Plane selection (G17)
4. Rapid move (G00)
5. Cutting move (G01 / G02 / G03)
6. Tool retract
7. Program end (M30)

This structure prevents:

  • Tool crashes
  • Wrong cutting depth
  • Machine errors

Common Beginner CNC Mistakes (Avoid These)

❌ Forgetting Z-safe height
❌ Using high feed rates
❌ Skipping simulation
❌ Wrong coordinate zero
❌ Not checking tool direction

✔ Always dry-run your program first.

Free Tools to Practice CNC Programming

Tool NameUse
NC ViewerOnline G-code simulation
Fusion 360CAD + CAM
Mach3CNC machine control
LinuxCNCOpen-source CNC software

Final Tip for Beginners

“First understand tool movement, then understand cutting.”

If you master G00, G01, G02, and G03, you already know 70% of CNC programming.

Leave a Reply

Your email address will not be published. Required fields are marked *