From: Xplosiv166 on
Hi,

I am looking to implement the following filter in either C, C#.Net or
Visual Basic.Net.

Type: - Low Pass FIR
Sampling Frequency: - 480Hz (10Bit ADC Values from a microprocessor)
Number of TAPs: - 51
Cut-off frequency: - 30Hz
Window: - Kaiser

Basically this is a filter that somebody has proved using LabView and I
need to write a similar filter in the either of the above languages.

So far i have got an FFT (Forward and reverse) working it C and Visual
Basic.Net, but have no idea how I would go about writing the above filter.
Can somebody help point me to a tutorial? I have ordered a book recommend
in another post so helpfully that will help.

The other option is to give-up and buy a filter library for Visual Basic
or Visual C#.Net but i am not sure if a) one exists and b) it is within my
budget.

any advice would be much appreciated,

Best regards,

Xplosiv166


From: Rune Allnor on
On 3 Nov, 19:15, "Xplosiv166" <andrew_...(a)blueyonder.co.uk> wrote:
> Hi,
>
> I am looking to implement the following filter in either C, C#.Net or
> Visual Basic.Net.
>
> Type:               - Low Pass FIR
> Sampling Frequency: - 480Hz (10Bit ADC Values from a microprocessor)
> Number of TAPs:     - 51
> Cut-off frequency:  - 30Hz
> Window:             - Kaiser
>
> Basically this is a filter that somebody has proved using LabView and I
> need to write a similar filter in the either of the above languages.

If you need to replicate what others have already done in LabView,
the main concern is to get hold of a copy of the filter coefficients
that whoever have shown to work in the application.

Once you have the coefficients, the filer itself is a simple loop
(pseudo code inspired by matlab):

x = vector of N input samples
y = zeros(N+50);
h = 50 filter coeffficients

for n=0:(N-1+50)
for k = 0:50
y(n)= y(n)+h(k)*x(n-k);
end
end

Don't take this too literally - I have ignored end effects, proof
reading and testing.

However, once you have the filter coefficients h, the filter is
only marginally more complicated than shown. No need for FFTs or
IFFTs.
The FFT / IFFT pair speed computations up in offline applications,
but tend to complicate matters in online applications. They are
convenient, but not essential.

Newbies can just stick with the simple loop like above. The main
problem with fixed-point arithemtic will likely not be speed, but
numerical inaccuracy issues.

Rune
From: Xplosiv166 on
>On 3 Nov, 19:15, "Xplosiv166" <andrew_...(a)blueyonder.co.uk> wrote:
>> Hi,
>>
>> I am looking to implement the following filter in either C, C#.Net or
>> Visual Basic.Net.
>>
>> Type: =A0 =A0 =A0 =A0 =A0 =A0 =A0 - Low Pass FIR
>> Sampling Frequency: - 480Hz (10Bit ADC Values from a microprocessor)
>> Number of TAPs: =A0 =A0 - 51
>> Cut-off frequency: =A0- 30Hz
>> Window: =A0 =A0 =A0 =A0 =A0 =A0 - Kaiser
>>
>> Basically this is a filter that somebody has proved using LabView and
I
>> need to write a similar filter in the either of the above languages.
>
>If you need to replicate what others have already done in LabView,
>the main concern is to get hold of a copy of the filter coefficients
>that whoever have shown to work in the application.
>
>Once you have the coefficients, the filer itself is a simple loop
>(pseudo code inspired by matlab):
>
>x =3D vector of N input samples
>y =3D zeros(N+50);
>h =3D 50 filter coeffficients
>
>for n=3D0:(N-1+50)
> for k =3D 0:50
> y(n)=3D y(n)+h(k)*x(n-k);
> end
>end
>
>Don't take this too literally - I have ignored end effects, proof
>reading and testing.
>
>However, once you have the filter coefficients h, the filter is
>only marginally more complicated than shown. No need for FFTs or
>IFFTs.
>The FFT / IFFT pair speed computations up in offline applications,
>but tend to complicate matters in online applications. They are
>convenient, but not essential.
>
>Newbies can just stick with the simple loop like above. The main
>problem with fixed-point arithemtic will likely not be speed, but
>numerical inaccuracy issues.
>
>Rune
>

Hi Rune,

Thank you for you response it was very helpful.

Question is the window in this case Kaiser part of the filter coefficients
? or is it part of the filter calculation loop (like in you example above)

Also how hard would it be for me to design the above filter myself? I
don't have any design tools although I think i have a students copy of
Matlab 6.5 somewhere around although this would be no good for commercial
applications.

As i am not sure if I can actual get the coefficients, the filter does not
have to be a perfect match to the one above.

Also Can somebody please explain ((if they have time) why one would use a
window and why would you use a Kaiser window specifically?

Many thanks for your time and help,

Xplosiv166
From: Jerry Avins on
Xplosiv166 wrote:
>> On 3 Nov, 19:15, "Xplosiv166" <andrew_...(a)blueyonder.co.uk> wrote:
>>> Hi,
>>>
>>> I am looking to implement the following filter in either C, C#.Net or
>>> Visual Basic.Net.
>>>
>>> Type: =A0 =A0 =A0 =A0 =A0 =A0 =A0 - Low Pass FIR
>>> Sampling Frequency: - 480Hz (10Bit ADC Values from a microprocessor)
>>> Number of TAPs: =A0 =A0 - 51
>>> Cut-off frequency: =A0- 30Hz
>>> Window: =A0 =A0 =A0 =A0 =A0 =A0 - Kaiser
>>>
>>> Basically this is a filter that somebody has proved using LabView and
> I
>>> need to write a similar filter in the either of the above languages.
>> If you need to replicate what others have already done in LabView,
>> the main concern is to get hold of a copy of the filter coefficients
>> that whoever have shown to work in the application.
>>
>> Once you have the coefficients, the filer itself is a simple loop
>> (pseudo code inspired by matlab):
>>
>> x =3D vector of N input samples
>> y =3D zeros(N+50);
>> h =3D 50 filter coeffficients
>>
>> for n=3D0:(N-1+50)
>> for k =3D 0:50
>> y(n)=3D y(n)+h(k)*x(n-k);
>> end
>> end
>>
>> Don't take this too literally - I have ignored end effects, proof
>> reading and testing.
>>
>> However, once you have the filter coefficients h, the filter is
>> only marginally more complicated than shown. No need for FFTs or
>> IFFTs.
>> The FFT / IFFT pair speed computations up in offline applications,
>> but tend to complicate matters in online applications. They are
>> convenient, but not essential.
>>
>> Newbies can just stick with the simple loop like above. The main
>> problem with fixed-point arithemtic will likely not be speed, but
>> numerical inaccuracy issues.
>>
>> Rune
>>
>
> Hi Rune,
>
> Thank you for you response it was very helpful.
>
> Question is the window in this case Kaiser part of the filter coefficients
> ? or is it part of the filter calculation loop (like in you example above)
>
> Also how hard would it be for me to design the above filter myself? I
> don't have any design tools although I think i have a students copy of
> Matlab 6.5 somewhere around although this would be no good for commercial
> applications.
>
> As i am not sure if I can actual get the coefficients, the filter does not
> have to be a perfect match to the one above.
>
> Also Can somebody please explain ((if they have time) why one would use a
> window and why would you use a Kaiser window specifically?

The shaping window will usually be part of the given coefficients. The
capculations will certainly be done that way. You can ask when you get
the coefficients whether they have been windowed or not.

From what you wrote, the filter was designed according to the "windowed
sinc" method. The choice of window sets the stop-band attenuation,
passband ripple, and band-edge sharpness. More sophisticated windows
improves the first two and worsens the last. A few more taps get that
performance back.

A window increases the stop-band attenuation

If, in the end, you need to derive the coefficients yourself, ignore all
that and use a filter-design program that iteratively calculates optimum
coefficients with whatever cut-off sharpness, stop-band attenuation, and
passband ripple is specified. You can use a free trial version of
ScopeFIR form http://www.iowegian.com/ to calculate the coefficients.

A low-pass with a cutoff frequency that is such a small fraction of the
sample frequency is best done with an IIR unless there is a particular
reason to use an FIR filter. Was that considered?

Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
From: Jerry Avins on
Jerry Avins wrote:

...

> A window increases the stop-band attenuation
>
> If, in the end, you need to derive the coefficients yourself, ignore all
> that and use a filter-design program that iteratively calculates optimum
> coefficients with whatever cut-off sharpness, stop-band attenuation, and
> passband ripple is specified. You can use a free trial version of
> ScopeFIR form http://www.iowegian.com/ to calculate the coefficients.
>
> A low-pass with a cutoff frequency that is such a small fraction of the
> sample frequency is best done with an IIR unless there is a particular
> reason to use an FIR filter. Was that considered?

Look at http://www.dsptutor.freeuk.com/remez/RemezFIRFilterDesign.html
and http://www.dsptutor.freeuk.com/IIRFilterDesign/IIRFiltDes102.html

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