Notifications
Clear all

Actuating 2 steppers

3 Posts
3 Users
0 Likes
1,561 Views
(@greenbee)
Member
Joined: 3 years ago
Posts: 3
Topic starter  

Hello everyone!

I'm working on a project that involves moving two linear rails, each with a stepper motor attached. I need to move them in a way that their movements begin and end simultaneously, even though each one moves a different distance. Furthermore, I'd like the speed of the movement to be dependant on the reading from a pressure sensor so that they slow down if the pressure is too high.

I had started with only one stepper and used software interrupts on Timer1 to generate a PWM wave to actuate the stepper, with the frequency of the wave dependant on the pressure sensor reading. However, I'm not certain how to add in the second motor. The main reason I'm using interrupts is that I need my device available to receive commands (serial commands) in case of an emergency stop.  

Does anyone have any tips for me? Do you think I'm tackling this from the right direction or should I look into another option?


   
Quote
(@borkutip)
Member
Joined: 3 years ago
Posts: 6
 

Hello,
Here is a theoretical algorithm, I do not know if it suits you:

Let's say Motor1 needs N steps and Motor2 needs K steps and the time for going along the rays is T.
T is the same for the two motors.
So you have to make stepping Motor1 N times during the time T.

The delays between each step are:

T/N for motor1 and T/K for motor2.

I think, that you only need to set T based on the pressure sensor values. So, if you need to move faster the steppers, decrease T and vice versa.

What do you think?


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

 GreenBee

It might be better to use a counter as a divisor for each motor and the interrupt for the emergency stop. You can sample the pressure and preload each counter with the appropriate divisor similar to what borkutip indicates in the previous post then use something like millis() to decrement the counters for pulse timing for the stepper motors.

 


   
ReplyQuote