Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Stepper Motor Direction control

I'm using the USB 6008 to control a stepper motor.

I can control the motor to move Clock wise or counter clockwise, my problem is that i can't get the motor to change direction without stopping the program, switching direction, and then running the program again, I need it to change direction via the toggle switch I use to set the direction.

My code is quite simple, I use a case structure to call either a CW.VI or CCW.VI, which controls the actual movement of the motor in that direction.



0 Kudos
Message 1 of 9

Wrap that code in a while loop.  Include a brief Wait so the loop does not try to execute millions of times per second. Add a Stop button.  When the stop button is pressed, stop the loop and outside the loop write a command to the stepper motor to de-energize all windings or put it into a known condition.



0 Kudos
Message 2 of 9

Ah ok, had tried the while loop, but without the rest, will try it out when I get in.

0 Kudos
Message 3 of 9

Ok I think I'm misunderstanding how the case statement works, according to the new VI, what should be happening in my mind is the toggle it set to a direction, the 1st frame calls a VI that deenergizes the motor, the 2nd frame then calls a VI which runs the motor in a given direction.

Now, when the toggle is switched, the case should change and deenergize the motor, then call the VI to run it in the other direction, but I still have to stop the program, toggle the switch, then rerun it.

Does the case statement indeed work this way and my error is somewhere else?

0 Kudos
Message 4 of 9

Nvm, I figured it out, the VI I was calling to run in a direction was looping continuously so the program would never check the toggle switch again

0 Kudos
Message 5 of 9

Those are indications that you have not fully grasped the concept of dataflow on which LabVIEW is based.  If you have not done so, I recommend that you work through the on-line tutorials.



0 Kudos
Message 6 of 9

Yeah all my Labview is self taught based on my experience with other languages, so I keep getting caught with some of these differences I'm not used too, thanx, I'll go through the tutorials again.

0 Kudos
Message 7 of 9

Hi, I'm not sure whether this is the right place for asking this question or not and if not, then please guide me to the right place for asking such question. Thanks.

I have a stepper motor with the Vector Network Analyzer Anritsu MS4623B. I got it up and running with the LabWindows/CVI. I need to sync the motion of the stepper motor with my data acquisition. Basically, I have to acquire the data in a way that in the start the motor will come back to home position wherever it was and then I want to move it to the specific position to do the measurements (For Example, I want to measure the 40 GHz channel between 1m to 3m movement of a stepper motor on a linear positioning system (ball-screw)). I've interfaced the VNA with the PC using LabWindows/CVI and I've controlled the clockwise and anti-clockwise movements of the stepper motor using LabWindows/CVI but I'm unable to sync the system in a way that whenever I run the code, the motor will run back to the home position and then move to a specific measurement start position and move till the end position and in between do the increment and stop and acquire the data. Is there any one to help me please? It's really urgent please and I'm doing this thing first time so please guide me in a proper way. I shall really apprecaite that and will be highly obliged with you. Thanks for your time and concern.


Thanks and Regards.


0 Kudos
Message 8 of 9

Hey, I see you posted this as its own thread here:


This is certainly preferred over resurrecting old threads.  Have a nice day.


Best regards,

Matthew H.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 9