Configuring Grbl

Grbl has the neat ‘$’-command to tweak the settings at runtime.

Connect to Grbl using the serial terminal of your choice (baud rate 9600 unless you changed that in config.h).

Once connected you should get the Grbl-prompt. Write $ and press enter. You should see something like this:

$0 = 400.0 (steps/mm x) $1 = 400.0 (steps/mm y) $2 = 400.0 (steps/mm z) $3 = 30 (microseconds step pulse) $4 = 480.0 (mm/sec default feed rate) $5 = 480.0 (mm/sec default seek rate) $6 = 0.100 (mm/arc segment) $7 = 0 (step port invert mask. binary = 0) $8 = 25 (acceleration in mm/sec^2) $9 = 300 (max instant cornering speed change in delta mm/min)

To change e.g. the microseconds step pulse option to 50us you would do this:
>> $3=50
The settings are stored in eeprom and will be retained forever or until you change them.

$0, $1 and $2 – Steps/mm

Grbl needs to know how far each step will take the tool in reality. To calculate steps/mm for an axis of your machine you need to know:

  1. The turns per mm of the lead screw
  2. The full steps per revolution of your steppers (typically 200)
  3. The microsteps per step of your controller (typically 1, 8 or 16)

The steps/mm can then be calculated like this

steps_per_mm = (steps_per_revolution*microsteps)/turns_per_mm

Do this for every axis.

$3 – Microseconds/step pulse

Stepper drivers are rated for a certain minimum step pulse length. Check the data sheet or just try some numbers. You want as short pulses as the stepper drivers can reliably recognize. If the pulses are too long you might run into trouble running the system at high feed rates. Generally something between 20 and 50 microseconds works.

$5 – default feed rate

When running G-code this setting will usually not enter into the picture as all feed rates will be specified in the file. I set these to the highest practical feed rates.

$6 – mm/arc segment

Grbl renders circles and arcs by subdividing them into teeny tiny lines. You will probably never need to adjust this value – but if you find that your circles are too crude (really? one tenth of a millimeter is not precise enough for you? Are you in nanotech?) you may adjust this. Lower values gives higher precision but may lead to performance issues.

$7 – invert mask

My cnc-stepper controller needs its values inverted. Signal lines are normally high and goes low for a couple of microsecond to signal an event. To achieve this I need to invert some of the bits. This value is a byte that is xored with the step-data before it is sent down the stepping port. That way you can use this both to invert step pulses (like I do) or to invert one or more of the directions of the axes. The bits in this byte corresponds to the pins assigned to stepping in config.h. Per default bits are assigned like this:

#define X_STEP_BIT 0
#define Y_STEP_BIT 1
#define Z_STEP_BIT 2
#define X_DIRECTION_BIT 3
#define Y_DIRECTION_BIT 4
#define Z_DIRECTION_BIT 5

If you wanted to invert the X and Y direction in this setup you would calculate a value like this (in your favourite calculating environment):

>> (1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)

Which is equal to 24 so issuing this command would invert them:

>> $7=24

$8 – acceleration

This is the acceleration in mm/second/second. You don’t have to understand what that means, suffice it to say that a lower value gives smooooother acceleration while a higher value yields tighter moves.

$9 – max instant cornering speed change

This is the maximum immediate speed change that the acceleration manager will allow. Higher values gives generally faster, possibly jerkier motion. Lower values makes the acceleration manager more careful and will lead to careful cornering.

Coming soon: Using Grbl

Vist 64537 ganger.