shooter64738 / grbl-mega

Grbl Mega 2560 with Backlash Compensation
14 stars 12 forks source link

alarm 2 thrown when axis is reversed with soft limits enabled #18

Open chris2560 opened 2 years ago

chris2560 commented 2 years ago

Thank you for going to the effort of adding backlash compensation to GRBL, it's really important to my project as currently my leadscrews are M8 studding, with about 0.4mm backlash.

However, backlash compensation works well without soft limits ($20), and soft limits work with 0 backlash compensation, but if both are enabled, then it gives 'alarm 2' (movement will cause overtravel) whenever I reverse the direction of travel. Edit: Error 2 occurs as the machine is headed back towards machine home, when previously going away from home.

I've not tested this yet in any other axis, I've only yet tested X because that's all I've got connected up so far. Edit: I've just tested this in Y and the same error is thrown.

The relevant parameters are:

$20=1 $130=195.000 $140=0.4;

To generate the error, run:

$HX; G00 G90 X100.; G00 X50.;

And it moves to X100, then displays:

ALARM:2 [MSG:Reset to continue]

Any help or ideas as to why would be greatly appreciated.

Marcel43367 commented 1 year ago

@chris2560 I´ve had the same issue on my machine. I have solved this by only executing soft limits check, if current planned motion is not done by backlash compensation. In motion_control.c Line 36: Replace: if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE)) { By: if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE) && !(pl_data->condition &(1<<PL_COND_FLAG_BACKLASH_COMP))) {

I´ll write a pull request as soon as I got some time for that.