LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is derivative PtByPt same as using a shift register?

I need to differentiate an encoder signal to get velocity and acceleration. I set up something that works ok using shift reigsters. It takes the current position, subtacts the previous position and then divides by the time change. I used a shift register for the time change as well. Is this the same thing as using the derivative PtByPt?
 
The velocity signal looks ok but the acceration signal is pretty noisy. Decreasing the sampling rate helps a lot but need to capture human movement so I need a pretty fast sampling rate (around 60 Hz). At this rate the acceleration is pretty messy. I think I will need a multi-point method and I am trying to find the best solution.

Message Edited by justapro on 07-16-2007 10:29 AM

0 Kudos
Message 1 of 14
(3,973 Views)
You can open the diagram to the Pt by Pt VI.  It is using Shift registers to hold the values, so it is most likely very similiar to your VI.
0 Kudos
Message 2 of 14
(3,958 Views)
The PtByPt Vis are just VIs so you can look at their diagrams. The Derivative PtByPt VI uses a shift register to build up an array and then calls the standard Derivative VI. That VI calls some non-LV code so you cannot see what it is doing internally.

Differentiation is a highpass filtering process so any high frequency noise, jitter, or even quatization noise in your input signal tends to get enchanced. Finding the right balance of filtering can be tricky because no one size fits all.

Lynn
0 Kudos
Message 3 of 14
(3,956 Views)
Thanks to you both. I am pretty new to LabView and I forgot I could look under the hood of these VIs. It looks to be pretty much what I am doing. I will need to balance sampling rate and filtering to see if I can get something useful.
0 Kudos
Message 4 of 14
(3,950 Views)

When you say "encoder" signal, are you talking about some kind of digital pulse train?  If it's TTL (or you can convert to TTL), you may want to consider measuring frequency (speed) directly using a counter task.  I assume you're presently performing an edge counting or position measurement task.

You'll still get some differentiation noise when calculating accel, but at least you'll only have one stage of differentiation to deal with.  Also, you're probably dealing with a pretty low frequency encoder pulse rate, like a few kHz or less -- right?  If so, your original frequency measurement can have a pretty low quantization error, which will also help in your differentiation.

-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 5 of 14
(3,934 Views)
Yes, it is TTL. Thanks for the tip, I will look into this tomorrow.
0 Kudos
Message 6 of 14
(3,927 Views)
I have had very good luck with this type of problem using Savitzky-Golay filtering.  It is a simple convolution, so can be done point-by-point, but is the equivalent to fitting a curve to a subset of your points and picking the value, and/or derivatives from the curve.  It is fairly noise immune for acceleration data and can be tweaked in several ways.  Newer versions of LabVIEW include a VI to calculate the coefficients if you want derivatives.  The Savitzky-Golay filter VIs only do simple filtering. They do not calculate derivatives.

You can find out more about Savitzky-Golay filters in Numerical Recipes in C, 2nd edition, by Press et. al.  Make sure you get a copy of the second edition, since the first does not include the info.  Most university libraries, and some large municiple ones, will have the book.  You can also probably browse it on Amazon.

You may also wish to search these forums for Savitzky-Golay, as the subject has been discussed in the past.
Message 7 of 14
(3,908 Views)

I tried to use the 'Count Frequency' task and it seemed to exhibit more noise than my count edges task. I tried both the low and high frequency methods. The low frequency method has a lot of noise and the high frequency method gave me an error (basically it said my signal was too slow for the measurement time) until I raised the measurement time. Then the results were not at all what I would expect. It was a slowly increasing or decreasing line even though I was moving the wire up and down more rapidly. Overall I was getting a lot better results with the count edges task.

I will look into the Savitzky-Golay filtering.

0 Kudos
Message 8 of 14
(3,884 Views)
I need to get the velocity in real time for control purposes. Can Savitzky-Golay be used in real time to smooth data? I won't have "future" values of the position. I will need to output more than one count at a time in the task, right?
0 Kudos
Message 9 of 14
(3,876 Views)
You can set up the Savitzky-Golay coefficients with any number of before and after points.  Unfortunately, the VIs available in LabVIEW do not expose this functionality, so you will have to roll your own.  The Numerical Recipes reference I quoted above has the info you need.  It is fairly straightforward, and the book does a good job of explaining it (much better than I could).

If you try this and run into implementation issues, let us know.
0 Kudos
Message 10 of 14
(3,861 Views)