Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature Speed

Can the example code measure angular position be modified to give speed information?
We have a quadratrue encoder and need to get speed and Direction.  From the example I can get direction but am looking for a way I think to reset the position count at a timed interval (every second).


0 Kudos
Message 1 of 9
(5,629 Views)

What example code?  What hardware board?  DAQmx or traditional NI-DAQ?

I would think that a buffered position measurement would be pretty straightforward approach.  There should be an example or two to get you started.  Basically, one counter measures the quadrature encoder's position while the other generates a sampling clock.  For any interval, the average speed is the change in position over the elapsed time between those positions.  The sign of the position change gives you the sign for direction.

Post back if you need more specifics...

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 9
(5,613 Views)
Example code is

Measure Angular Position

Dmx using 6602.  Not sure how to manage the clocked reset or sampling clock.  also the quadrature encoder has no index pulse.




0 Kudos
Message 3 of 9
(5,608 Views)

Scott,

1.  Unfortunately, there probably isn't any reliable way to perform a "clocked reset" if your quad encoder doesn't have an index pulse.  Any external signal you may want to use isn't likely to meet the polarity and timing requirements required by the "z index reload" feature.  I agree that there's many apps that need more flexible options for "z index reload" and I put it high on my personal wish list for counter features as seen several posts into this thread

However, if your main purpose for resetting position to 0 was for ease in calculating velocity, then you'll be better off with a buffered position measurement anyway.  That will give you hardware timing on the position readings.  Using software timing to occasionally query position would become a major source of noise in your velocity calculations.

2. For a sampling clock, there are two steps.   First create it, second use it.  To create it, configure another counter to generate a pulsetrain -- for starters you could simply run a pulsetrain example in parallel with your encoder measurement vi.  To use it, you'll need to place a DAQmx Timing vi in the config chain before starting the task.  There you'll need to specify that the source of the sampling clock should be the output from the pulsetrain counter.  You'll also need to wire in a value for "sampling rate".

3.  For future reference, you can often get a more precise measurement of speed by performing a frequency or period measurement.  The downside is that you wouldn't get any direction information from this approach so it's mainly useful when you know a motion will be unidirectional throughout the measurement time.

-Kevin P.

 

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 9
(5,596 Views)

I agree, buffered position measurement is the right way to go. I have done this with the 6602 and a quadrature encoder and the results are very good for velocity and even acceleration.

0 Kudos
Message 5 of 9
(5,537 Views)
Been playing with counters, and dont seem to be getting the results I expected.  would you perhaps have some code to do RPM based on encoder with out Z pulse that you could share?


I tryed to set up a counter to generate pulses and routed that to the quadrature counter as a z pulse thinking that would give me the reset.  For some reason its not doing what I thought it would.

Scott
0 Kudos
Message 6 of 9
(5,534 Views)
"would you perhaps have some code to do RPM based on encoder with out Z pulse that you could share?"
 
For rpm you only need to measure the time between pulses on one encoder channel. You can use "A" or "B" channel... it doesn't matter. There are some example programs that come with LabView to demonstrate how to measure period (time) between pulses with your 6602. Once you know the time between pulses, and the number of pulses per revolution of your encoder you can easily calculate rpm.


"I tryed to set up a counter to generate pulses and routed that to the quadrature counter as a z pulse thinking that would give me the reset.  For some reason its not doing what I thought it would."
 
On an encoder the "Z" signal is meant to be used as a reference mark. This reference mark is normally used to reset the counter in the device connected to the encoder. If you need to reset the count you may be concerned with this signal although if all your trying to do is measure rpm no reset is necessary.


Message Edited by WantToGolf on 02-01-2006 06:51 AM

0 Kudos
Message 7 of 9
(5,525 Views)
Here is a good example of buffered period measurement. You can find it in the LabView examples.
 
Meas Dig Periods-Buffered-Continuous-High Freq 2 Ctr.vi
0 Kudos
Message 8 of 9
(5,519 Views)

Just adding a little to WantToGolf's good advice...

Using period measurement may very well give you a more precise RPM reading than you'd get by measuring position and taking a derivative.  However, period measurement alone won't be able to distinguish direction -- you'd need to handle that separately.  What are your needs for precision?  How frequently do you need to sample a new RPM value?  How many pulses/sec will your encoder be producing?

Also, can you explain your interest in the z-index reset function?  It's going to be difficult to use it unless your encoder produces its own index pulse, though there are some schemes that'll work for uni-directional measurements.  Also it can only be used in a position measuring mode, not in any other mode like period measurement.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 9 of 9
(5,514 Views)