Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Making a stepper motor run a specific number of steps?

I have a stepper motor (NEMA 11 stepper motor) and a driver for it. I create a program in a while loop which provides a step signal (PWM) and direction signal (Digital out) from the myRIO to the drivers. 

 

There are three controls I specify for this program: the number of steps to run, the PWM frequency (steps per second) and the direction. I set the duty cycle of the PWM as a constant 0.5. I added a stopwatch using the Elapsed Time VI which basically keeps track of time and multiplies the elapsed seconds with the PWM frequency to find out theoretically how many steps would have been ran, and once it has reached the number of steps to run, the while loop breaks. I attached a picture of the program as a screenshot.

 

But a problem I am having is when I specify lower number of steps to run such as running 10 steps at 10 steps/second, or even 1 step at 1 step/second, it looks like it moves much more than the number of steps specified almost as if it is not able to run such a small number of steps.

 

Can someone look at my program and tell me how I can make this stepper control better? FYI: I also have a limit switch which breaks the while loop

 

Thanks!

0 Kudos
Message 1 of 8
(5,254 Views)

Hi,

 

Could you attach your VI for us to take a look at please?

 

Kind regards, 

Michael

0 Kudos
Message 2 of 8
(5,220 Views)

This is the VI to run my motor. 

 

When the limit switch is pressed, the direction changes so that the motor moves away from the limit switch. 

0 Kudos
Message 3 of 8
(5,213 Views)

Hi,

 

Thanks! 

 

When you are saying that it is moving more than expected, how much more is this moving?

 

Kind regards, 

Michael

0 Kudos
Message 4 of 8
(5,200 Views)

The motor moves at around 55.56 steps per angle.

 

If I run this code specifying to run it at 1 step per second and to run it for 1 step, and one step is barely anything, in the timer it will say 1 second and it moved 1 step but physically it looks like it moves like at least around an angle. I think this is an issue with how I might have implemented the Elapsed Time VI or how the PWM pulses come out. 

0 Kudos
Message 5 of 8
(5,197 Views)
0 Kudos
Message 6 of 8
(5,195 Views)

Hi,

 

For the first link: I do not use an encoder. This is basically an open loop scenario, the controller sends a number of pulses to move to a position and it assumes it moved to that position.

 

Second link: I know the step resolution/steps per revolution of the motor which I have mentioned before it is 55.56 steps per angle.

 

Third link: I do not have or use an NI motion motor. I brought a NEMA motor from their website, connected to a driver, and the myRIO sends steps/dir signals to it.

 

Fourth link: I have a good understanding of microstepping.

 

I think my main question I still need answered is, after looking at my VI, does it look like it's doing the job of controlling the motor? The fact that I use an Elapsed Time VI to measure the time signals are sent and then I use the time elapsed to calculate the steps actually moved? (With obviously the second problem being the actual number of steps moved does not represent the calculated steps moved from the VI)

 

 

0 Kudos
Message 7 of 8
(5,172 Views)

Hi,

 

Sorry for the delayed response.

 

From my end, it looks to be working okay. 

 

Elapsed Time VI just waits a specified amount of time before sending out a signal. It doesn't control the rate at which a loop executes (how time has elapsed)

0 Kudos
Message 8 of 8
(5,138 Views)