LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

encoder velocity

I am having troubles measuring the velocity of my linear encoder with PCI-6220 card.  I have read examples that used dx/dt, but I cannot seem to get that to wok-- when I wire that output to a gauge, I get "0".  I have also tried using shift registers to store previous data for position & time stamp to calculate changing position / changing time, but the problem with that is I get a lot of NaN & inf values randomly occuring admidst getting velocity readings that are appropriate. 

Thanks!
0 Kudos
Message 1 of 6
(3,727 Views)
One thing which happens with any derivative function (dx/dt) is that small variations tend to get amplified. If you are getting NaN and Inf, you are probably seeing zeros or counter overflow in the data. Smoothing functions may help. Expand the left side of the shift register to include the last 5 readings and calculate the velocity from those. This introduces some delay but will eliminate much of the sample to sample variations. There are more sophisticated algorithms, but try this simple one first.

Lynn
0 Kudos
Message 2 of 6
(3,716 Views)
Thanks for the prompt reply.  I suspect that is what is happening-- it seems to be my change in distance that escalates to inf & NaN, independent of the change in time.  What do you mean by expand the left side of the shift register?  I am unsure of how to make it store 5 pieces of data...

Thanks!
0 Kudos
Message 3 of 6
(3,697 Views)
To expand the shift register, right click on it and select 'Add Element'. Repeat another 3 times to get a total of 5 elements.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 4 of 6
(3,694 Views)
Hello!!! I am a universitary study... I have got your same problem measuring the velocity of my linear encoder with PCI-6220 card. Are you so kind, to mail me your .Vi, so that I can make an idea about  crossing this problem?!? Thanks!!!! Paolo
0 Kudos
Message 5 of 6
(3,644 Views)
Hello Paolinooo,

To get an understanding of how to program an encoder task with the NI-DAQmx VIs and your PCI-6220, I would recommend taking a look at the DAQmx shipping examples found within the LabVIEW Example Finder by going to Help > Find Examples.  The encoder measurement examples can be found under DAQmx > Counter Measurements > Position.  Also, you can search the online example program database, found at www.ni.com/examples

Travis G.
Applications Engineering
National Instruments
www.ni.com/support
0 Kudos
Message 6 of 6
(3,614 Views)