Skip to content

Interruping blocking-mode functions (e.g., limit switch) #38

@luriomer

Description

@luriomer

Hello,

In my application I'd like to incorporate limit switches that would stop the motor immediately when engaged (e.g., when reaching a hardstop).
For non-blocking mode functions (i.e., constantly calling run() or runSpeed() inside a loop) it is pretty straight-forward by either interrupts or polling. No problem there.

I wonder if there is a way to do the same for blocking functions, such as runToPosition(). Even if I interrupt to set a flag or whatever, as soon as the ISR function returns (which will be very shortly, if it's just setting a flag) the motor will continue the movement (and if a hard stop was reached it will just slip and won't move).
So basically what I am looking for is a way to use interrupts to conditionally break out runToPosition.

I would say this is a pretty basic feature that many other might need.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions