LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Smooth stepper motor velocity profiles

Hello. I am working on a stepper motor control program in LabVIEW using LIFA. I'd like to be able to implement a smooth velocity profile for my stepper motors, since the motion I'm trying to achieve is fairly complex. I'm using the Stepper Write.vi function in LIFA right now. My idea was to set up a 2D array of velocity and number of steps values and feed a new pair in every 100 ms or so, but whenever I feed a new velocity into the subVI, the motor comes to a complete stop, then starts again. Surely there is a way to have the motor change speeds smoothly. I know LINX is out there and supposed to be better, but I am modifying a VI that was made previously using LIFA, so I'd like to avoid completely rebuilding the program if possible. I am using an Arduino Mega 2560.

0 Kudos
Message 1 of 18
(9,345 Views)

Cterrill,

Post your VI. Lets see what we can do.

Regards

Barddya

0 Kudos
Message 2 of 18
(4,763 Views)

Here's a small VI I whipped up. The actual VI is far too large to post, but this one illustrates my problem. Here I have two Stepper Write functions in a sequence structure. Entering an acceleration value (100 here) causes the motor to decelerate to 0 before moving on to the next segment. If I use 0 to disable the acceleration, the transition is jerky.

stepper motor example.PNG

Here is a similar VI with a for loop instead of a sequence structure. The speed and step # arrays are set up so that each loop iteration lasts 100 ms. The motion is fairly jerky here but that may just be the disparity in the velocity values. I can't tell if it comes to a complete stop when it changes or not, but since I'm planning to measure small forces while the motion occurs, I'd like to avoid jerking as much as possible.

stepper motor example for loop.PNG

Thanks!

0 Kudos
Message 3 of 18
(4,763 Views)

I'm guessing it is because you are waiting until the steps are complete.  Maybe it would be better to check the number of steps left and to issue a new command just before the finishes (you could even add a few steps to each step so that you can catch it before it stops for the new command).  This would require that you poll the "to go" VI and if you have reached your threshold, then write a the next command to the stepper.  It would essentially be a state machine and would need to use a while loop.  Also, because you don't have a the auto-indexing feature in this situation, you would need to keep track of the array index also.

0 Kudos
Message 4 of 18
(4,763 Views)

I suggest you don't use LIFA for this application.  Instead run the experiment using Arduino code.  You can do it in Arduino by using two loops.  An outer loop for the velocity profile and a inner loop for the number of steps.

hrh1818

0 Kudos
Message 5 of 18
(4,763 Views)

In the actual application, I need to apply different velocity profiles to 4 different stepper motors and collect data from a load cell. I feel that LabVIEW is the easiest way to synchronize all of this.

Nathan_B., I'll try your suggestion in the morning.

0 Kudos
Message 6 of 18
(4,763 Views)

HRH1818's suggestion is actually the best  because you remove a [big] layer of abstraction which allows you more flexibility, faster exectuion, and more precise control on things like this.

My method described above may still be plagued by the same issues that you are currently experiencing depending on the execution speed of the VIs.  The execution speed of VIs on a PC are determined by your OS and everything else running on the OS which means that it could be faster or slower depending on the processes running at the time.  This could cause sloppy operation overall when interfacing with something that has a slow interface.

Good luck with either method you choose to approach your problem with.

0 Kudos
Message 7 of 18
(4,763 Views)

How are you planning on running 4 different stepper motors?  As far as I know LIFA can only run 1 stepper motor at a time.  Nathan please correct me If I am wrong.

You can simultaneously run more than one stepper motor at a time if you use a faster micro controller like an Arduino Due or Chipkit 32.  However, running multiple stepper motors simultaneously is not compatible with the existing version of LIFA.

hrh1818

0 Kudos
Message 8 of 18
(4,763 Views)

I have already been running 4 stepper motors simultaneously through LabVIEW so I assume it is possible to do so.

0 Kudos
Message 9 of 18
(4,763 Views)

I didn't think it could do more than one but I'm not all that well versed in the stepper motor functionality of Arduino or LIFA.

0 Kudos
Message 10 of 18
(4,763 Views)