Page 1 of 1

Is there any way to speed up setTargetPosition?

Posted: Fri Mar 27, 2020 7:30 pm
by josh.williams
Hi all,

I have a segment of code in python 3.7 that I'm trying to run on a timer that includes:

Code: Select all

stepper1.setTargetPosition(stepper1_targetposition)
stepper2.setTargetPosition(stepper2_targetposition)
From timing my code, it looks like these two lines take about 0.04 seconds to run.

I'd like to run this code on a timer every 0.01 second. Does anyone know of a way to do so? Is it possible to actually change the target position of my stepper every 0.01 second?

I've played around with

Code: Select all

setTargetPosition_async()
a little bit but don't really understand what it's doing nor have been able to get my code to run.

Thanks!
--Josh

Re: Is there any way to speed up setTargetPosition?

Posted: Fri Mar 27, 2020 9:06 pm
by mparadis
The async version of the function is non-blocking so it should run a bit faster because both steppers are being set simultaneously. I'm not sure why it's not working for you. Whether your motor can physically respond to changes every 0.01s though is another matter since it takes time to change direction.