Close

GRBL Mega 1.1g - Tough Transition

A project log for Sub $200 PCB Mill that doesn't suck!

A PCB mill inspired by open source CNC 3D printers with a custom design to fit standard size copper clad boards (6" x 4" / 160mm x 100mm)

timo-birnscheinTimo Birnschein 12/17/2021 at 15:400 Comments

This morning, I spend 2.5h figuring out why the homing cycle on my mill doesn't wouldn't work after I upgraded to the latest GRBL mega. I couldn't find out where I had stored my original grbl version for this mill but it was rather old, like 0.9g and had quite a few bugs that I wasn't keen on carrying forward.

So this morning, after much consideration, I jumped right into it, cloned the repository and tried to reverse engineer the changes I had done for the old CycloneGRBL, or whatever I used back then, to work. Turns out the changes were rather minimal and what bit me in the end was a missing pullback for homing.

Since my mill uses an Arduino Mega256 with a RAMPS1.4 board, I needed to define the appropriate build flags in the config.h:

#define DEFAULTS_RAMPS_BOARD
#define CPU_MAP_2560_RAMPS_BOARD

Then I changed what the homing cycle looks like to reflect that I don't have a Z-axis endstop switch:

#ifdef DEFAULTS_RAMPS_BOARD
  #define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))   // Home X axis
//  #define HOMING_CYCLE_1 (1<<Y_AXIS)   // Home Y axis
//  #define HOMING_CYCLE_2 (1<<Z_AXIS)   // OPTIONAL: Home Z axis
#else
//  #define HOMING_CYCLE_0 (1<<Z_AXIS)                // REQUIRED: First move Z to clear workspace.
//  #define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS))  // OPTIONAL: Then move X,Y at the same time.
  #define HOMING_CYCLE_0 (1<<X_AXIS)                // REQUIRED: First move Z to clear workspace.
  #define HOMING_CYCLE_1 (1<<Y_AXIS)  // OPTIONAL: Then move X,Y at the same time.
  // #define HOMING_CYCLE_2                         // OPTIONAL: Uncomment and add axes mask to enable
#endif // DEFAULTS_RAMPS_BOARD

And for my specific setup, I'm running the SPINDLE_ENABLE_PIN on Digital Pin 9 for some historical reason, so I had to change the cpu_map.h in the appropriate place:

// Define spindle enable and spindle direction output pins.
//  #define SPINDLE_ENABLE_DDR      DDRG
//  #define SPINDLE_ENABLE_PORT     PORTG
//  #define SPINDLE_ENABLE_BIT      5 // MEGA2560 Digital Pin 4 - Ramps 1.4 Servo 4 Signal pin
  #define SPINDLE_ENABLE_DDR   DDRH
  #define SPINDLE_ENABLE_PORT  PORTH
  #define SPINDLE_ENABLE_BIT   6     // MEGA2560 Digital Pin 9

After that, it was a matter of setting the correct configuration parameters using using the GRBL config that can be set at runtime (an amazing feature, btw. I wish Marlin would have something like that, too).

$0=10
$1=127
$2=0
$3=6
$4=0
$5=0
$6=1
$10=31
$11=31.000
$12=0.002
$13=0
$20=0
$21=1
$22=1
$23=0
$24=50.000
$25=1000.000
$26=250
$27=0.500
$30=0
$31=0
$32=0
$100=800.000
$101=800.000
$102=3200.000
$110=1800.000
$111=1800.000
$112=450.000
$120=30.000
$121=30.000
$122=10.000
$130=162.000
$131=107.000
$132=30.000

 The important learning that cost me almost 2h of my life is $27=0.500. This defines the pull back distance after the homing switches have been hit during homing for the first time. I didn't want any pullback, I thought, and on my old setup this value was set to 0mm so I replicated that right after flashing without checking anything. However, GRBL 1.1 reacts differently from 0.9g as it REQUIRES a pullback distance to be defined to be able to home at all.

If the pullback distance is set to 0mm, it will go straight into an alarm state once the endstop was hit. In the end, it was a test like: "Yeah whatever, I'm running out of options...." shot in the dark. Target hit. Everything worked all of a sudden... dude.

What really bothers me, though, is that LaserGRBL still doesn't like the mill. I thought it doesn't like GRBL0.9g but it still won't connect to my mill. It's works fine with the laser cutter and apart from the lock state it wakes up in. But according to LaserGRBL, that's acceptable. Hm. I guess I have to continue to work on cnc-gcode-controller and make that software work for me with all it's quirks and bad performance gcode streamer.

Discussions