[time-nuts] PLL Math Question
Magnus Danielson
magnus at rubidium.dyndns.org
Fri Mar 14 11:56:16 EDT 2014
On 13/03/14 07:35, Daniel Mendes wrote:
> Em 13/03/2014 01:35, Bob Stewart escreveu:
>> Hi Daniel,
>>
>> re: FIR vs IIR
>>
>>
>> I'm not a DSP professional, though I do have an old Smiths, and I've
>> read some of it. So, could you give me some idea what the FIR vs IIR
>> question means on a practical level for this application? I can see
>> that the MA is effective and easy to code, but takes up memory space I
>> eventually may not have. Likewise, I can see that the EA is hard to
>> code for the general case, but takes up little memory. Any thoughts
>> would be appreciated unless this is straying too far from time-nuts
>> territory.
>>
>>
>
> FIR = Finite Impulse Response
>
> It means that if you enter an impulse into your filter after some time
> the response completely vanishes. Let´s have an example:
>
> your filter has coefficients 0.25 ; 0.25 ; 0.25 ; 0.25 (a moving
> average of length 4)
>
> instead we could define this filter by the difference equation:
>
> y[n] = 0.25x[n] + 0.25x[n-1] + 0.25x[n-2] + 0.25x[n-3] (notice that
> Y[n] can be computed by looking only at present and past values of x)
>
> your data is 0; 0; 1; 0; 0; 0; 0 ...... (there´s an impulse of
> amplitude 1 at n= 2)
>
> your output will be:
>
> 0; 0; 0.25; 0.25; 0.25; 0.25; 0; 0; 0; ..... (this is the convolution
> between the coefficients and the input data)
>
> after 4 samples (the length of the filter) your output completely
> vanishes. This means that all FIR filters are BIBO stable (BIBO =
> bounded input, bounded output... if you enter numbers not infinite in
> the filter the output never diverges)
>
> IIR = infinite Impulse Response
>
> It means that if you enter an impulse into your filter the response
> never settle down again (but it can converge). Let´s have an example:
>
> your filter cannot be described by coefficients anymore because it has
> infinite response, so we need a difference equation. Let´s use the one
> provided before for the exponential smoothing with a_avg = 1/8:
>
> x_avg = x_avg + (x - x_avg) * 1/8;
>
> this means:
>
> y[n] = y[n-1] + (x[n] - y[n-1]) * 1/8
>
> y[n] = y[n-1] - 1/8*y[n-1] + 1/8*x[n]
>
> y[n] = 7/8*y[n-1] + 1/8*x[n]
>
> you can see why this is different from the other filter: now the output
> is function not only from the present and past inputs, but also from the
> past output(s).
>
> Lets try the same input as before:
>
> your data is 0; 0; 1; 0; 0; 0; 0 ...... (there´s an impulse of
> amplitude 1 at t= 2)
>
> your output will be:
>
> y[0] = 0 = 7/8*y[-1] + 1/8*x[0] (i´m assuming that y[-1] = 0.. and x[0]
> is zero)
> y[1] = 0 = 7/8*y[0] + 1/8*x[1]
> y[2] = 1/8 = 7/8*y[1] + 1/8*x[2] (x[2] = 1)
> y[3] = 7/64 = 7/8*y[2] + 1/8*x[3] (x[3] = 0) = 0.109
> y[4] = 49/512 = 7/8*y[3] + 1/8*x[4] (x[4] = 0) = 0.095
> y[5] = 343/4096 = 7/8*y[4] + 1/8*x[5] (x[5] = 0) = 0.084
>
> You can see that without truncation this will never go to zero again.
>
> Usually you can get more attenuation with a IIR filter having the same
> computational complexity than a FIR filter but you need to take care
> about stability and truncation. Well, i´ll just copy here the relevant
> part from wikipedia about advantages and disadvantages:
>
>
> Advantages and disadvantages
>
> The main advantage digital IIR filters have over FIR filters is their
> efficiency in implementation, in order to meet a specification in terms
> of passband, stopband, ripple, and/or roll-off. Such a set of
> specifications can be accomplished with a lower order (/Q/ in the above
> formulae) IIR filter than would be required for an FIR filter meeting
> the same requirements. If implemented in a signal processor, this
> implies a correspondingly fewer number of calculations per time step;
> the computational savings is often of a rather large factor.
>
> On the other hand, FIR filters can be easier to design, for instance, to
> match a particular frequency response requirement. This is particularly
> true when the requirement is not one of the usual cases (high-pass,
> low-pass, notch, etc.) which have been studied and optimized for analog
> filters. Also FIR filters can be easily made to be linear phase
> <http://en.wikipedia.org/wiki/Linear_phase> (constant group delay
> <http://en.wikipedia.org/wiki/Group_delay> vs frequency), a property
> that is not easily met using IIR filters and then only as an
> approximation (for instance with the Bessel filter
> <http://en.wikipedia.org/wiki/Bessel_filter>). Another issue regarding
> digital IIR filters is the potential for limit cycle
> <http://en.wikipedia.org/wiki/Limit_cycle> behavior when idle, due to
> the feedback system in conjunction with quantization.
You need to understand that the PI loop already is a IIR filter in
itself, and you need to understand what the averager you add inside that
loop does to the loop properties. Generic discussions on IIR vs FIR does
not cut it. If you do a FIR averager then you need to consider what the
poles and zeros (yes it has both) of that do inside the PI-loop.
Cheers,
Magnus
More information about the time-nuts
mailing list