LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping a stepper motor at 90 degrees angle

1. I am a student doing a project where the motor has to stop at North, East, South, West. At the moment, after various of different methods, I am unable to stop the motor.

It keeps running. How do I make it stop?  FYI- the whole program is in a while loop so that other features keep running. I just want the motor to stop.

 

2. Adding on, is there ANY possible way to stop a for loop within a while loop, without affecting the while loop.

 

 


Urgent Help much needed and appreciated. THANKS

0 Kudos
Message 1 of 6
(7,397 Views)

In newer versions of LabVIEW you can stop for loops (right click and add the terminating terminal).  

 

As far as your code is concerned, it really helps if you post it.  It sounds as if your code to move the motor isn't isolated from the while loop.  By isolated I mean that it should only run when a button is pressed.  So the basic idea would be to have the user press a button, which starts a for loop for the motor movement.  Depending on your stepper motor, it may be tricky to confirm it is always stopping at exactly 90 degrees.  Dropped step signals are not so easy to notice and can induce a larger degree of error from time to time.

 

A state machine architecture will make the overall functionallity easier to understand.  In your idle state, the code will run it's normal functions and check to see if a move/rotate button is pressed, if so, it goes to the motor control state.  Here, it will issue the appropriate number of steps for your 90 deg rotation.

 

 

I have a question though, will it always be moving 90 degrees? or just have to stop at them?  Lets say it starts at 47 degrees, you'd then need a way to determine it's starting angle.  Or, completely ignore the starting angle and create a way to monitor when it is at a 90 degree rotation mark.

0 Kudos
Message 2 of 6
(7,393 Views)

@LukeMclovin wrote:

1. I am a student doing a project where the motor has to stop at North, East, South, West. At the moment, after various of different methods, I am unable to stop the motor.

It keeps running. How do I make it stop?  FYI- the whole program is in a while loop so that other features keep running. I just want the motor to stop.

 

2. Adding on, is there ANY possible way to stop a for loop within a while loop, without affecting the while loop.


Urgent Help much needed and appreciated. THANKS


You can have While loop running, forever, but you might want to keep the code responsible to rotate the motor inside a Case structure (within While loop)... So now you can control the Case structure and also motor.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 3 of 6
(7,385 Views)

Synopsis of my project

 

Normal mode = An opto coupler circuit is used to simulate a sensor that detects a person entering or leaving a room. When the optocoupler is blocked once, it simulates someone entering the room. When it is blocked the second time, it simulates a person leaving the room. A light sensor (LDR) is mounter on a stepper motor. When a person enters, the stepper motor will start turning until it detects a highest preset light intensity and it stops once detected (here I've got no problem stopping) If it fails to detect the after turning 360 degrees, it will stop (my problem)

 

Diagnostic mode = Optocoupler blocked once = Motor moves 90 degrees. Twice= another 90 degrees. Thrice = another 90 degrees. Fourth time and above motor does not need to move.

 

The problem is I can't stop the motor after 360 degrees ( for normal mode) or 90 degrees ( for diagnostic mode). And it does not matter where the motor stopped previously, I just want it to move in 90 or 360 degrees. It approximately 18 degrees per step. Attached is te stripped down version of my vi.

 

 

Sorry if I sound inexperienced, I am super new to labview. THANKS

0 Kudos
Message 4 of 6
(7,380 Views)

Version 2012 please...!!


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 5 of 6
(7,376 Views)

I think you have quite accurately described the different states of a state machine here. If you have not heard of a state machine before, a quick search here or in the example finder will be helpful. What you need to do is maintain a counter to keep track of your motor position, and then repeat the "rotate and check for light threshold" state until you find light or reach 360 degrees of rotation. 

 

Keywords: state-machine (case structure in while or for loop), shift register propagation of states, counter for rotation, perform checks on values/signals to determine the next state to execute.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 6 of 6
(7,364 Views)