Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper position control with myRIO

Firstly, sorry for double posting.  I realized I accidentally posted my question earlier in the LabVIEW forum instead of this one.  

 

Secondly, I am developing a position control system to move a linear stage back and forth using a stepper motor (file 1).  The stage will ultimately need to follow the motion path set out in a function that I have defined (file 2).  

 

I have been able to get the motor to move using a Big Easy Driver from Sparkfun (file 3), sending it a PWM signal from one myRIO pin, and setting another pin on the myRIO to high or low in order to establish the direction.  From what I understand, each low-to-high transition in the PWM signal causes the motor to take one step (or microstep).  Therefore the PWM frequency is equal to steps/second, the motor speed.  Using timed loops along with this information, I am able to control how many rotations the motor performs at a constant speed.  

 

However, I would like to be able to count steps, so that I can give the motor a position (number of steps to take from some defined "home") and it will go there, and vary speed accordingly to get there and ultimately follow my function.  I will apparently need to implement some sort of PID control eventually, in order to accomplish this task.  Right now I would just like to know how I can keep track of the position of my motor and control it that way. 

 

I greatly would greatly appreciate any advice on how to implement this process. 

 

Best, 

E

Message 1 of 3
(7,854 Views)

Hey E,

 

I have actually been working on something very similar recently. Does your stepper motor include encoder feedback? Without an encoder, there isn't much need to use PID in this type of application since stepper motors only move when the STEP input is changed from low to high, as you mentioned. Because of this fact, you can very accurately control the location of the stepper without PID by ensuring you program safe acceleration/deceleration rates to prevent the stepper motor from slipping.

 

The easiest way to have the stepper move a specific distance is to do some kinematics calculations in software using a velocity curve that you define. You can program a constant acceleration and deceleration in your code to create a trapezoidal velocity profile, like the picture below:

 

Stepper example.png

If you select the acceleration/deceleration rates and top speed appropriately, you can safely and accurately move the stepper motor an exact distance without need for PID.

 

I hope this makes sense, and gives you a good idea as to how this can be done.

 

Regards,

 

Ryan

Ryan P.
CLA
Message 2 of 3
(7,824 Views)

Hi Ryan, 


Thanks for your reply.  My stepper does not include encoder feedback, and so your response indeed makes sense.  I had actually started working on something similar, so I was very pleased to see your suggestion.  


Best, 

Emma 

0 Kudos
Message 3 of 3
(7,808 Views)