From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stepper Motor Control

Hello

 

Iam using a labview to design a VI to control stepper motor, now the way Iam going with this is that I have CDS photorisistor in a voltage divider.. Now the voltage that is comming out of this divider will determine the exact angle the motor needs to rotate.  Attached is the program iam going to use that would determine the steps that the motor needs to move. The question I have is what function I can use-so that voltage comming out my sensor would determine the angle my motor needs to rotate.

0 Kudos
Message 1 of 6
(6,054 Views)

Please attach the VI you build for us to help you. From the what you explained and your attachment, it looks like you would need to calibrate the step of the motor to the voltage output. Say, the minimum step is 3 degrees and it need 20mV to turn 3 degrees. Then next step is to just write voltage in steps if 20mV using function 'Analog Write' and that will turn your motor accordingly.

Hope it helps!



------------------------------------------------------------------------------------------------------
Kudos are (always) welcome for the good post. 🙂
0 Kudos
Message 2 of 6
(6,050 Views)

Ok well Iam still in the process of building the VI for stepper control. but just to clarify more....I have a sensor voltage comming through DAQ to my Labview...so the algorithm Iam trying to build is that "as long as that voltage is above a certain threshold then motor should rotate this many steps"......so I need to know should I use CASE structure... or something similar..

 

 

Thanks
SK

0 Kudos
Message 3 of 6
(6,046 Views)

Little confusing compared to what you said last time. I was assuming that you are using your PCI card to generate voltage that drives the current circuit which in turn drives the motor. Thats why I suggested calibration. I don't know exactly how you are controlling the motor.?



------------------------------------------------------------------------------------------------------
Kudos are (always) welcome for the good post. 🙂
0 Kudos
Message 4 of 6
(6,041 Views)

It sounds like you need a state machine. There are examples of this in the labview help that I higthly recommend looking at.

 

Your stepper motor requires a sequence of writes to move. This could be acomplished with on-demand writing in a state machine or with an array. Then you can read voltage from your daq card to determine whether to to move again or wait. 

 

There are many ways you could make the system through. If you run into problems why don't you post pictures of what you have/are trying to do so we can help you with more specific questions.

 

Jesse Dennis
Engineer
INTP
0 Kudos
Message 5 of 6
(6,001 Views)

Hi SK, 

 

After reading your other questions I think I can help you out more. The code you have been looking at is a state machine.  In this case "Position" is using a shift register and so is detecting changes from loop to loop, let me know if you don't get how this works. 

 

Know we know that "1" corresponds to "true" usually. So the original example is really just writing: 

 

0

1

 

to move the stepper motor, using digital lines instead of analog lines. Your profs decided to make it hard on you, so you are using analog lines. You will need to figure out the actual voltage required to set your voltage to true. Typically 0V corresponds to "0" or "false" and 5V corresponds to "1" or "true." So first you need to change the system to look something like: 

analogsingle.png

 

But now we need to write to multiple lines, because we have four different wires to control. You need to figure out which wires to physically wire into your board and what lines correspond to what lines correspond to what on your actual motor. However,writing to multiple lines at the same time is easy, as shown below:

 

 

analogmultiple.png

 

In this example I have written: 

1010

1011

 

 

This should be enough to get you going, make sure to let us know how it turns out. 

 

 

 

Jesse Dennis
Engineer
INTP
0 Kudos
Message 6 of 6
(5,993 Views)