No way of simply running a stepper. With start/stop

Hi, its simply an MCU connected to one Driver and Stepper.
Or in more detail:
An Raspberry-Zero2w uses an rp2040 as mcu, that is connected over spi to an tmc5160 pro driver.

So basically its extremely simple.

The goal:
I want simply to make a button or 2 buttons for start rotating and stop.

Problem:
There is actually no way to do this with klipper, at least i dont know any.
The problem is, if you do this in small gcode moves, like you put a g1 move into an interruptable loop…
klipper will stop and start the motor between those moves, because that are small moves in a loop.
the stop and start just takes a microsecond or so, but it sounds like the motor is broken.
Additionally it will never accelerate to the desired speed. And i need a relative slow acceleration.

If you use manual stepper:
MANUAL_STEPPER STEPPER=my_motor ENABLE=1 SPEED={speed} MOVE={degree} SET_POSITION=0 STOP_ON_ENDSTOP=1
in particular an extreme long move with STOP_ON_ENDSTOP=1, you run into the problem of “MCU Shutdown because timer in the past”

That timer in the Past issue happens on any move that is longer, basically i can run the motor max 30 seconds (less or more depending on the speed)

So you have no choice other as segment small steps in a loop.

Does anyone has any ideas how you can simply accomplish running an motor infinitive and beeing able to start stop that?

Ive ended up with a semi working solution, simply by restarting the klipper service with a button and external script.
The downside is there, that there no deceleration happens, so its an incredible loud stop.

Ive uploaded my configs (the are very small and nothing special, its just one stepper) xD

buttons.cfg (7.0 KB)
printer.cfg (1.4 KB)

If anyone has an idea, please tell me! Thanks!

Hello @Ramalama !

I’m afraid Klipper is a bit over dimensioned for this purpose.
Also you have to trick out some safety features like proper movement of the steppers after homing.

You may use a simple Arduino for that:

You are absolutely right, but klipper has acceleration/deceleration and the most important fact is, that i know klipper very well :person_facepalming:
Im not a big friend of Arduino projects, dunno if the support an tmc5160 over spi etc :person_facepalming:

So i really don’t want to learn sth new, for this super stupid basic task.
I mean i have it all done etc, it’s in a box and so on :joy:

But thank you for the help, very appreciated :+1:

Edit:
Btw, even if i wanted, I can’t use that project, because im forced to use an mellow external tmc5160 pro…
Thats like an really big stepper driver from mellow that is only controllable over spi.
Im driving an nema34 stepper at 48v at 4amps.
No other stepper driver can deliver that sadly.

Hi there,

I came across your post while searching for a solution to a very similar challenge I’m facing. Like you, I’m trying to achieve infinite stepper motor control with the ability to start and stop the motor, all integrated with Klipper.

I’m particularly interested in whether you have found a workaround or solution to the problems.

I’ve dived into the source code of mannual stepper, but got stuck when trying to utilize the external API through FFI_main = cffi.FFI(). In my attempts to initiate motor movement, I’ve used the following command:

self.manual_stepper.do_move(30000, 10, 0, 1)

And I tried to stop the motor by using:

self.manual_stepper.do_set_position(30000)
self.manual_stepper.stepper.set_trapq(None)

Unfortunately, neither approach yielded the desired results.It seems like once the steps are generated and sent to motor, there is no way to stop it.

I’m reaching out in the hopes that a developer from the Klipper team, or someone familiar with its intricacies, might notice this post and offer some guidance.

Any insights would be greatly appreciated :pray: