Notifications
Clear all

Asynchronous stepper motor library.

3 Posts
2 Users
0 Reactions
2,949 Views
 Amin
(@amin)
Member
Joined: 5 years ago
Posts: 5
Topic starter  

Greetings,

I have an arduino mega that's connected to two stepper motors.  Each stepper motor has one stop/limit switch that would indicate the end of the travel distance.  I'm using "AccelStepper" library to control the motors.  I'm also using the "Eventually" event-based lib to do perform some action when an event occurs. 

Everything works great in serial fashion. But I need to have a few things run at the same time. The two stepper motors, for example. The issue that I have is AccelStepper is blocking meaning that once I call "runToPosition" function call, nothing else happens unless and until the function returns.  

I looked at "Metro" and "Chrono" packages but again since the "runToPosition" is a blocking function call, everything comes to the halt until the function call returns.

Of course, one thing I can do is move each motor a few degrees in a loop with AccelStepper lib or just pulsing it.  But I was wondering if there is any stepper motor libs that are asynchronous?  Something like fire-and-forget.  Thanks all.

 


   
Quote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

@amin

I'd be surprised if such a library exist. There would be no way for a library function to get back control once it relinquished it. However, it is fairly simple for you to do it using the one step method you mentioned or several other means.


   
ReplyQuote
 Amin
(@amin)
Member
Joined: 5 years ago
Posts: 5
Topic starter  

@ruplicator

Thanks.  I tried one-step method but it's painfully slow with AccelStepper and the stepper motor that I have.  Going to look at raspberry pie to see if I can control the GPIO in an async fashion.  


   
ReplyQuote