3dSynth

Tutorials / Custom G-code

Open in the interactive tutorials reader

---
title: Tutorial 3 Movement Commands
description: How to control speed and precision.
---

Tutorial 3 Movement Commands

1. Lesson Header

2. Concept Introduction (Why It Matters)

Purpose: Understand that not all movement is equal.

In Lesson 1, we learned G1. But there are actually two ways to move:
1. G0 (Rapid): "Get there as fast as possible. I don't care how."
2. G1 (Linear): "Move in a straight line at a specific speed."

Think of G0 like teleporting in a video game (travel).
Think of G1 like driving a car (printing).

When you are printing plastic, speed matters. Too fast, and the plastic won't stick. Too slow, and it melts everything. This is controlled by Feedrate (F).

3. Machine State Explanation

Feedrate is Modal.
This means if you set F3000 on one line, the machine will keep moving at 3000mm/min until you tell it otherwise.

Units Matter.
- G20: Inches (Rarely used in 3D printing).
- G21: Millimeters (Standard).
- Feedrate Units: Usually Millimeters per Minute (mm/min).
- F60 = 1mm per second.
- F3000 = 50mm per second.

4. Command Breakdown

The Rapid Move (G0)

Used for non-printing moves (travel). - Syntax: G0 X[value] Y[value] - Behavior: Moves at the machine's maximum speed. Often ignores F values.

The Linear Move (G1)

Used for printing moves. - Syntax: G1 X[value] Y[value] F[value] - Behavior: Moves in a straight line at speed F.

Set Units (G20 / G21)

- G20: Inches. - G21: Millimeters. (Always use this!)

5. Minimal Working Example

Let's move fast to a start point, then slow down to "draw."

; Lesson 3 - Speed Control
G21        ; Millimeters
G90        ; Absolute Positioning
G28        ; Home

; Rapid Travel
G0 Z5      ; Lift Z fast
G0 X10 Y10 ; Go to start point fast

; Slow Drawing
G1 Z0.2 F300 ; Lower nozzle slowly (300mm/min)
G1 X60 Y10 F1500 ; Draw line to X60 at 25mm/s

Line-by-Line:
1. G0 X10 Y10: The machine zips to the start.
2. G1 Z0.2 F300: We lower the nozzle carefully. F300 ensures we don't smash into the bed.
3. G1 X60 Y10 F1500: We move sideways at a moderate printing speed.

6. Visual Representation

Imagine a pen plotter.

Interactive preview is available in the interactive reader.

7. Build Exercise

Task: Draw a 50mm square.
1. Rapid move (G0) to X50 Y50.
2. Move (G1) around the square at F1200 (20mm/s).
3. Rapid move (G0) back to 0,0 (Home).

Remember to set G21 and G90 first!

...

Solution:

G21
G90
G28

; Travel to Start
G0 Z5
G0 X50 Y50

; Draw Square
G1 F1200     ; Set speed once
G1 X100 Y50  ; Right
G1 X100 Y100 ; Back
G1 X50 Y100  ; Left
G1 X50 Y50   ; Front (Close Loop)

; Go Home
G0 Z10       ; Lift
G0 X0 Y0     ; Rapid Home

8. Deep Insight Section

Why separate G0 and G1?

In modern 3D printer firmware (Marlin, Klipper), G0 is often treated exactly the same as G1. The machine just uses its "Max Travel Speed" setting for G0.

However, in CNC Machining, the distinction is critical. G0 moves all axes as fast as possible independently, meaning the path might be a "dog-leg" (not straight). G1 guarantees a straight line.

Even though 3D printers handle them similarly, using G0 for travel and G1 for printing makes your code readable and professional. It tells the reader (and the machine): "I am not printing here."

9. Common Failure Modes

  1. Forgot the F value: If you write G1 X100 without ever setting F, the machine might move at the last used speed (which could be super slow from a previous print, or super fast from a travel move). Always set F explicitly at the start of a print.
  2. Confusing mm/min with mm/s: Slicers often show speed in mm/s (e.g., 60mm/s). G-code uses mm/min.

10. Real-World Application

"Travel Moves" in Slicers

In your slicer preview, you often see "Travel" lines in blue or purple. These are G0 commands. The slicer tries to minimize these because they are wasted time.

Optimization algorithms (like "Comb Mode" in Cura) try to keep these travel moves inside the object so stringing doesn't show. This is just clever path planning using G0 commands.

11. Final Clean Version

Save this as lesson3.gcode.

; Lesson 3 - The Speedy Square
; Setup
G21        ; Millimeters
G90        ; Absolute Positioning
G28        ; Home

; Move to Start
G0 Z5 F3000 ; Lift Z fast
G0 X50 Y50  ; Rapid to start corner

; The Square (Printing Speed)
G1 F1200     ; Set printing speed (20mm/s)
G1 X100 Y50  ; Leg 1
G1 X100 Y100 ; Leg 2
G1 X50 Y100  ; Leg 3
G1 X50 Y50   ; Leg 4

; Finish
G0 Z20       ; Lift clear
G0 X0 Y200   ; Present print (Park)

12. Stretch Challenge

Challenge: Create a "Ramp up" movement.
Move 100mm in X, but increase speed every 25mm.
- 0-25mm: Slow (F500)
- 25-50mm: Medium (F1500)
- 50-75mm: Fast (F3000)
- 75-100mm: Turbo (F6000)

Answer Key:

G1 X25 F500
G1 X50 F1500
G1 X75 F3000
G1 X100 F6000