LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read RPM from Quadrature Encoder

Hi Everyone,
I wish to measure the RPM of a shaft using a quadrature encoder and a PCI-6259 card. I've seen a few examples on reading position, which i have managed to get working, but Im not sure on how to get RPM. Any tips or code examples would be greatly appreciated.
Thanks,
David
0 Kudos
Message 1 of 7
(5,718 Views)

Hi David-

The easiest way to measure digital frequency (i.e. RPM) using your M Series card is to perform buffered event counting on one phase of your encoder signal.  This provides you with hardware-timed interval counts of the number of rising edges that occur during known measurement periods.  From the count values and the measurement periods you use, you can easily extrapolate an RPM value based on the number of pulses you expect per revolution of your shaft.

A great LabVIEW example to show the setup for NI-DAQmx is "Count Digital Events-Buffered-Continuous-Ext Clk.vi" which can be found in the NI Example Finder (Help>>Find Examples) by browsing to Hardware Input and Output>>DAQmx>>Counter Measurements>>Count Digital Events.  The required external clock could easily be supplied using a second counter for pulse train output as shown in Hardware Input and Output>>DAQmx>>Generating Digital Pulses>>Gen Dig Pulse Train-Continuous.vi.  The clock source for the edge counting VI would then be of the form "/Dev1/Ctr0InternalOutput"

Hopefully this helps-

Tom W
National Instruments
Message 2 of 7
(5,696 Views)

Hi Tom,

Thanks for your reply. I have done what you have suggested (combining the two examples) but im still at a loss on how to correctly configure this....im sure its not as difficult as im making it out to be but any further help would be appreciated. I have attached what I have done so far.

0 Kudos
Message 3 of 7
(5,682 Views)
Hi David-
 
It looks like you actually chose a position measurement instead of the edge counting I suggested.  The pulse counting method should be quite straightforward;  the buffered operation will give you an array of pulse count readings, and since you know the amount of time between each reading you can then extrapolate the number of pulses/second.  Based on the number of pulses per revolution of your encoder, you can then convert pulses/second to revolutions/second.
 
Hopefully this helps-

Message Edited by Tom W. on 11-28-2005 05:42 PM

Tom W
National Instruments
Message 4 of 7
(5,682 Views)

Hi Tom,

Is it possible to do both operations at once? I need position and RPM.

Thanks
0 Kudos
Message 5 of 7
(5,676 Views)
I believe this does it.  I don't know if it uses the same card as yours, but it should work with any compatible DAQ card.  I think the routines are in LV 6.1.  After you extract the files, run Test Shaft RPM.vi.  You may need to change the device number of the card.

Let me know if this solves the problem.

0 Kudos
Message 6 of 7
(5,669 Views)
Hi All-
 
Thanks for the suggestion DJ, but your VI will not work as it is written using the Traditional (Legacy) NI-DAQ driver and David's M Series card is only compatible with the NI-DAQmx driver.
 
To answer David's question, it is not possible to directly measure position and count edges at the same time.  What you can do is count edges with external Up/Down control (basically the same as a X1 encoder) and then use the edge counting to calculate both frequency and displacement in ticks/degrees/RPM/etc.  I have attached an example I did recently that shows how to use an edge count with external Up/Down control (i.e. PFI10 or PFI11 for M Series ctr0 or ctr1, respectively) provided by the 'B' phase signal and the 'A' phase provided to the counter source.
 
Hopefully this helps-
Tom W
National Instruments
Message 7 of 7
(5,653 Views)