From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Velocity control of a stepper motor using sine wave

Hi! 

Sorry if i m reposting this again, but I figured this would give a better overview of the issue. I have to control the velocity of stepper motor using a sine wave so that it simulates a simple harmonic motion. The problem is that my stepper motor driver accepts STEP and DIR pulses, so I have no clue how to convert the sine wave to stepper motor pulses. 

 I did figure out a way to reverse the direction of the stepper motor, by differentiating the sine wave, everytime the derivative changes, a pulse is sent to the DIR to change direction. It would be great if someone could suggest a way to control the velocity using the sine wave.

Thanks!

0 Kudos
Message 1 of 3
(3,330 Views)

What hardware are you using to communicate with your drive? Is it LabVIEW? From those two inputs, it doesn't sound like you have control over velocity but there may be another command to send to your drive that changes the velocity.

Rob B
FlexRIO Product Manager
0 Kudos
Message 2 of 3
(3,290 Views)

 

Most steppers I've worked with are inherently pretty resonant down in the low speed range,

where "low speed" would generally mean revs/sec measured in small single digits.  This is

something to watch out for with bi-directional simple harmonic motion, especially if you have

low friction / damping in your system.

 

That caveat aside, the basic way to approach this is to feed a variable frequency pulsetrain to

the STEP input.  Pulsetrain frequency will be proportional to commanded rotational speed.

You'll need to synchronize your direction input to change at the zero crossings.

 

What DAQ hardware do you have?  To do this well, you'll need the pulsetrain frequency

changes to be hardware timed.  I'd want to use an STC-3 based counter/timer (found in

X-series MIO boards, maybe other places?) that supports buffered pulse generation, but I've

done analagous things using correlated DIO with an STC-2 based counter timer on an

M-series MIO board.

 

Another small subtlety to look out for: depending on your particular sinewave freq and amplitude,

quantization *might* cause the + direction to get 1 step more or less than the - direction, causing

a slow mechanical drift in one direction to the tune of 1 step per sine wave cycle.  Now that you

know to watch out for it, you can go ahead and prevent it.

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 3
(3,279 Views)