Working with GRBL (Custom CNC Part 4)
If you are just joining us,
- Part 1: Custom Built CNC, an Introduction
- Part 2: Building the Structure, Folding CNC
- Part 3: CNC Electronics
Introduction
Grbl is a no-compromise, high performance, low cost alternative to parallel-port-based motion control for CNC milling. This version of Grbl runs on an Arduino Mega2560 only.
https://github.com/fra589/grbl-Mega-5X
The controller is written in highly optimized C utilizing every clever feature of the AVR-chips to achieve precise timing and asynchronous operation. It is able to maintain up to 30kHz of stable, jitter free control pulses.
It accepts standards-compliant g-code and has been tested with the output of several CAM tools with no problems. Arcs, circles and helical motion are fully supported, as well as, all other primary g-code commands. Macro functions, variables, and most canned cycles are not supported, but we think GUIs can do a much better job at translating them into straight g-code anyhow.
Grbl includes full acceleration management with look ahead. That means the controller will look up to 24 motions into the future and plan its velocities ahead to deliver smooth acceleration and jerk-free cornering.
I really couldn’t say it better. GRBL is to CNCs as Marlin is to 3D printers. Its the brains of the whole thing. GRBL interprets GCODE and controls all of the logic, pulses and timing needed to drive the stepper motors as the code commands.
For my purposes I decided to use FRA5589’s GRBL-MEGA-5X which can control up to 6 axis simultaneously. It is an offshoot of the GRBL MEGA branch which is still limited to 3 axis, with a 4th clone. I also found that the 5X version had been updated more recently.
Installation
You will need to head over to https://github.com/fra589/grbl-Mega-5X to download the most recent version. Then, you will need to go back to the original GRBL site and follow the directions for compiling and burning the image onto the Mega. These instructions are found here: https://github.com/gnea/grbl/wiki/Compiling-Grbl
NOTE: When you install a Library in Arduino, it will copy it to your Arduino directory. Mine was in the my documents folder. You have to go to that directory and edit that version of the code for your changes to take effect. It took me a few hours before I realized the code had been copied to a different directory and that I had been editing a different file than I thought.
Configuring
If you didn’t see it, I talk about setting up my homing cycle and axis back https://replicantfx.com/cncpart3. The big take away from it was that to clone an axis, you simply rename the axis you wish to become the clone to the same name as the axis it is cloning, like below.
#define AXIS_4_NAME 'A' // Letter of axis number 4
To:
#define AXIS_4_NAME 'Y' // Letter of axis number 4
The rest of the configuration was pretty straight forward and if you are coming from Marlin it will be reminiscent.
GRBL takes care of most of its user setting via EEPROM. The settings are as follows:
To manipulate these settings, you will use a console. You can use the console in the Arduino editor (Serial Monitor) or in your GCode Sender (I’ll show you one soon). To get a print out of your current settings, use “$$”. To change a setting use “$130=100.0” which will set the X Max Travel to 100.0mm. For more details about configuring GRBL via EEPROM, check out their site at:
https://github.com/gnea/grbl/wiki/Grbl-v1.1-Configuration
Note, they will not list the A, B and C axis settings, I had to discover these on my own. I think that is it for what I wanted to point out about GRBL. Their Wiki is actually pretty great, so head over there for more details.