There are 8 messages in this thread.
You are currently looking at messages 1 to .
Is this discussion worth a thumbs up?
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.______________________________
>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.
>
>
>
My suggestion is to simulate it in Matlab using a noise signal as the
filters input. Create any kind of noise signal
(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, so
you'll need to save you're workspace for repeatable results.
Then put the coefficients ("a" and "b" terms) into the filter() function
and BAM you're done. If you have a series of filters, you also convolve
the coefficients to get the cascaded response usning conv(). Keep in mind
this is done easily with floating point arithmetic. If it's fixed point
then you'll have to be much more crafty with you're Matlab code.
Unfortunatley there is no standard data set out there for verification
purposes, you'll have to create your own.
Jeff
______________________________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______________________________
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______________________________
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 j...@bittware.com http://www.bittware.com (603) 226-0404 x536 The sooner you get behind, the more time you'll have to catch up______________________________
>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. > I suspect you are right. >Where do you get these desine formula? > from customer requirements, this is why I havent posted them since they are in confidence. but I believe they are asking for something they dont 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 step input that I am looking for. something I can prove the code against so matlab alike. ( I dont have matlab and we wont be buying it for this task alone). >Regards, > >Kamar Ruptan >DSP Guru > thanks for your help.______________________________
>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. > > Excellent that is what I am looking for, thankyou very much. >> >> 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): > I didnt mean to mislead anyone, I am a software engineer and this is a professional exercise, its a small part of a much bigger project, the filters will have been designed ONCE but I think there is a mistake because these filters dont need to do anything other than noise supression 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,______________________________
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______________________________