Loading Grbl on Arduino Mega2560
The source code for the Mega lives in this repository at github. You will need to install the version control system git to check out the code. Select “Run Git from the Windows Command Prompt” when downloading. All other options are default.
Download latest Arduino IDE from http://arduino.cc/en/main/software (i.e. Arduino 1.0.4).
(You must add the paths the the executable's like make.exe and avrdude.exe to windows environment variables. Right click my computer on the start menu and click Properties. Go to the Advanced tab and on the bottom there will be a button that says environment variables. Under system variables there will be a Variable with the name "Path". Click edit and add the paths to the executable's eg,
C:\arduino-00xx\hardware\tools\avr\bin;
C:\arduino-00xx\hardware\tools\avr\avr\bin;
C:\arduino-00xx\hardware\tools\avr\utils\bin
Do not erase your previous paths just add the new ones. Once this is done you can compile the source.)
Open CMD window by going to Start All Programs Accessories. Highlight “Command Prompt” and select “Run as administrator.”
In CMD window, navigate to folder where cloned Grbl will be stored on local PC and use command “git clone https://github.com/openpnp/grbl.git” (no apostrophes) and press Enter. This is grbl that has been coded for the Mega2560 and OpenPnP project.
Grbl folder will be created automatically. In CMD window type in “cd grbl” (no apostrophes) and press Enter to go into grbl folder. Then type command “make clean” (no apostrophes) and press Enter.
In same folder, use command “make grbl.hex” (no apostrophes) and press Enter. Below is how the CMD window looked while loading the Uno. The Mega2560 is similar. Now you can use XLoader to load the .hex file to your Arduino.
Open XLoader. Select your Arduino's COM port from the drop down menu on the lower left.
Under “Device” select Mega(ATMEGA2560).
Check that Xloader set the correct baud rate for the device: 115200 for Mega2560.
Now use the browse button on the top right of the form to browse to your grbl.hex file.
Once your grbl hex file is selected, click "_Upload_". After clicking upload, you'll see the RX/TX lights flashing on the Mega2560. The upload process generally takes about 10 seconds to finish. Once completed, a message will appear in the bottom left corner of XLoader telling you how many bytes were uploaded. If there was an error, it would show instead of the total bytes uploaded.
Once loaded, I used a Putty serial window to confirm the load and move the motors with simple x##y##z## commands. Xloader uses baud rate of 115200, however, Putty uses the baudrate in Grbl, which is defaulted to 38400. This is changeable by the user, but involves recompiling the code.
Note: To recompile Grbl, make changes as necessary in the .c files and then repeat the “make clean” and “make grbl.hex” commands as seen in Step 5 above.