Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not end motion on jog cancel #1396

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

breiler
Copy link
Contributor

@breiler breiler commented Dec 7, 2024

This is an attempt to fix a problem with jog cancel on multiple small jog commands. It will cause the machine to abruptly stop, not taking the deceleration into account. The same problem does not exist on classic GRBL or grblHAL.

I have tried debugging the jog cancel by adding extra logging to these functions:

static void protocol_start_holding() {
    if (!(sys.suspend.bit.motionCancel || sys.suspend.bit.jogCancel)) {  // Block, if already holding.
        sys.step_control = {};
        if (!Stepper::update_plan_block_parameters()) {  // Notify stepper module to recompute for hold deceleration.
            log_info("End motion")
            sys.step_control.endMotion = true;
        } else {
            log_info("Don't end motion")
        }
        sys.step_control.executeHold = true;  // Initiate suspend state with active flag.
    }
}
// Called by planner_recalculate() when the executing block is updated by the new plan.
bool Stepper::update_plan_block_parameters() {
    if (pl_block != NULL) {  // Ignore if at start of a new block.
        log_info("Planning block available");
        prep.recalculate_flag.recalculate = 1;
        pl_block->entry_speed_sqr         = prep.current_speed * prep.current_speed;  // Update entry speed.
        pl_block                          = NULL;  // Flag prep_segment() to load and check active velocity profile.
        return true;
    }
    return false;
}

When canceling a long jog command such as this, the deceleration works as intended:

> $J=G21G91X-100F2007
ok
> Jog cancel
INFO: Planning block available
INFO: Don't end motion

However when canceling multiple commands it doesn't see the planning block and will therefore set the endMotion=true which will cause the abrupt halt:

ok
> $J=G21G91X0.335F2007
ok
> $J=G21G91X0.335F2007
ok
> $J=G21G91X0.335F2007
ok
> $J=G21G91X0.335F2007
ok
> Jog cancel
INFO: End motion

My interpretation is that when doing a jog cancel we never want to do a endMotion, this PR has therefore collected the cancel logic to its own jog-cancel-function.

There is another problem where trying to issue a feed hold command while jogging which will make the controller unresponsive. This PR will not fix that problem, but it will at least not get worse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant