# Differentiator with FIR filter

Started by February 11, 2010
```Dear all,

I need to calculate an acceleration signal from a signal containing speed
samples. I have been looking into using FIR differentiators. Especially the
article http://www.dsprelated.com/showarticle/35.php seems interesting.

When comparing FIR differentiators, it is probably not enough to look at
just the frequency magnitude and phase delay response.

For example one can use a simple forward difference scheme or a more
complicated five point difference scheme. The latter will result in smaller
errors. (http://oregonstate.edu/instruct/ch490/lessons/lesson11.htm)

In http://cnx.org/content/m28304/latest they use a filter window to smooth
the frequency response of a differentiator. I do not understand however why
this approach would be better or worse than the differentiator described in
http://www.dsprelated.com/showarticle/35.php.

No my question is: Which other graph's and figures should one calculate to
compare the quality of a FIR differentiator?

What would be the FIR differentiator equivalent of a differencing scheme as
used in equation 1.5 of
http://oregonstate.edu/instruct/ch490/lessons/lesson11_files/image005.jpg?

```
```Dinne wrote:
> Dear all,
>
> I need to calculate an acceleration signal from a signal containing speed
> samples. I have been looking into using FIR differentiators. Especially the
> article http://www.dsprelated.com/showarticle/35.php seems interesting.
>
> When comparing FIR differentiators, it is probably not enough to look at
> just the frequency magnitude and phase delay response.
>
> For example one can use a simple forward difference scheme or a more
> complicated five point difference scheme. The latter will result in smaller
> errors. (http://oregonstate.edu/instruct/ch490/lessons/lesson11.htm)
>
> In http://cnx.org/content/m28304/latest they use a filter window to smooth
> the frequency response of a differentiator. I do not understand however why
> this approach would be better or worse than the differentiator described in
> http://www.dsprelated.com/showarticle/35.php.
>
> No my question is: Which other graph's and figures should one calculate to
> compare the quality of a FIR differentiator?
>
> What would be the FIR differentiator equivalent of a differencing scheme as
> used in equation 1.5 of
> http://oregonstate.edu/instruct/ch490/lessons/lesson11_files/image005.jpg?

When there are many ways to do a task, the chances are high that all
have problems, and that different ways have different problems. Deciding
which way is best for a particular application requires knowing what is
important for that application.

Why do you need the calculated acceleration signal?

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```
```>
>When there are many ways to do a task, the chances are high that all
>have problems, and that different ways have different problems. Deciding
>which way is best for a particular application requires knowing what is
>important for that application.
>
>Why do you need the calculated acceleration signal?
>

Hello,

In our application we have three gyroscopes. The gyroscopes will be mounted
on board of a ship. Each one is sampled at 25 Hertz. The spectrum in which
we are interested has a range from 0 to 6Hz.  The gyroscopes measure
angular rate (roll rate, pitch rate and yaw rate). The goal is to calculate
angular acceleration in real time. To do this the derivative must be
calculated of the angular rate.

The accelerations are used to determine if a ship experienced violent
movements during its journey.
```
```I forgot to mention that the signals will have an oscillatory behavior as
the ship will roll/pitch/yaw continuously on the waves. The mean of the
signal over a large number of samples will be 0.

```
```On Thu, 11 Feb 2010 15:30:56 -0600, Dinne wrote:

>>When there are many ways to do a task, the chances are high that all
>>have problems, and that different ways have different problems. Deciding
>>which way is best for a particular application requires knowing what is
>>important for that application.
>>
>>Why do you need the calculated acceleration signal?
>>
>>
> Hello,
>
> In our application we have three gyroscopes. The gyroscopes will be
> mounted on board of a ship. Each one is sampled at 25 Hertz. The
> spectrum in which we are interested has a range from 0 to 6Hz.  The
> gyroscopes measure angular rate (roll rate, pitch rate and yaw rate).
> The goal is to calculate angular acceleration in real time. To do this
> the derivative must be calculated of the angular rate.
>
> The accelerations are used to determine if a ship experienced violent
> movements during its journey.

Then you need a filter that acts like a differentiator up to around 6Hz,
and whose response tails off after that.  Just where you need that
response to start tailing off, and how sharply, depends heavily on the
noise that you expect to get from the gyros -- if the gyros are very
quiet compared to the acceleration you're trying to estimate then your
best bet may be a simple back-step one-delay differentiator.  If the
gyros are very noisy, and if you need everything below 6Hz and nothing
above it (and you don't mind _lots_ of delay), then you need something
very different.

To really do this right you'd want to construct a Wiener filter (or a
Kalman filter if you needed the thing to spin up quickly from a power-on,
but I doubt that).  That may well be overkill, and it requires that you
know a staggering amount of close detail about the system.  Without
requirements, the signal you're trying to pull out of it, etc., etc.,
etc. I cannot say.

Probably the best thing to do is to get sample gyro data from calm seas
conditions and from rough seas condition, and try a few different filters
out on them.  If you find one that seems to be good enough -- it may well
be good enough.

--
www.wescottdesign.com
```
```Dinne wrote:
>> When there are many ways to do a task, the chances are high that all
>> have problems, and that different ways have different problems. Deciding
>> which way is best for a particular application requires knowing what is
>> important for that application.
>>
>> Why do you need the calculated acceleration signal?
>>
>
> Hello,
>
> In our application we have three gyroscopes. The gyroscopes will be mounted
> on board of a ship. Each one is sampled at 25 Hertz. The spectrum in which
> we are interested has a range from 0 to 6Hz.  The gyroscopes measure
> angular rate (roll rate, pitch rate and yaw rate). The goal is to calculate
> angular acceleration in real time. To do this the derivative must be
> calculated of the angular rate.
>
> The accelerations are used to determine if a ship experienced violent
> movements during its journey.

Differentiators emphasize high frequencies, hence noise. They delay the
signal. Accurate differentiation usually requires frequencies beyond the
Nyquist limit, or at least substantially higher than the signal being
differentiated. It is common in control systems to oversample by 10;
less than 5 is likely not to work. Your sample rate seems skimpy.

More sophisticated differentiators provide smoother signals at the price
of more delay. Few feedback control systems can tolerate much delay, but
most can work with signals that a human looking at an oscilloscope would
consider ugly. Rick Lyons' differentiator that you cited delays the
derivative by 3 sample times. At a high enough sample rate, that might
be acceptable. since digital differentiators operate by subtracting
(nearly) successive samples, sampling too often  results in zero output.
You have to work out the best compromise taking all the effects into
account for each application. Life's a bitch!

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```
```Dear all,

With these sensors the noise output is defined as x degree/sec/sqr(Hz).
This means that a higher samplerate will introduce more noise into the
signal. It is the question whether the increase in differentiator accuracy
outweighs the decrease in signal accuracy. Probably this will only be
determined after some field tests.

I eventually implemented a differentiator as described in:

http://www.holoborodko.com/pavel/?page_id=245

I chose this approach because the filter design accommodates for changes in
the length of the filter (N). The 6Hz cutoff is achieved by choosing the
filter with parameters n=4, N=9

regards,
Dinne

```
```Dinne wrote:
> Dear all,
>
>> Your sample rate seems skimpy.
>
> With these sensors the noise output is defined as x degree/sec/sqr(Hz).
> This means that a higher samplerate will introduce more noise into the
> signal.

The Hz above refers to sensor bandwidth, not to sample rate. Rethink.

> It is the question whether the increase in differentiator accuracy
> outweighs the decrease in signal accuracy. Probably this will only be
> determined after some field tests.
>
> I eventually implemented a differentiator as described in:
>
> http://www.holoborodko.com/pavel/?page_id=245
>
> I chose this approach because the filter design accommodates for changes in
> the length of the filter (N). The 6Hz cutoff is achieved by choosing the
> filter with parameters n=4, N=9

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```