LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine the direction my motor is turning?

I am working on a vi that calculates the speed of a motor as well as direction. I have successfully determined the speed of the motor but I cannot figure out how to tell which direction it is going. The outside holes are the 0 index of the DAQ and the inside holes are the 1 index. I know that if I could sense which indicator lit first I could tell the direction that way, but I am lost as to how to implement this in labview. I can get it to output clockwise or counter-clockwise, but since the loop is updating every 20 milliseconds the indicator is constantly switching. Any help that I could get would be greatly appreciated.

 

 

Thanks,

Matt

0 Kudos
Message 1 of 8
(3,425 Views)

wheel.jpgHere is a picture of the encoder wheel I am using.

0 Kudos
Message 2 of 8
(3,419 Views)

So do you have 2 digital inputs that basically behave like a quadrature encoder where one digital input always leads the other input for coming on or turning off and that means one direction, and if it lags, it is the other direction?

 

Do it like this.  When you detect the transition of one digital input from low to high, look at the value of the other digital input at the same time.  If it is low, it is one direction.  If it is high, then it is the other direction.

 

PS.  Look at this message in the Rube Goldberg thread and see if you can spot anything like it in your code.Smiley Wink

0 Kudos
Message 3 of 8
(3,402 Views)
We have the voltage from two photocells being fed into a daq. The vi then checks for an edge based on the input voltage. My problem is that the vi is updating every 20 ms and I do not know how to latch in the first boolean value.
0 Kudos
Message 4 of 8
(3,396 Views)
I'm assuming that you are talking about the boolean output being fed into a selector with a true and false attached to it? I am pretty new to labview and part of this is code provided from a professor. I thought it seemed a little redundant but who am I to judge?
0 Kudos
Message 5 of 8
(3,394 Views)

New to LabVIEW?  Take the tutorials.

I LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

 

Yes.  There is no reason to have a Select Function with a True wired to the top and a False wired to the bottom.  The boolean wire going into it is already a True or a False.  Maybe the professor needs to take some LabVIEW tutorials.

 

How fast are the pulses occurring?  Right now you are relying on software timing with your 20 msec while loop and reading the both voltages 1 sample at a time.  This is okay as long as you don't need speed calculations with better than millisecond accuracy (actually 20 msec +/- a few  msec accuracy) and the pulses are sufficiently slow enough that you will detect all of them.

 

You might be better off reading more samples such as N samples for 1/4 or 1/2 second.  Now you'll have a 2-D array of different samples in one dimension, and the two channels in the other dimension.  Then you can be sure you've acquired all the samples at a regular pace and can analyze that array for multiple edges at a time and determine which channel leads the other one.

0 Kudos
Message 6 of 8
(3,369 Views)

That is my goal, but I am stuck on figuring out how to get a window of time equivalent to one inside hole and one outside hole--freeze that by a stored voltage value and compare the two,,,,,or do a check during this time window to see which one goes high first.   It seems really simple but I have not found the right combination of structures or functions to make this work.

0 Kudos
Message 7 of 8
(3,314 Views)

This is for FPGA but havea  look at the bottom and see if the logic suits your needs.

 

http://zone.ni.com/devzone/cda/tut/p/id/3921

 

Edit: I think I linked the wrong article. Search the knowledgebase. I know there is stuff there on calculating rotational direction using the encoder. This may help too.

0 Kudos
Message 8 of 8
(3,309 Views)