FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-20-2008, 09:13 PM
tismealso
Guest
 
Posts: n/a
Default filter algorithms

I have to implement three filters in C++. An IIR, FIR an
COMBINED(basically a sum of the two). I have been given the formulae an
its fairly simple (I think) but I know little about filters and would lik
to be able to test them against something accurate (a good data set). I
there something [free] that I can use to input my formulae and obtain
good test data set against which I can test my implementation.

Oddly (from what I have been reading here and elsewhere) the FIR filte
contains terms in Y. Is this reasonable?

any help appreciated.


Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 11:02 PM
sparafucile17
Guest
 
Posts: n/a
Default Re: filter algorithms

>I have to implement three filters in C++. An IIR, FIR and
>COMBINED(basically a sum of the two). I have been given the formulae and
>its fairly simple (I think) but I know little about filters and woul

like
>to be able to test them against something accurate (a good data set). Is
>there something [free] that I can use to input my formulae and obtain a
>good test data set against which I can test my implementation.
>
>Oddly (from what I have been reading here and elsewhere) the FIR filter
>contains terms in Y. Is this reasonable?
>
>any help appreciated.
>
>
>


My suggestion is to simulate it in Matlab using a noise signal as th
filters input. Create any kind of noise signa
(white/pink/gaussian/whatever) and make sure you only do this step once!
Every time you call the rand() function you'll get a new data set, s
you'll need to save you're workspace for repeatable results.

Then put the coefficients ("a" and "b" terms) into the filter() functio
and BAM you're done. If you have a series of filters, you also convolv
the coefficients to get the cascaded response usning conv(). Keep in min
this is done easily with floating point arithmetic. If it's fixed poin
then you'll have to be much more crafty with you're Matlab code.

Unfortunatley there is no standard data set out there for verificatio
purposes, you'll have to create your own.

Jeff
Reply With Quote
  #3 (permalink)  
Old 02-21-2008, 02:21 AM
DSPGURU
Guest
 
Posts: n/a
Default Re: filter algorithms

On Feb 20, 3:13*pm, "tismealso" <midgley...@hotmail.com> wrote:
> I have to implement three filters in C++. An IIR, FIR and
> COMBINED(basically a sum of the two). I have been given the formulae and
> its fairly simple (I think) but I know little about filters and would like
> to be able to test them against something accurate (a good data set). Is
> there something [free] that I can use to input my formulae and obtain a
> good test data set against which I can test my implementation.
>
> Oddly (from what I have been reading here and elsewhere) the FIR filter
> contains terms in Y. Is this reasonable?
>
> any help appreciated.


Hello,

If in your doubt, Y is output, then this is not reasonable since the
filter is no more an FIR filter but an IIR filter. Y terms in filter
mean feedback.

Where do you get these desine formula?

Do you know with certaintly what this frequency respons should be? If
no, then checking result will be hard. If yes, do FFT of impulse
respons and see if match is obtained. But first find out why Y terms
nonzero. Make size of FFT big enough to see detail to make match with
expected. If FIR, use no window on impulse respons.

Regards,

Kamar Ruptan
DSP Guru
Reply With Quote
  #4 (permalink)  
Old 02-21-2008, 09:43 AM
Andor
Guest
 
Posts: n/a
Default Re: filter algorithms

tismealso wrote:
> I have to implement three filters in C++. An IIR, FIR and
> COMBINED(basically a sum of the two).


Perhaps you meant recursive, transversal and combined?

> I have been given the formulae and
> its fairly simple (I think) but I know little about filters and would like
> to be able to test them against something accurate (a good data set). Is
> there something [free] that I can use to input my formulae and obtain a
> good test data set against which I can test my implementation.


You can use Scilab or Octave (free Matlab-like interpreters). As
others have written, you can take noise or an impulse as input and see
what comes out. The impulse response is (theoretically) sufficient to
check your filter. However, programming errors might not show up in
the impulse response, so random signals filtering is a good double-
check for your implementation.


>
> Oddly (from what I have been reading here and elsewhere) the FIR filter
> contains terms in Y. Is this reasonable?


Assuming that Y is the output, then it is possible, but unlikely.
Recursive FIR filter do exist but are probably not on the agenda for
students meeting filters for the first time (but then again, they
might be). An example of a recursive FIR filter is the "boxcar"
filter, which just averages over a number of samples (y is output, x
is input):

y[n] = 1/N (x[n] + x[n-1] + ... + x[n-(N-1)] ).

Its recursive form is

y[n] = y[n-1] + 1/N (x[n] - x[n-N]).

>
> any help appreciated.


Regards,
Andor

Reply With Quote
  #5 (permalink)  
Old 02-21-2008, 03:44 PM
Jim Thomas
Guest
 
Posts: n/a
Default Re: filter algorithms

DSPGURU wrote:
> If in your doubt, Y is output, then this is not reasonable since the
> filter is no more an FIR filter but an IIR filter. Y terms in filter
> mean feedback.


y[n] = x[n] + y[n-1] - x[n-N]

This has feedback, but it's FIR. While IIR's require feedback, feedback
does not necessarily imply IIR.

--
Jim Thomas Principal Applications Engineer Bittware, Inc
[email protected] http://www.bittware.com (603) 226-0404 x536
The sooner you get behind, the more time you'll have to catch up
Reply With Quote
  #6 (permalink)  
Old 02-21-2008, 08:28 PM
tismealso
Guest
 
Posts: n/a
Default Re: filter algorithms

>On Feb 20, 3:13=A0pm, "tismealso" <midgley...@hotmail.com> wrote:
>> I have to implement three filters in C++. An IIR, FIR and
>> COMBINED(basically a sum of the two). I have been given the formula

and
>> its fairly simple (I think) but I know little about filters and woul

like=
>
>> to be able to test them against something accurate (a good data set)

Is
>> there something [free] that I can use to input my formulae and obtai

a
>> good test data set against which I can test my implementation.
>>
>> Oddly (from what I have been reading here and elsewhere) the FI

filter
>> contains terms in Y. Is this reasonable?
>>
>> any help appreciated.

>
>Hello,
>
>If in your doubt, Y is output, then this is not reasonable since the
>filter is no more an FIR filter but an IIR filter. Y terms in filter
>mean feedback.
>


I suspect you are right.

>Where do you get these desine formula?
>


from customer requirements, this is why I havent posted them since the
are in confidence. but I believe they are asking for something they don
want.

>Do you know with certaintly what this frequency respons should be? If
>no, then checking result will be hard. If yes, do FFT of impulse
>respons and see if match is obtained. But first find out why Y terms
>nonzero. Make size of FFT big enough to see detail to make match with
>expected. If FIR, use no window on impulse respons.
>


thank you, it is more a standard curve against a pulse input or a ste
input that I am looking for. something I can prove the code against s
matlab alike. ( I dont have matlab and we wont be buying it for this tas
alone).

>Regards,
>
>Kamar Ruptan
>DSP Guru
>


thanks for your help.

Reply With Quote
  #7 (permalink)  
Old 02-21-2008, 08:32 PM
tismealso
Guest
 
Posts: n/a
Default Re: filter algorithms

>tismealso wrote:
>> I have to implement three filters in C++. An IIR, FIR and
>> COMBINED(basically a sum of the two).

>
>Perhaps you meant recursive, transversal and combined?
>
>> I have been given the formulae and
>> its fairly simple (I think) but I know little about filters and woul

like
>> to be able to test them against something accurate (a good data set)

Is
>> there something [free] that I can use to input my formulae and obtai

a
>> good test data set against which I can test my implementation.

>
>You can use Scilab or Octave (free Matlab-like interpreters). As
>others have written, you can take noise or an impulse as input and see
>what comes out. The impulse response is (theoretically) sufficient to
>check your filter. However, programming errors might not show up in
>the impulse response, so random signals filtering is a good double-
>check for your implementation.
>
>


Excellent that is what I am looking for, thankyou very much.

>>
>> Oddly (from what I have been reading here and elsewhere) the FI

filter
>> contains terms in Y. Is this reasonable?

>
>Assuming that Y is the output, then it is possible, but unlikely.
>Recursive FIR filter do exist but are probably not on the agenda for
>students meeting filters for the first time (but then again, they
>might be). An example of a recursive FIR filter is the "boxcar"
>filter, which just averages over a number of samples (y is output, x
>is input):
>


I didnt mean to mislead anyone, I am a software engineer and this is
professional exercise, its a small part of a much bigger project, th
filters will have been designed ONCE but I think there is a mistak
because these filters dont need to do anything other than noise supressio
and a certain lead/lag (many filters - same algorithm).

>y[n] = 1/N (x[n] + x[n-1] + ... + x[n-(N-1)] ).
>
>Its recursive form is
>
>y[n] = y[n-1] + 1/N (x[n] - x[n-N]).
>
>>
>> any help appreciated.

>
>Regards,
>Andor
>
>

thanks again,

Reply With Quote
  #8 (permalink)  
Old 02-22-2008, 02:17 AM
DSPGURU
Guest
 
Posts: n/a
Default Re: filter algorithms

On Feb 21, 9:44*am, Jim Thomas <jtho...@bittware.com> wrote:
> DSPGURU wrote:
> > If in your doubt, Y is output, then this is not reasonable since the
> > filter is no more an FIR filter but an IIR filter. Y terms in filter
> > mean feedback.

>
> y[n] = x[n] + y[n-1] - x[n-N]
>
> This has feedback, but it's FIR. *While IIR's require feedback, feedback
> does not necessarily imply IIR.
>
> --
> Jim Thomas * * * * * *Principal Applications Engineer *Bittware, Inc
> jtho...@bittware.com *http://www.bittware.com* *(603) 226-0404 x536
> The sooner you get behind, the more time you'll have to catch up


Hello James,

You are correct that you can take FIR filter and add cancelling pairs
of poles and zeros to make it have feedback. Rarely would you ever
want to, rarely would you want such a filter from general filter
design program. Generally (not your example) it makes filter take more
computations, makes some fix-point implementation harder. In special
case of boxcar function you present, since filter has pole on unit
circle, having the filter work right depends on things that one would
need to be knowledgable off or have luck to avoid. If you break filter
into two sections, first implementing denominator, second implementing
numerator, filter can only work with non-saturating fix-point
implementation, not floating-point, not saturating fix-point, because
first section is unstable. If program designed your filter and got 2
ones in denominator, exactly, but numerator coefficients not exactly
same (1 or not, but not 0), then filter not stable. If all cancelling
poles and zeros not match exactly filter turns to IIR. Your filter is
special design for boxcar filter alone or as use in CIC filter, it
would not be expected from general filter design program. My comments
about 'same' numbers obviously ignore appropriate signs; apply as
appropriate.

Original poster should not expect feedback terms from general filter
design program that is to design FIR filter. If so, he should get
money back.

(got English help from my mate Roopnath, understand better?)

Regards,

Kamar Ruptan
DSP Guru
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Verifying my algorithms [email protected] DSP 2 02-23-2006 02:14 AM
transition from frequency filter (LPF etc.) to noise filter (Kalman filter) Zulkifli DSP 0 02-24-2005 08:43 AM
FFT algorithms.... Apurva Agarwal DSP 0 01-28-2005 01:20 PM
Reg. AGC Algorithms kanhaiya DSP 5 09-01-2004 12:47 AM
Algorithms for DSP Rune Allnor DSP 3 12-13-2003 07:12 PM


All times are GMT +1. The time now is 01:17 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved