-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PONG #17
Comments
Hi, Stepping jobs act like Future proxies (in fact they contain 3 Futures but the from stepper_motors_juanmf1.Controller import MotorDriver, BipolarStepperMotorDriver
from stepper_motors_juanmf1.ControllerFactory import MultiProcessingControllerFactory
from stepper_motors_juanmf1.StepperMotor import GenericStepper, PG35S_D48_HHC2
def main():
factory = MultiProcessingControllerFactory()
motor = GenericStepper(minPps=50, maxPps=300, maxSleepTime=1/50, minSleepTime=1/300, spr=200)
# motor = PG35S_D48_HHC2(loaded=True)
driver: BipolarStepperMotorDriver = (factory.setUpProcess()
.withDriver(multiprocessObserver=None,
factoryFnReference=factory.getMpExponentialTMC2209With,
# factoryFnReference=factory.getMpCustomTorqueCharacteristicsDRV8825With,
stepperMotor=motor, directionGpioPin=16, stepGpioPin=20, enableGpioPin=21)
.spawn())[0]
while True:
driver.signedSteps(int(motor.spr * 1/8)).result()
driver.signedSteps(-int(motor.spr * 1/8)).result() You could also use events. If you need not to block on a stepping job, say your app needs to keep vigilant of balls coming, then you could be open to change course on the fly or wait for 2 built in events:
So, if you are confident you can wait until a job is done to decide on next move, use the snippet as example. |
I'm running two motors synchronously and need to know when the move I have given them is complete so I can tell them to move again. Currently we are using the sleep command as a poor substitute to ensure the motors don't get overlapping commands. I am an EE and not a CompSci major so I apologize if I am asking an ignorant question. |
No worries, Your (basic) answer is already there. No SleepAbove, these lines complete 1/8th turn in one direction, no # .result() blocks until stepping job is done.
while True:
driver.signedSteps(int(motor.spr * 1/8)).result().
driver.signedSteps(-int(motor.spr * 1/8)).result() 2 motors in syncMake sure you use the Then you have several scenarios.
xJob = driverX.signedSteps(300)
yJob = driverY.signedSteps(200)
# We get here immediately, jobs probably didn't start yet.
xJob.result(). # blocks until done
yJob.result() # blocks until done, continues if already done
print("both drivers just completed their job, but this thread was blocked all along")
Simplest approach is same as before but instead of blocking right away you test for some input. If there are other parts of your system that need to get notified of a stepping job done you could use the Hope this helps. BTW |
Hello,
My senior design team and I (we are seniors in an EE program) are working on a display for the game PONG using two stepper motors and the CoreXY methodology. We are using your code to run the motors simultaneously to decrease the jerkiness of the motion. We are having a hard time figuring out where the "Move Complete" flag is stored. We'd like to use it as a flag to start the next movement.
Can you help?
The text was updated successfully, but these errors were encountered: