LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the position automatically of stepper motor multiple times

Hello, my name if Ares and I am having a bit of a problem editing a sample on a project with LabView 8.5.

 

Currently, I found an example that helped me connect my phidgets Unipolar Stepper Motor Controller with LabView quite successfully.

 

My problem is that I am not able to edit the example to make it so that the motor moves automatically multiple times. 

I tried to edit it but once I change someting the example didn't work. 

 

As of right now, I only aim to change the targer position from a slider to prompt the user to enter multiple target position and once the proggram runs to automatically move the stepper motor from one position to the next and back to the original position. 

 

The example I am using is below

0 Kudos
Message 1 of 4
(3,600 Views)

First, put the Stop Terminal inside the Event Loop Stop Value Change Event Case.

Next, your while loop has a 5mS delay. and the Event structure has a 5mS timeout event----  This is bad! you will always be processing the timeout case. Remove the delay in the while loop and THIS IS IMPORTANT! Your timeout case exists to update front panel indicators only.  That means the consumer of the data produced is a HUMAN- they can't process data a 5mS intervals! set the timeout value to no less than 50mS.

 

If that does not help

see what you can do to do some general clean-up of the block diagram. help us help you with some comments about what that state machine is doing.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 4
(3,585 Views)

Yes, the block diagram needs cleanup.

 

Just put a function that checks if motor is moving into timeout case. If it has stopped, send motor to new position.

You need additional shift register to monitor program state (initializing, idle, moving once, moving forward, moving backward). Obviously, you need to automatically send motor to new position only if it is moving forward.

 

Hint: sliders with value change event are not trivial to work with. They generate event when mouse shifts a little bit. So, when you move slider from beginning to middle, it generates 100s events, each of them includes instrument communication - it takes time, and they pile up. Also there is a checkbox in event setup "locks front panel activity untill event processing completes" - it makes slider less responsive.

So to initiate movements, use button that reads target slider position once.

 

One more hint: use type definition enums for the states instead of the strings. They will save from a lot of errors.

0 Kudos
Message 3 of 4
(3,553 Views)

@Alexander_Sobolev wrote:

Hint: sliders with value change event are not trivial to work with.


But if you want to ignore his otherwise excellent advice anyway (or else just see what you are in for if you do ignore it) then look here:

 

http://forums.ni.com/t5/LabVIEW/Labview-slider-event-handling-problems-revisited/m-p/210418#M118917

 

 

0 Kudos
Message 4 of 4
(3,519 Views)