3dSynth

Tutorials / Custom G-code

Open in the interactive tutorials reader

---
title: Tutorial 15 Using G2 / G3 (Arcs)
description: True Arcs. The cleanest way to draw circles.
---

Tutorial 15 Using G2 / G3 (Arcs)

1. Lesson Header

2. Concept Introduction

The Native Curve.
Instead of 100 straight lines (G1), we can tell the firmware: "Draw an arc from here to there with this center point."
- G2: Clockwise Arc (CW).
- G3: Counter-Clockwise Arc (CCW).

3. Machine State Explanation

Why Arcs?
- Smaller Files: 1 line vs 1000 lines.
- Smoother Motion: The planner knows it's a curve, so it can maintain constant velocity (no corner deceleration).
- Better Finish: No "facets" on the print surface.

4. Command Breakdown

The Syntax

G2 X[end] Y[end] I[offset_to_center_X] J[offset_to_center_Y]

5. Minimal Working Example

A Quarter Circle.
Start: 0,0.
End: 10,10.
Center: 10,0. (So Radius is 10).
Direction: Counter-Clockwise (G3).

G1 X0 Y0
G3 X10 Y10 I10 J0

6. Visual Representation

Interactive preview is available in the interactive reader.

The arc sweeps from Start to End around the Center.

7. Build Exercise

Task: Draw a full circle (Radius 20mm) centered at X=100, Y=100.
We can't do a full 360 in one G2 command reliably on all firmwares.
Standard practice: Break it into 4 quadrants (90 degrees each).

  1. Start at (120, 100). (Right edge).
  2. Arc to (100, 120). (Top edge). Center is at (100,100).
  3. Arc to (80, 100). (Left edge).
  4. ...and so on.

Solution:

; Move to Start (Right edge)
G1 X120 Y100
; Q1 (Top-Right)
G3 X100 Y120 I-20 J0
; Q2 (Top-Left)
G3 X80 Y100 I0 J-20
; Q3 (Bottom-Left)
G3 X100 Y80 I20 J0
; Q4 (Bottom-Right)
G3 X120 Y100 I0 J20

8. Deep Insight Section

I and J are Relative.
This is the most confusing part.
I and J are relative distances from the current nozzle position to the center of the circle.
They are NOT absolute coordinates of the center.
If you are at X=10, and the center is at X=15, then I=5.

9. Common Failure Modes

  1. "Radius to End of Arc Differs from Radius to Start": If your math is slightly off (e.g., floating point error), the distance from Center to Start != distance from Center to End. Marlin will throw an error and stop.
  2. Wrong Direction: Using G2 instead of G3 makes the arc go the "long way" or "wrong way" around.

10. Real-World Application

CNC Machining.
G2/G3 are standard in CNC milling.
In 3D printing, slicers ignored them for years because 8-bit microcontrollers struggled with the math (sqrt, sin, cos).
Modern 32-bit boards handle arcs easily, and "Arc Welder" plugins are popular to compress G-code.

11. Final Clean Version

Save this as lesson15.gcode.

; Lesson 15 - The Perfect Circle
G28
G1 Z0.3
G1 F3000

; Move to Center (Visual reference only)
G1 X100 Y100
G1 Z5 ; Lift
G1 Z0.3 ; Drop

; Move to Start of Circle (Radius 20)
G1 X120 Y100

; Draw Circle (CCW)
; I/J are relative offsets to center (100,100)
; From (120,100), Center is at X-20, Y0. So I-20 J0.
G3 X100 Y120 I-20 J0  ; Q1
G3 X80 Y100 I0 J-20   ; Q2
G3 X100 Y80 I20 J0    ; Q3
G3 X120 Y100 I0 J20   ; Q4

; Draw Smaller Circle (CW) inside
G1 X110 Y100
; From (110,100), Center is at X-10, Y0. So I-10 J0.
G2 X100 Y90 I-10 J0   ; Q4 (CW goes down)
G2 X90 Y100 I0 J10    ; Q3
G2 X100 Y110 I10 J0   ; Q2
G2 X110 Y100 I0 J-10  ; Q1

G28 X0 Y0

12. Stretch Challenge

Challenge: Draw a Figure-8 using two tangent circles.
Circle 1: Center (50,50), Radius 20.
Circle 2: Center (90,50), Radius 20.
Start at the touching point (70,50).
Go CCW around Circle 1, then CW around Circle 2.

Answer Key:

G1 X70 Y50
; Left Circle (CCW)
G3 X70 Y50 I-20 J0
; Right Circle (CW)
G2 X70 Y50 I20 J0