Closed ar055 closed 3 years ago
I do not reproduce your bug with only one motor. ( I have only one wired yet)
Your code look similar to mine, except that I have added the startasync()
exactly to avoid an additional thread.
What I see is another bug :
m1.stepper = stepper.attach(m1.dir_pin, m1.step_pin, 200, 60, 6000, 100, 100)
m1.stepper:move(1000)
pio.pin.setlow(m1.en_pin)
stepper.startasync(m1.stepper)
tmr.sleepms(1000)
stepper.stop(m1.stepper) -- or stepper.stopasync(m1.stepper)
-- here come the bug
stepper.start(m1.stepper) -- or stepper.startasync(m1.stepper)
Restarting a stepper after a call to stop()
or stopasync()
leave the stepper in an incoherent state. Note that calling the move() method reset this state.
m1.stepper:move(m1.stepper:getdistance())
stepper.start(m1.stepper) -- or stepper.startasync(m1.stepper)
I see where the bug from your sample code
stepper.stopasync(m1.stepper) -- all steppers stopped
the mask
parameter is never used. I will provide a patch soon
idn't know that startasync starts the process itself, my mistake was pio.pin.sethigh (motor.en_pin) right after stepper.startasync(motor.stepper). confirm, stepper.startasiync() - it's work!
Yeah, the documentation is lacking ... But I don't know how to edit the wiki.
I did not see that you disabled the motors right after the startasync() , I am glad it works for you.
Wiki is a separate repo that can be pulled, locally modified and pushed:
Any GitHub wiki can be cloned by appending wiki.git to the repo url, so the clone url for the repo https://myorg/myrepo/ is: git@github.com:myorg/myrepo.wiki.git (for ssh) or https://github.com/my/myrepo.wiki.git (for https).
You make edits, and commit and push your changes, like any normal repo. This wiki repo is distinct from any clone of the project repo (the repo without wiki.get appended).
Thank you @the0ne , I will give it a try.
see 3abf0ea5876f92405a80e3d6d0a47732a28c7349 in #377 for a fix to the stop() and stopasync() to stop only the stepper that where asked .
commit e4d5059f1e0b5599bfa2b1f9ada4d6e23c353fbc
could you please post some lua code demonstrating how these functions work?
my code: