Limit switch sensing for manual stepper control

Hi,

I am using a MANTA M8P V2.0 for a custom device (not a 3D printer) and have configured a manual stepper that is driven with a TMC5160Tpro driver to operate a device that rotates for a relatively long time by getting it to loop through large rotation segments. However, I want this rolling device to be able to come to a stop when it detects a lid has been opened. I am planning on using a limit switch sensor connected to one of the endstop pins on the MANTA board in order to detect the pull down value when the switch is closed and likewise the pull up when the switch is reopened.

I have tried 2 approaches so far to integrate this with klipper and my custom GUI python application and have ran into some problems. The reason for these problems is because I want the rotations to be relatively continuous so cannot afford the spins to be sent in short segments.

Approach 1: Using the enable = 0 G-Code command to disable the stepper when it detects the end stop pin pulls down as I get it to continuously poll this pin’s value via moonraker to detect when the lid is opened/closed. This is not a bad approach but the issue here is it cannot seem to interrupt the large rotation g code commands. It seems to be queued up in Klipper and only disables after the full spin segment completes which defeats the purpose of the limit switch detection.

Approach 2: Using STOP_ON_ENDSTOP = 1 and assigning the endstop pin that I connected to the limit switch sensor to the manual stepper’s config. This actually worked so well, was able to disable when lid opened and even re-enable the roller to spin on its own once lid was closed, although if I never opened the lid during the move to max position, it triggered the “end stop not triggered” error messages since Klipper thinks the endstop has been triggered by setting STOP_ON_ENDSTOP = 1. This is definitely not ideal and clean to have as it could interfere with smooth running of Klipper.

Any suggestions or ways around this would be appreciated. I have not included any logs as there is nothing really anything relevant besides the end stop did not trigger error message.

Please do it anyway. Maybe there is something that leads to that issue.

1 Like

klippy.log (1.1 MB)

is a gcode_button and emergency stop an option?

I was hoping for something that would software restart it so that’s why emergency stop isn’t really an option.

For gcode_button, I don’t think it can halt queued movements? I believe I also attempted to do that at one stage but it would only disable after the movement completed.

I did find out however that you can set STOP_ON_ENDSTOP to 2 if you want it to complete the move without error even if the endstop does not trigger. This hopefully will be perfect for what I want.