Grbl

On this page 7

Grbl is an open-source G-code parser and motion control firmware that runs on small microcontrollers, originally the 8-bit ATmega328P found on the Arduino Uno, and turns G-code commands into precisely timed step and direction pulses for stepper motor drivers. In 3D printing & making, and particularly in CNC & laser cutting, it is the most widespread controller firmware for hobby CNC routers, desktop mills and diode laser engravers.

Grbl was started by Simen Svale Skogsrud and later developed for many years by Sungeun Jeon. The classic AVR branch reached version 1.1, which remains a de facto reference, while 32-bit descendants such as grblHAL and FluidNC carry the same command set to faster processors.

How Grbl controls a machine

Grbl works as a real-time motion controller that receives G-code over a serial link from a host computer, interprets each line and executes it as coordinated axis motion. It does not generate toolpaths itself; CAM software produces the G-code, and a separate program called a G-code sender streams it to the controller line by line.

Inside the firmware, a look-ahead motion planner buffers upcoming moves and calculates trapezoidal acceleration profiles across them, so the machine can keep speed through gentle direction changes instead of stopping at every segment. A step generator driven by hardware timers then emits pulses at rates of roughly 30 kHz on the original AVR, which is sufficient for most hobby machines with typical microstepping.

The table below outlines the main functional blocks of the firmware.

BlockFunctionPractical effect
G-code parserValidates and interprets each lineRejects unsupported or malformed commands
Motion plannerBuffers moves, plans accelerationSmooth motion through short segments
Step generatorProduces timed step pulsesAccurate positioning of each axis
Real-time handlerProcesses urgent single-character commandsInstant feed hold, resume and reset
Settings storageKeeps parameters in EEPROMConfiguration survives power cycles
Main functional blocks of Grbl

Configuring Grbl with dollar settings

Grbl is configured through numbered settings prefixed with a dollar sign, which a user types or sends from the host. Sending $$ lists all current values, and a command such as $100=80 sets a parameter directly without recompiling the firmware.

Correct calibration of these settings is essential for dimensional accuracy and safe operation. Steps per millimeter must match the drive mechanics, while maximum rates and accelerations must stay below the point where the steppers lose steps under load.

SettingMeaningTypical consideration
$100 to $102Steps per millimeter for X, Y and ZDepends on pulley, lead screw and microstepping
$110 to $112Maximum rate per axis in mm/minLimited by motor torque and frame rigidity
$120 to $122Acceleration per axis in mm/s²Too high causes lost steps
$130 to $132Maximum travel per axis in mmUsed for soft limits
$22Homing cycle enableRequired for repeatable machine zero
$32Laser mode enableAllows continuous motion with power changes
Important Grbl settings and what they control

Grbl for laser cutting and engraving

Grbl 1.1 introduced a dedicated laser mode that makes the firmware a common choice for diode laser engravers. With laser mode enabled, the controller changes spindle output power without stopping motion, which is necessary for raster engraving where power varies thousands of times per pass.

The M4 command activates dynamic laser power, which scales output with the actual speed during acceleration and deceleration. This prevents darker burns at corners where the head slows down, a typical artifact of constant power set with M3. Laser software such as LightBurn supports Grbl directly and generates G-code tuned to these modes.

Grbl compared with other controller options

Grbl occupies the lightweight, embedded end of the controller spectrum. LinuxCNC runs on a full PC with a real-time kernel and supports complex kinematics, many axes and extensive customization, while Grbl offloads the user interface to a sender and keeps only motion control on the microcontroller.

SolutionHardwareStrengthLimitation
Grbl 1.18-bit ATmega328PSimple, proven, inexpensiveThree axes, limited speed and memory
grblHAL32-bit microcontrollersHigher step rates, more axesBoard-specific builds
FluidNCESP32 boardsWi-Fi, file-based configurationDifferent setup model
LinuxCNCPC with real-time kernelAdvanced kinematics and toolingMore complex installation
Grbl and related CNC control solutions

For a three-axis router or a diode laser, classic Grbl remains adequate. Machines that need a fourth axis, automatic tool changes or very high feed rates benefit from grblHAL or LinuxCNC.

Operating states, alarms and common mistakes

Grbl reports a machine state such as Idle, Run, Hold, Jog or Alarm in response to the ? status query. An Alarm state locks out motion after events such as a triggered limit switch, a failed homing cycle or a reset during movement, and the user must home the machine or send $X to unlock it.

  • Unlocking with $X without homing leaves the controller unaware of the real position, so soft limits cannot protect the machine.
  • Wrong steps per millimeter scale every part incorrectly; calibrate by measuring a known move.
  • Electrical noise on limit switch wires causes false alarms; shielded cable and filtering help.
  • Unsupported G-code, such as tool change commands or canned cycles, triggers error messages and stops the job.

The simple explanation

A CNC machine needs a small brain to move its motors. Grbl is the software inside that brain. A computer sends it simple text instructions. Each one says where to move and how fast. Grbl turns those instructions into exact motor steps.

It is a bit like a translator between a drawing and a pair of hands. The computer plans the work. Grbl makes the motors carry it out smoothly. It is free, small and works on very cheap boards, which is why so many home routers and laser engravers use it.

How it is used in practice

A furniture hobbyist builds a 600 by 600 mm desktop CNC router with stepper motors, GT2 belts on X and Y and a lead screw on Z, controlled by an Arduino Uno with a Grbl-compatible driver shield. After flashing Grbl 1.1, the builder sets steps per millimeter to 80 for the belt axes and 400 for the Z screw.

A test cut of a 100 mm square measures 99.4 mm, so the builder corrects the X and Y values slightly and enables homing with limit switches. The builder also lowers the acceleration to 300 mm/s² after hearing missed steps during fast moves.

The router now cuts drawer pulls from 18 mm oak using G-code from a CAM program, streamed through a desktop sender. Later, the builder mounts a diode laser, enables laser mode with $32=1 and engraves logos on the same machine with dynamic M4 power.