LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper motor acceleration software lag

Solved!
Go to solution

I am programming a stepper motor and would like to accelerate it from a frequency of 200 Hz up to 1000 Hz using about 6 steps, hold it at 1000 Hz for a desired input amount of steps, then decelerate it back to 200 Hz in using 6 steps, similarly to the acceleration. My VI works when connected to the myDAQ and stepper motor, however the frequency outputted to the motor during the first few steps (acceleration) and last few steps (deceleration) seems lower than it should be qualitatively. I believe that the way I have coded this VI is inefficient and thus causing the software to take longer to run my code, resulting in a delay in the output to the hardware, specifically in my for loops that control the acceleration and deceleration. Any insight on how to clean up or rewrite this portion of my code to avoid this delay would be much appreciated. My VI is attached below. Thanks in advance! 

0 Kudos
Message 1 of 6
(4,027 Views)

I don't have LV2017 installed so I can't have a look at your vi but what you're observing is most probably a physical phenomena than a software issue. A stepper can't change speed instantly, how fast it can accelerate/decelerate is related to the inductance and resistance of the windings, the ability of your power source to deliver energy rapidly to the motor and other factors (load inertia, resonance, ...)

Did you used a scope  to measure these variations?

 

Ben64

0 Kudos
Message 2 of 6
(4,020 Views)
Solution
Accepted by topic author kbauman

You are correct.  That code is inefficient.

 

Create your task once.  Write to your Task in a loop.   Stop your task once.  Clear your task.

 

Ramp Pattern.vi is a friend you need to make. 

 

 

 

 


"Should be" isn't "Is" -Jay
Message 3 of 6
(4,002 Views)

Just a forewarning:  your myDAQ device is very likely inadequate for the task of outputting a variably frequency with a very specific # of pulses.   The newish X-series boards were the first to support buffered pulse train output, a feature you'd need to provide both variable frequency and precise control over total # steps.  The myDAQ doesn't support this.

 

Before X-series were around, I used hardware-timed DO as a tedious method to accomplish the same thing, but the myDAQ doesn't support that either.  You'll probably need a different DAQ board or, better yet, a dedicated stepper controller.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 6
(3,943 Views)

Hi, thanks for your help. The reason I have my task starting and clearing so many times was because I was having errors about the output counter channel being "reserved." Is there a way to avoid this and use only one task while changing the command I'm giving that one channel?

0 Kudos
Message 5 of 6
(3,927 Views)

Dear kbauman,

 

I'm not entirely certain that this is what you are looking for, but it may help to take a look at these examples and documents.

 

Change Counter Output Frequency on the Fly

 

Generate a Continuous Digital Pulse Train With On The Fly Frequency Control

 

Counter Output PWM with Dynamic Duty Cycle Updates in DAQmx

 

Pulse Width Modulation (PWM) Using NI-DAQmx and LabVIEW

 

Hope this helps!

 

Alyssa H.

National Instruments

0 Kudos
Message 6 of 6
(3,900 Views)