0
0
3D Printingknowledge~6 mins

Common G-code commands (G0, G1, G28, M104, M106) in 3D Printing - Full Explanation

Choose your learning style9 modes available
Introduction
When controlling a 3D printer, you need clear instructions to tell it how to move and operate. These instructions come as simple codes that the printer understands to perform tasks like moving the print head or heating the nozzle.
Explanation
G0 - Rapid Movement
G0 commands tell the printer to move the print head quickly to a new position without extruding any material. This is used to reposition the head between printing areas to save time. The printer moves as fast as possible along the specified coordinates.
G0 moves the print head fast without printing.
G1 - Controlled Movement with Extrusion
G1 commands move the print head to a new position while extruding filament to build the object layer by layer. The speed and amount of material extruded are controlled precisely to create accurate shapes. This is the main command used during printing.
G1 moves the print head while pushing out filament to print.
G28 - Auto Home
G28 sends the print head to its home position, usually the corner of the printer bed. This resets the printer’s position sensors so it knows exactly where the head is before starting a print. It ensures accurate printing by starting from a known point.
G28 moves the print head to the home position to reset location.
M104 - Set Nozzle Temperature
M104 sets the temperature of the printer’s nozzle to a specific value but does not wait for it to reach that temperature before continuing. This command prepares the nozzle to melt the filament for printing. It allows the printer to heat up while doing other tasks.
M104 sets the nozzle temperature without waiting.
M106 - Fan On
M106 turns on the cooling fan at a specified speed to help solidify the printed material quickly. Cooling is important to prevent warping and improve print quality. The fan speed can be adjusted from off to full power.
M106 controls the cooling fan speed during printing.
Real World Analogy

Imagine you are painting a wall. G0 is like moving your brush quickly to a new spot without painting. G1 is moving the brush slowly while applying paint. G28 is stepping back to the corner of the room to start fresh. M104 is turning on the heater to warm the paint so it spreads well. M106 is turning on a fan to help the paint dry faster.

G0 - Rapid Movement → Moving your brush quickly without painting
G1 - Controlled Movement with Extrusion → Moving your brush slowly while applying paint
G28 - Auto Home → Stepping back to the corner to start fresh
M104 - Set Nozzle Temperature → Turning on the heater to warm the paint
M106 - Fan On → Turning on a fan to dry the paint faster
Diagram
Diagram
┌───────────────┐
│   Start Print │
└──────┬────────┘
       │
       ▼
┌───────────────┐       ┌───────────────┐
│     G28       │──────▶│   G0 Move     │
│  Auto Home    │       │ Rapid Position │
└──────┬────────┘       └──────┬────────┘
       │                       │
       ▼                       ▼
┌───────────────┐       ┌───────────────┐
│    M104       │       │     G1 Move   │
│ Set Nozzle    │       │ Controlled    │
│ Temperature   │       │ Movement +    │
└──────┬────────┘       │ Extrusion     │
       │                └──────┬────────┘
       ▼                       │
┌───────────────┐              ▼
│    M106       │       ┌───────────────┐
│  Fan On       │       │   Printing    │
│ (Cooling)     │       │   Process     │
└───────────────┘       └───────────────┘
This diagram shows the flow of common G-code commands during a 3D print, from homing to moving, heating, cooling, and printing.
Key Facts
G0Moves the print head quickly without extruding filament.
G1Moves the print head while extruding filament to print.
G28Moves the print head to the home position to reset coordinates.
M104Sets the nozzle temperature without waiting for it to reach the target.
M106Turns on the cooling fan at a specified speed.
Common Confusions
Believing G0 extrudes filament like G1.
Believing G0 extrudes filament like G1. G0 only moves the print head quickly without pushing filament; extrusion happens only with G1.
Thinking M104 waits for the nozzle to heat before continuing.
Thinking M104 waits for the nozzle to heat before continuing. M104 sets the temperature but does not pause the printer; M109 is the command that waits.
Assuming G28 moves the print head to any position.
Assuming G28 moves the print head to any position. G28 always moves the head to the predefined home position to reset coordinates.
Summary
G0 moves the print head quickly without printing, while G1 moves it precisely with filament extrusion.
G28 resets the printer’s position by moving the head to the home corner before printing starts.
M104 sets the nozzle temperature without waiting, and M106 controls the cooling fan speed.