Other Useful Commands#
Pause (G4)#
G4 inserts a pause in the G-code. It is also called “dwell”.
G4 P3 - a 3-second pause
G4 P0.5 - a half-second pause
This is useful for example when you want to insert a pause in the G-code to allow the spindle to get up to speed. Make sure you don’t pause during actual cutting. If the tool spins in one place for long, it could burn the material and start a fire.
Note: The number in the P parameter is in seconds for Grbl. Other firmware may expect the value to be in milliseconds.
Warning: Some 32-bit versions of Grbl do not handle the G4 command correctly. Test it well before relying on it in your G-code.
In case your machine doesn’t support it, a partial workaround is to issue a short move at a very slow feed rate. The command “G1 G91 G21 Z0.1 F1” will move up 0.1 mm over a couple of seconds. For a longer delay, you can add a second command that moves back down by -0.1 mm.
Keep in mind that the part “G91 G21” will modify the parser state. You may need to include an additional line to restore the expected state to absolute move (G90) or inches (G20) if the rest of the program assumes it.
Only do this if you have a good understanding of how G-code works.
Set work offset (G10)#
G10 lets you set the offset between the machine origin and the work origin. It has two flavors - L2 and L20.
- L2 sets the explicit offset between the coordinate systems
- L20 sets the current position to match the given coordinate value. This is more commonly used in practice
A few examples
G10 L2 P0 G21 X100 - sets the X offset to be 100 mm (work 0 mm will match machine 100 mm)
G10 L20 P0 X0 - sets the work zero for X to be the current position
G10 L20 P0 G21 Z15 - sets the work zero for Z to be 15 mm below the current position
The last command is often used when Z probing to set the Z zero at the bottom of the probe plate after locating the top of the plate.
Note: G10 doesn’t cause any movement to occur. The command simply changes the offset of the work coordinate system.
Note: You should always specify P0 (which means “current coordinate system”), as well as G21 or G20 to select the correct distance units.
Spindle control (M3, M5)#
M3 starts the spindle and M5 stops it.
M3 - start the spindle using a previously set speed value
M3 S12000 - start the spindle at speed 12000 RPM
Show parser state ($G)#
The $G command prints the current parser state to the console
[GC:G0 G54 G17 G21 G90 G94 M5 M9 T0 F500 S0]
Show Grbl settings ($$)#
The $$ command lists the current Grbl settings. The exact text will depend on the sender software, but it should look something like this:
$0=10 ;Step pulse time, microseconds
$1=255 ;Step idle delay, milliseconds
...
$131=400.000 ;Y-axis maximum travel, millimeters
$132=100.000 ;Z-axis maximum travel, millimeters
Examining your settings for suspicious values is often the first step when troubleshooting.