Change Modes

G20 G-code

G20 means “all moves starting now have their units specified in inches (imperial units).”

G20’s evil twin is G21, which means “all moves starting now have their units specified in millimeters (metric units),” which is the default when Smoothie starts.

An inch is 25.4 millimeters.

Format

The command is used as such:

G20

Which means: units are now imperial until another G-code changes it (modal command).

Parameters

No parameters.

V1 and V2 Compatibility

V1 Implementation:

The G20 command in Smoothieware V1 sets all subsequent motion commands to use imperial units (inches).

  • Source: Robot.cpp line 456
  • Function: push_state() modal command
  • Behavior: Sets modal_group_1 mode to imperial
  • Duration: Persists until G21 is sent or machine is powered off
  • Default: V1 starts in G21 (metric) mode
  • Fully supported - Fundamental G-code that is always available

V2 Implementation:

The G20 command in Smoothieware V2 maintains identical behavior to V1.

  • Source: Robot.cpp line 768
  • Function: push_state() modal command (identical to V1)
  • Behavior: Sets modal_group_1 mode to imperial
  • Duration: Persists until G21 is sent or machine is powered off
  • Default: V2 starts in G21 (metric) mode
  • Fully supported - Identical implementation to V1

Status: Identical implementation across V1 and V2 - no behavioral differences.

  • G21 - Set units to metric (millimeters)
  • G0 - Rapid positioning
  • G1 - Linear interpolated motion

Further reading

These resources are used as references for Gcode:

This is a wiki! If you'd like to improve this page, you can edit it on GitHub.