Sign in

username:

password:



Not a member?

Search compdsp



Search tips

comp.dsp by Keywords

Adaptive Filter | ADPCM | ADSP | ADSP-2181 | Aliasing | AMR | Anti-Aliasing | ARMA | Autocorrelation | AutoCovariance | Beamforming | Bessel | Blackfin | Butterworth | C6713 | CCS | Chebyshev | CIC Filter | Circular Convolution | Code Composer Studio | Comb Filter | Compression | Convolution | Cross Correlation | DCT | Decimation | Deconvolution | Demodulation | DM642 | DSP Boards | DSP/BIOS | DTMF | Echo Cancellation | Equalization | Equalizer | ETSI | EZLITE (Ez-kit Lite) | FFT | FFTW | FIR Filter | Fixed Point | FSK | G.711 | G.723 | G.729 | Gaussian Noise | Goertzel | GPIO | Hilbert Transform | IFFT | IIR Filter | Interpolation | Invariance | JTAG | Kalman | Laplace Transform | Levinson | LPC | McBSP | MIPS | Modulation | MPEG | Multirate | Notch Filter | Nyquist | OFDM | Oversampling | Pink Noise | Pitch | PLL | Polyphase | QAM | QDMA | Quantization | Quantizer | Radar | Random Noise | Reed Solomon | Remez | Resampling | RTDX | Sampling | Sharc | TI C6711 | Undersampling | Viterbi | Wavelets | White Noise | Wiener Filter | Windowing | XDS510PP | Z Transform

Ads

Discussion Groups

Free Online Books

Discussion Groups | Comp.DSP | IIR Filter Difference Equation Implementation

There are 4 messages in this thread.

You are currently looking at messages 0 to 4.


IIR Filter Difference Equation Implementation - Benjamin M. Stocks - 15:25 10-07-03

Hi All,
I have a beginner-esqe question: all of my DSP literature shows the
IIR Difference Equation as:
y(n) = b(0)x(n) + b(1)x(n-1) + b(2)x(n-2) + ... + a(1)y(n-1) +
a(2)y(n-2) + ...

But then the C code implementations I see are something along the
lines:
FeedForwardVariable = (b[0] * x[n]) + (b[1] * x[n-1]) + (b[2] *
x[n-2]);
FeedBackwardVariable = (a[1] * y[n-1]) + (a[2] * y[n-2]) + (a[3] *
y[n-3]);
ResultVariable = FeedForwardVariable - FeedBackwardVariable;

The implementation uses a subtraction operation on the feed back
calculations that I don't see in the Difference Equation. Why is that?

I realize I'm setting myself up for a "Duh!!", but I'm really confused
why this is the case.

Thanks much,

Ben

Re: IIR Filter Difference Equation Implementation - Fred Marshall - 16:25 10-07-03



"Benjamin M. Stocks" <s...@ieee.org> wrote in message
news:1...@posting.google.com...
> Hi All,
> I have a beginner-esqe question: all of my DSP literature shows the
> IIR Difference Equation as:
> y(n) = b(0)x(n) + b(1)x(n-1) + b(2)x(n-2) + ... + a(1)y(n-1) +
> a(2)y(n-2) + ...
>
> But then the C code implementations I see are something along the
> lines:
> FeedForwardVariable = (b[0] * x[n]) + (b[1] * x[n-1]) + (b[2] *
> x[n-2]);
> FeedBackwardVariable = (a[1] * y[n-1]) + (a[2] * y[n-2]) + (a[3] *
> y[n-3]);
> ResultVariable = FeedForwardVariable - FeedBackwardVariable;
>
> The implementation uses a subtraction operation on the feed back
> calculations that I don't see in the Difference Equation. Why is that?
>
> I realize I'm setting myself up for a "Duh!!", but I'm really confused
> why this is the case.
>
> Thanks much,
>
> Ben

y(n) = b(0)x(n) + b(1)x(n-1) + b(2)x(n-2) + ... - [a(1)y(n-1) + a(2)y(n-2) +
...]
                                             n.b^
or

y(n) = b(0)x(n) + b(1)x(n-1) + b(2)x(n-2) + ... -a(1)y(n-1) -
a(2)y(n-2) - ...


is the normal expression for the difference equation.

Fred




Re: IIR Filter Difference Equation Implementation - Matthew Donadio - 16:38 10-07-03

On Thu, 10 Jul 2003 13:25:13 -0700, Benjamin M. Stocks wrote:
> I have a beginner-esqe question: all of my DSP literature shows the
> IIR Difference Equation as:
> y(n) = b(0)x(n) + b(1)x(n-1) + b(2)x(n-2) + ... + a(1)y(n-1) +
> a(2)y(n-2) + ...
> 
> But then the C code implementations I see are something along the
> lines:
> FeedForwardVariable = (b[0] * x[n]) + (b[1] * x[n-1]) + (b[2] *
> x[n-2]);
> FeedBackwardVariable = (a[1] * y[n-1]) + (a[2] * y[n-2]) + (a[3] *
> y[n-3]);
> ResultVariable = FeedForwardVariable - FeedBackwardVariable;
> 
> The implementation uses a subtraction operation on the feed back
> calculations that I don't see in the Difference Equation. Why is that?
> 
> I realize I'm setting myself up for a "Duh!!", but I'm really confused
> why this is the case.

That is not a dumb question at all; it causes a lot of confusion.

It has to do with a few different conventions.

Oppenheim and Schafer, and Lyons use the following:

	y[n] = sum(k=0..M)(b[k]*x[n-k]) + sum(k=1..N)(a[k]*y[n-k])

	         sum(k=0..M)(b[k]*z^-k)
	H(z) = --------------------------
	       1 - sum(k=1..N)(a[k]*z^-k)

Rabiner and Gold, Parkus and Burrus (*), and Proakis and Manolakis use the
following:

	y[n] = sum(k=0..M)(b[k]*x[n-k]) - sum(k=1..N)(a[k]*y[n-k])

	         sum(k=0..M)(b[k]*z^-k)
	H(z) = --------------------------
	       1 + sum(k=1..N)(a[k]*z^-k)

In addition, some sources use a[k] for the numerator and b[k] for the
denominator coefficients.  Also be warned, that some texts (like (*)
above), don't always normalize a[0] to 1.

They are all equivalent, except for the sign of the a[k].  With positive a[k]
you subtract, and with negative a[k] you add.  The moral of the story is
to be triple sure of what you have when designing and implementing IIR
filters, especially if you are using someone else's code.

-- 
Matthew Donadio (m...@ieee.org)


Re: IIR Filter Difference Equation Implementation - Benjamin M. Stocks - 09:07 11-07-03

Matthew Donadio <m...@ieee.org> wrote in message
news:<p...@ieee.org>...
> On Thu, 10 Jul 2003 13:25:13 -0700, Benjamin M. Stocks wrote:
> > I have a beginner-esqe question: all of my DSP literature shows the
> > IIR Difference Equation as:
> > y(n) = b(0)x(n) + b(1)x(n-1) + b(2)x(n-2) + ... + a(1)y(n-1) +
> > a(2)y(n-2) + ...
> > 
> > But then the C code implementations I see are something along the
> > lines:
> > FeedForwardVariable = (b[0] * x[n]) + (b[1] * x[n-1]) + (b[2] *
> > x[n-2]);
> > FeedBackwardVariable = (a[1] * y[n-1]) + (a[2] * y[n-2]) + (a[3] *
> > y[n-3]);
> > ResultVariable = FeedForwardVariable - FeedBackwardVariable;
> > 
> > The implementation uses a subtraction operation on the feed back
> > calculations that I don't see in the Difference Equation. Why is that?
> > 
> > I realize I'm setting myself up for a "Duh!!", but I'm really confused
> > why this is the case.
> 
> That is not a dumb question at all; it causes a lot of confusion.
> 
> It has to do with a few different conventions.
> 
> Oppenheim and Schafer, and Lyons use the following:
> 
> 	y[n] = sum(k=0..M)(b[k]*x[n-k]) + sum(k=1..N)(a[k]*y[n-k])
> 
> 	         sum(k=0..M)(b[k]*z^-k)
> 	H(z) = --------------------------
> 	       1 - sum(k=1..N)(a[k]*z^-k)
> 
> Rabiner and Gold, Parkus and Burrus (*), and Proakis and Manolakis use the
> following:
> 
> 	y[n] = sum(k=0..M)(b[k]*x[n-k]) - sum(k=1..N)(a[k]*y[n-k])
> 
> 	         sum(k=0..M)(b[k]*z^-k)
> 	H(z) = --------------------------
> 	       1 + sum(k=1..N)(a[k]*z^-k)
> 
> In addition, some sources use a[k] for the numerator and b[k] for the
> denominator coefficients.  Also be warned, that some texts (like (*)
> above), don't always normalize a[0] to 1.
> 
> They are all equivalent, except for the sign of the a[k].  With positive a[k]
> you subtract, and with negative a[k] you add.  The moral of the story is
> to be triple sure of what you have when designing and implementing IIR
> filters, especially if you are using someone else's code.


Thank you, I understand it much better now.

Regards,

Ben