Supported G-Codes

Smoothie is primarily a G-code interpreter.

Here is a list of the G-codes that are currently supported:

Make sure your Gcode is in uppercase, separation by space characters is optional, as shown everywhere on this wiki. For example:

G1 X10 F100

Lowercase is reserved for commands.

G codes

G-Code Description Example
G0 Move to the given coordinates. To the contrary of G1, if there is a tool it will most of the time be off during this kind of move. This is a “go to” move rather than a “do while going to” move. The F parameter defines speed and is remembered by subsequent commands ( specified in millimetres/minute ) (command is modal) G0 X10 Y5 F100
G1 Move to the given coordinates, see above for difference with G0. Takes the same F parameter as G0. (command is modal) G1 X20 Y2.3 F200
G2 Clockwise circular motion: go to point with coordinates XYZ while rotating around point with relative coordinates IJ (command is not modal) G2 X10 J5
G3 Counter-clockwise motion: see above (command is not modal) G3 Y5 X10 I2
G4 Dwell S or P, In grbl mode P is float seconds to comply with gcode standards G4 P1000
G10 Do firmware extruder retract G10
G11 Do firmware extruder un-retract G11
G10 L1 Set extruder tool offset for specified extruder where Pn is the extruder number + 1 (T0 is P1, T1 is P2), This stays set until reset. Permanent change must be added to config, Only active when multiple extruders have been defined G10 L1 P2 X10
G10 L2, G10 L20 Set workspace coordinates LinuxCNC G10 L2 and LinuxCNC G10 G10 L2 P1 X0
G17 Select XY plane for arc commands (G2/G3) (command is modal) G17
G18 Select XZ plane (command is modal) G18
G19 Select YZ plane (command is modal) G19
G20 Inch mode: passed coordinates will be considered as Inches, so internally translated to millimeters (command is modal) G20
G21 Millimeter mode (default) : passed coordinates will be considered as millimeters (command is modal) G21
G28 Home The given axis, or if no axis specified home all axis at the same time (edge) NOTE in CNC/grbl mode this is move to park position, use $H to home G28
G28.1 Set Predefined Position - This position will be returned to by G28.2 G28.1
G28.2 Move to Predefined Position - This perform a rapid move to the Predefined position set by G28.1 (in grbl mode this will do a home) G28.2
G28.3 Manual Homing - This allows you to set a home position manually without moving to limit switches G28.3
G28.4 V2 Only - Manual Homing based on actuator position. This allows you to set a home position manually based on actuator position (used for rotary delta) G28.4
G28.5 Clears the homed flag for the specified axis, or all if not specifed G28.5 G28.5 Z0
G28.6 Shows the homing status of each axis G28.6
G28.7 V2 Only - Home slaved axis. For dual-motor axes (e.g., dual Z motors), homes the secondary motor independently G28.7 Z
G29 Bed probe test - probes bed and reports heights. Behavior depends on levelling strategy (ThreePoint/DeltaGrid/CartGrid), see ZProbe G29
G30 Simple Z probe at current XY, reports distance moved down until probe triggers. optional F parameter defines the speed of probing, zprobe.slow_feedrate is used when not supplied G30 G30 F100
G31 Leveling strategy command - probes grid and activates compensation, or reports status (ThreePoint). Depends on levelling strategy, see ZProbe G31
G32 Depends on levelling strategy selected, see ZProbe. For calibration on delta, uses Z probe to calibrate delta endstops and arm radius, use R parameter to select only arm radius calibration and E to select only endstop calibration. I to set target precision, J to set probe_radius, K to keep current endstop trim settings. In Zgrid module, it starts the grid probing G32 G32 R G32 E G32 EK G32 I0.02
G33 V2 Only - Lathe threading with spindle synchronization. For CNC lathe operations, synchronizes tool feed with spindle rotation for cutting uniform threads G33 Z10 K2.0
G38.2 G38.3 G38.4 G38.5 Standard probe commands implemented as documented here G38.2 Z-10
G43.2 Baby steps G43.2 Z0.05
G53 Must be on a line by itself OR the first G code on a line, the directly following G0/G1 will be executed in MCS coordinates G53 G0 X0 Y0
G54 Select work coordinate system 1 (default) G54
G55 Select work coordinate system 2 G55
G56 Select work coordinate system 3 G56
G57 Select work coordinate system 4 G57
G58 Select work coordinate system 5 G58
G59 Select work coordinate system 6 G59
G59.1 Select work coordinate system 7 G59.1
G59.2 Select work coordinate system 8 G59.2
G59.3 Select work coordinate system 9 G59.3
G90 Absolute mode (default) (command is modal) G90
G91 Relative mode (command is modal) G91
G92 Set global workspace coordinate system to specified coordinates LinuxCNC G92 G92 X0 Y0 Z0
G92.1 Clear the G92 and G30 Znnn offsets G92.1
G92.4 manually set homing (MCS) for XYZ G92.4 X0 Y0 Z0
G94 Feedrate mode (motion per minute) - standard modal command for feedrate units (mm/min) G94
G Code comments

G Code comments begin at a semicolon, and end at the end of the line.

Example:
G0 X7 Y8 ;this is the comment

M codes

M-Code Description Example
M0 Program stop - pauses execution unconditionally until user intervention M0
M1 Sleep or conditional stop - pauses execution (may be ignored if optional stop disabled) M1
M3 Spindle on, clockwise - starts spindle or laser at specified speed (S parameter in RPM or %) M3 S12000
M5 Spindle/laser/tool stop M5
M9 Turn off coolant/auxiliary output M9
M17 Enable/power all stepper motors M17
M18 Disable all stepper motors (same as M84) M18
M20 List SD card contents. Optional S parameter for output style, P for directory path M20 S0
M21 Initialize/mount SD card M21
M23 Select SD file for printing (must be followed by M24 to start) M23 filename.gcode
M24 Start or resume SD print M24
M25 Pause SD print M25
M26 Abort SD print. Optional S parameter for byte position in file M26 S1024
M27 Report SD print progress M27
M30 Delete file from SD card M30 old_file.gcode
M32 Select and immediately start SD file M32 print.gcode
M82 Set extruder to absolute mode M82
M83 Set extruder to relative mode M83
M84 Stop idle hold - disable stepper motors (S parameter sets timeout in seconds) M84 S600
M92 Set axis steps per unit - calibrate steps/mm for X, Y, Z, E axes M92 X80 Y80 Z400 E93
M104 Set extruder temperature without waiting (S parameter in °C) M104 S200
M105 Get temperature reading - reports current and target temps for all modules M105
M109 Set extruder temperature and wait until reached (S parameter in °C) M109 S190
M112 Emergency stop - instantly halts all operations, turns off heaters, loses position M112
M114 Report current position of all axes M114
M119 Get endstop status - reports state of all endstop switches M119
M140 Set bed temperature without waiting (S parameter in °C) M140 S60
M143 Set maximum allowable temperature (S parameter in °C) M143 S250
M190 Set bed temperature and wait until reached (S parameter in °C) M190 S60
M200 Set filament diameter for volumetric extrusion (D parameter in mm) M200 D1.75
M203 Set maximum feedrate for axes (X, Y, Z, E in mm/min) M203 X18000 Y18000 Z1000 E9000
M204 Set acceleration - S for default, P for print, T for travel (in mm/s²) M204 S3000 P3000 T3000
M207 Configure firmware retraction - S length, F feedrate, Z lift M207 S4 F3000 Z0.5
M208 Configure firmware unretraction - S recover length, F feedrate M208 S0 F3000
M220 Set speed factor override percentage (S100 = normal speed) M220 S100
M221 Set flow rate/extrusion percentage override (S100 = normal flow) M221 S95
M301 Set PID controller parameters - P (Kp), I (Ki), D (Kd) M301 P22.2 I1.08 D114.0
M303 PID autotune - automatically calibrate PID. E for extruder (-1=bed), S target temp, C cycles M303 E0 S200 C8
M305 Configure temperature sensor - P heater number, T thermistor resistance, B beta M305 P0 T100000 B4138
M306 Set homing offset using current position (Z parameter in mm). Must follow with M500 to save M306 Z0
M408 Status query command - returns machine status for PanelDue (S parameter for response type) M408 S0
M500 Save configuration to SD card - persists calibration and config changes M500
M501 Restore settings from SD card M501
M503 Report current settings M503
M600 Suspend print - pauses execution, turns off heaters (configurable), allows jogging M600
M601 Resume print after M600 suspension M601
M665 Config override (Delta) - set Z height, diagonal rod (L), delta radius (R). Use M500 to save M665 L250 R140 Z297.5
M951 LED test - diagnostics command M951
M952 Error dump - output error statistics M952
M957 Report spindle status M957
M958 Set spindle parameters (P for PWM percentage) M958 P50
M911 V2 Only - Direct TMC stepper driver register access via SPI. Read all driver status with no parameters, write/read specific registers with S and V parameters M911
M911.1 V2 Only - Write TMC register. S parameter specifies register, V parameter specifies value to write M911.1 S V
M999 Clear halt state after emergency stop (M112) or kill button. Position lost - must re-home M999
M1000 Generic command wrapper - send console commands from G-code M1000 fire 50
M1234 Undocumented M-code (purpose unknown) M1234

Additional Codes

The Smoothieware configuration file permits the association of additional codes with some tool functions. For example, for a Switch module, you can specify an arbitrary command in the ‘input_on_command’ and ‘input_off_command’. This means that some additional codes may be available, depending on your specific configuration file.

For example, if you are using servos, then you will likely have configured the following commands:

G-Code Description Example  
M280 Move servo to S where position is 0-100 M280 S20 ; move servo to position 20 = 20% duty cycle  
M281 Turn off servo M281 ; Same as M280 S0 0% duty cycle, effectively off  

Additionally, in your configuration, you can assign sub-commands to deal with multiple tools of the same type, for example:

G-Code Description  
M280.1 Move your first servo  
M280.2 Move your second servo  

Tool change

Tn will change the tool to n for all future commands, it may appear anywhere on the line or on a line by itself:

T1 M200

M200 T1

NOTE This is not compatible with the G-code spec, but unfortunately most slicers create incorrect Gcode for tool change.

Important: In smoothie there must be a space in front of a line that is affected by a modal G code. Some G code processors like HeeksCNC don't prefix the space neither do they prefix each line with the modal G code.
This is a wiki! If you'd like to improve this page, you can edit it on GitHub.