LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper Motor Control

Hi,

 

I am using a stepper motor (Nema 23) along with a stepper motor drive (DM 556T) from stepperonline. I am trying to run the motor using NI USB-6210 and LabVIEW 2022 Q3 on a Windows platform. 

 

The motor shaft is connected to a flag. Since I do not have access to an encoder, I cannot know the current position of the motor.

Using the attached VI, I can rotate the shaft by a set amount (in degrees). What I want to do is to first get the flag aligned with some reference line and call that as my base location (this would be more of a hit-and-trial until I get the two aligned). From there I would turn the flag in increments of 2 degrees. But whenever I am done, I want to be able to return to the base location. I then want to start off in the other direction and repeat the same process.

 

I would appreciate any help with this.

 

Thanks,

lza

0 Kudos
Message 1 of 4
(876 Views)

I recently discussed my experience running a stepper motor using LabVIEW here.  You are using a more sophisticated motor drive than I, but you should have no difficulty interfacing the motor, motor-driver, and the 6212 to move the motor.

 

Steppers are very good for precise positioning.  As you note, they lack a "zero" setting.  What we have done is to put a photo-sensor that detects a "flag" mounted on the motor shaft.  When we power on the motor, we rotate in slowly until the photo-sensor goes high, then back up more slowly until the sensor goes low.  This constitutes the "known" position.  Depending on the circumstances, and what is mounted on the shaft, we do a final motion to bring whatever is mounted on the shaft to the position you want to consider "home".

 

Bob Schor

0 Kudos
Message 2 of 4
(838 Views)

Thank you, Bob_Schor.

 

I am using a laser alignment tool to find the 'home' position. The VI that I previously shared works fine as far as operating the stepper motor is concerned. My actual query is about automating/controlling its operation in the following manner:

1. Allow the motor to be rotated to small increments (positive/negative) using LabVIEW till I find the 'home' location using the alignment tool (I can do this part with my current VI).

2. After finding the 'home' location, I want to have some way of storing this information using LabVIEW so that this becomes a reference for all subsequent rotations.

2. Now when the automated part is initiated, the motor should rotate in 2 degree increments such that it waits for 10 seconds at every location at the end of which LabVIEW collects data for 5 seconds, and then the motor moves on to the next point (rotates by 2 deg), and so on till a pre-set maximum rotation.

3. The motor then returns to 'home' location.

4. The rotation direction is now changed, and the process is repeated.

 

Any pointers would be highly appreciated.

 

Thanks,

lza

 

0 Kudos
Message 3 of 4
(788 Views)

So here's what I do.  We have a little "flag" mounted on the shaft of the motor (near the base of the shaft, so it doesn't get in the way when the shaft turns) and a "sensor" that goes high when something "breaks the beam" (I have no idea if there even is a beam, but it does go high when the flag passes between the upper and lower "plate").  Assume the sensor reads Low, meaning the flag isn't being sensed.  Rotate clockwise at a moderate speed until the signal goes High.  When this happens, rotate slowly CCW until it goes Low.  Call this "Home".  [If initially the sensor read High, rotate slowly CCW until it goes Low.  Call it "Home".

 

Now ask the question "Is there a position of the shaft that I want to call 0°?".  You should (by this time) know how many "steps" it takes to do one rotation (or, equivalently, you know the size, in degrees, of a single step).  Move the Stepper CW or CCW (counting the Steps) until it is what you want to call 0° (note this will probably not be the same position as what you previously called "Home").  

 

So now you have your initialization routine.  Rotate CW and CCW to find Home, then move to what you now define as 0° (you don't really need to make this movement, but why not start out at a "standard position"?  Now to move to, say, Y° when you know you are at X°, rotate by moving Y° - X° (you do this in "steps", but you know, for your motor, how many Steps make a full revolution (360°), so it's a simple arithmetic computation.  Note you can get from X to Y by rotating either CW or CCW -- I recommend choosing the direction that has fewer steps (i.e. if the arithmetic says "Move 270° CW", I say "Move 90° CCW".

 

You keep track of where the motor is, so returning to Home from position Z is to simply rotate -Z.

 

If you now want a sequence of moves, just program it. Do a 2° move, wait 10 s, collect data for 5" (put the "Stall" VI on the Error line tying the sub-VI that does the Move from the sub-VI that collects data for 5 s, repeat this sequence until you sample at all the positions you need, then finally move back (or move forward if that's shorter) to get back to the starting poisition.

 

It is not clear to me why you have Point 4, "the rotation direction is now changed and we sample in the other direction".  You are "starting in the middle and sampling/rotating CW, then returning to the middle and sampling/rotating CCW".  Wny not start by starting at the far CCW position, sampling and moving to the final CW position?  But you can certainly do it your way ...

 

Bob Schor 

0 Kudos
Message 4 of 4
(763 Views)