From: gpezzella on
Hi Jerry

Every time I take new sample I calculate the actual value of Y[i] and save
it in a Y[i] array.

Since I have few memory, which is the minumum number of Y[i] that I must
save?

Thanks

P.S.
Remember that Ft = 50 Hz Sample Rate = 2.48KHz


>On 7/9/2010 5:42 AM, gpezzella wrote:
>> Ok I will use this notation from now
>>
>> I previous post (7/1/2010 3:21 AM) you wrote me the follow equation:
>> <a> "y[1] = k*x[i] + (1-k)*y[i-1] that behaves like a single RC".
>>
>> In the day 7/8/2010 I discovery another thread that use:
>> <b> "Y[i] = K * X[i] + [1-K] * Y[i-1]"
>> which is coincident to yours:
>> <c> "Y[i] = [ X[i] - Y[i-1] ] * K + Y[i-1]"
>>
>> Today instead you write that:
>> <d> "Y[i] = k*Y[i-1] + (k-1)*X[i]" is the correct equation
>>
>> Question 1: Which is the good one between a,b,c,d?
>
>They are all good. Where I initially have the coefficients as k and 1-k,
>your other gave them as 1-k and k. Because k is an arbitrary constant,
>the two notations are equivalent. After your response, I switched to
>your notation.
>
>> Question 2: After choose the correct equation, is the follow method
correct
>> for calculate K coefficient?
>>
--------------------------------------------------------------------------------
>> ts
>> -(--) Where: ts = sample period (seconds)
>> T T = time constant (seconds)
>> (1) K = 1 - e K = change in o/p after 1 ts
>>
>>
>> The value for K is then used as the coefficient in the RC LPF code.
>>
>> If the above equation is correct I should use for my case:
>> 1)Ft = 50 Hz
>> 2)Sample Rate = 2.48KHz
>>
>>
>> 1
>> T = ------- = 0.00318
>> 2*Pi*50
>>
>> ts = 1/2.48 Hz = 0.0004
>>
>>
>> 0.0004
>> -(--------)
>> 0.00318
>> K = 1 - e = 1 - 0.88 = 0.12
>>
------------------------------------------------------------------------------
>
>Yes. (I would have written the last line either as e^(-.0004/.00318) or
>exp(-.0004/.00318).)
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>�����������������������������������������������������������������������
>
From: gpezzella on
Hi Jerry

Every time I take new sample I calculate the actual value of Y[i] and save
it in a Y[i] array.

Since I have few memory, which is the minumum number of Y[i] that I must
save?

Thanks

P.S.
Remember that Ft = 50 Hz Sample Rate = 2.48KHz


>On 7/9/2010 5:42 AM, gpezzella wrote:
>> Ok I will use this notation from now
>>
>> I previous post (7/1/2010 3:21 AM) you wrote me the follow equation:
>> <a> "y[1] = k*x[i] + (1-k)*y[i-1] that behaves like a single RC".
>>
>> In the day 7/8/2010 I discovery another thread that use:
>> <b> "Y[i] = K * X[i] + [1-K] * Y[i-1]"
>> which is coincident to yours:
>> <c> "Y[i] = [ X[i] - Y[i-1] ] * K + Y[i-1]"
>>
>> Today instead you write that:
>> <d> "Y[i] = k*Y[i-1] + (k-1)*X[i]" is the correct equation
>>
>> Question 1: Which is the good one between a,b,c,d?
>
>They are all good. Where I initially have the coefficients as k and 1-k,
>your other gave them as 1-k and k. Because k is an arbitrary constant,
>the two notations are equivalent. After your response, I switched to
>your notation.
>
>> Question 2: After choose the correct equation, is the follow method
correct
>> for calculate K coefficient?
>>
--------------------------------------------------------------------------------
>> ts
>> -(--) Where: ts = sample period (seconds)
>> T T = time constant (seconds)
>> (1) K = 1 - e K = change in o/p after 1 ts
>>
>>
>> The value for K is then used as the coefficient in the RC LPF code.
>>
>> If the above equation is correct I should use for my case:
>> 1)Ft = 50 Hz
>> 2)Sample Rate = 2.48KHz
>>
>>
>> 1
>> T = ------- = 0.00318
>> 2*Pi*50
>>
>> ts = 1/2.48 Hz = 0.0004
>>
>>
>> 0.0004
>> -(--------)
>> 0.00318
>> K = 1 - e = 1 - 0.88 = 0.12
>>
------------------------------------------------------------------------------
>
>Yes. (I would have written the last line either as e^(-.0004/.00318) or
>exp(-.0004/.00318).)
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>�����������������������������������������������������������������������
>
From: Jerry Avins on
On 7/14/2010 7:14 AM, gpezzella wrote:
> Hi Jerry
>
> Every time I take new sample I calculate the actual value of Y[i] and save
> it in a Y[i] array.

No. A variable, If you have one to dedicate, a register.

> Since I have few memory, which is the minumum number of Y[i] that I must
> save?

You need only the last Y you calculated. The new one you calculate
replaces it. Remember: this is a one-pole filter. You may need something
with sharper cut-off. The simplest is a cascade of two or more of these,
but there are computationally more efficient ones.
http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html is an on-line
application to design them. Try a two- or three-pole filter with a 3 dB
cutoff point at 60 Hz.

Jerry
--
Engineering is the art of making what you want from things you can get.
From: gpezzella on
Dear Jerry,

GREAT LINK!! Thanks

If for example I choose:
-----------------------------------
filtertype = Chebyshev
passtype = Lowpass
ripple = -1
order = 5
samplerate = 2480
corner1 = 50
corner2 =
adzero =
logmin =

Recurrence relation:
y[n] = ( 1 * x[n- 5])
+ ( 5 * x[n- 4])
+ ( 10 * x[n- 3])
+ ( 10 * x[n- 2])
+ ( 5 * x[n- 1])
+ ( 1 * x[n- 0])

+ ( 0.8881071970 * y[n- 5])
+ ( -4.5278119979 * y[n- 4])
+ ( 9.2530651832 * y[n- 3])
+ ( -9.4749879058 * y[n- 2])
+ ( 4.8616237413 * y[n- 1])
----------------------------------

1) Always I must save Y[n] into a variable?
2) If yes, for check if there are been frequency under 50Hz I must only
compare Y[n] with a threshold, correct?

Thanks





>On 7/14/2010 7:14 AM, gpezzella wrote:
>> Hi Jerry
>>
>> Every time I take new sample I calculate the actual value of Y[i] and
save
>> it in a Y[i] array.
>
>No. A variable, If you have one to dedicate, a register.
>
>> Since I have few memory, which is the minumum number of Y[i] that I
must
>> save?
>
>You need only the last Y you calculated. The new one you calculate
>replaces it. Remember: this is a one-pole filter. You may need something
>with sharper cut-off. The simplest is a cascade of two or more of these,
>but there are computationally more efficient ones.
>http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html is an on-line
>application to design them. Try a two- or three-pole filter with a 3 dB
>cutoff point at 60 Hz.
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>
From: Jerry Avins on
On 7/15/2010 11:48 AM, gpezzella wrote:
> Dear Jerry,
>
> GREAT LINK!! Thanks
>
> If for example I choose:
> -----------------------------------
> filtertype = Chebyshev
> passtype = Lowpass
> ripple = -1
> order = 5
> samplerate = 2480
> corner1 = 50
> corner2 =
> adzero =
> logmin =
>
> Recurrence relation:
> y[n] = ( 1 * x[n- 5])
> + ( 5 * x[n- 4])
> + ( 10 * x[n- 3])
> + ( 10 * x[n- 2])
> + ( 5 * x[n- 1])
> + ( 1 * x[n- 0])
>
> + ( 0.8881071970 * y[n- 5])
> + ( -4.5278119979 * y[n- 4])
> + ( 9.2530651832 * y[n- 3])
> + ( -9.4749879058 * y[n- 2])
> + ( 4.8616237413 * y[n- 1])
> ----------------------------------

Why do you need so sharp a cutoff?

There will be attenuation at the corner frequency, so you should set it
higher than what you want to pass unattenuated.

> 1) Always I must save Y[n] into a variable?

Your recursion relation needs 5 past x[n] and 5 past y[n]. You need to
save them all, then update them for the next iteration.

> 2) If yes, for check if there are been frequency under 50Hz I must only
> compare Y[n] with a threshold, correct?

That should work.

Jerry
--
Engineering is the art of making what you want from things you can get.