DSPRelated.com
Forums

Re: High pass filter effect on frequency spectrum

Started by Jeff Brower June 22, 2009
Ramaraju-
> Here I have some observation with high pass filter implementation.
>
> Suppose if
>
> Sampling frequency is 2560
>
> Cutoff frequency is 10hz.
>
> Tap length is 500.
>
> ADC :24 bit
>
> Vref : 5V
>
> I observed that noise floor level is more in the fft spectrum , in which highpass
> filter is implemented compare to one which is High pass filter is not implemented.
> I am using windowed sinc filters.(hanning) according FDA tool pass-band should
> be proper.
>
> Is that High Pass filter will add any non-linearity in pass-band?

You are implementing on which DSP? Fixed-point or floating-point? If fixed-point,
what Q-notation are you using for the FIR filter coefficients?

What was the FIR design method you used? Can you post a plot of the filter response?
As a note, I designed a Kaiser Window type HPF to match your specs using
Hypersignal software, and to stay within your 500 tap length the maximum stop-band
attention could be 37 dB and max ripple about 1 dB. Is that what you expect?

-Jeff
Ramaraju SVS-

> i implemented on TI- OMAP processor (but i am using floating point operation).
> coefficient also in float format.
> i simulated same scenario with matlab. matlab also gives same kind of response.
> here i am giving matlab code

If you want to make your f-domain plots look "pretty", try setting SigFreq to a power
of 2 and a submultiple of Fs, and use Hamming window and 50% overlap. With a Hanning
window, you would expect to see some harmonics at 2*SigFreq and 4*SigFreq. At this
link is an example of what I mean:

http://www.signalogic.com/images/kaiser_hpf_hsm.jpg

In the plots, SigFreq = 128, Fs = 2560, STFFT params are [4096, 4096, Hanning, 50%
overlap], and top/bot traces are non-filtered/filtered (filter being Kaiser Window
500 tap HPF, 10 Hz Fc, -37 db atten, 1 dB passband ripple).

Note that both the filtered and non-filtered waveforms look the same... so I'm
guessing your "noise floor" issue has more to do with understanding short-time FFT
processing and plotting, rather than filtering, which you are probably doing fine.

-Jeff

> clc;
> clear all;
> close all;
>
> gain1=1.17044;
> FFTLength@96
> RPM840;
> fs = 16384/1 ; % Sampling frequency
> Ts=1/fs;
> Ns@960;
> %signal freq 1KhZ
> SigFreq00;
>
> t=[0:Ts:Ts*(Ns-1)];
> inputdata=sin(2*pi*SigFreq*t);
> figure;
> plot(inputdata(1:4096));
> title('Timedomain data');
>
> %take first set
> xn=inputdata(1:4096)
> xn=xn';
>
> %apply highpass filter
> N = 500; % Order
> Fc = 10; % Cutoff Frequency
> flag = 'noscale'; % Sampling Flag
>
> % Create the window vector for the design algorithm.
> win = hann(N+1);
>
> % Calculate the coefficients using the FIR1 function.
> b = fir1(N, Fc/(fs/2), 'high', win, flag);
> Hd = dfilt.dffir(b);
> Hp_out=filter(b,1,xn);
> figure;
> plot(Hp_out);
> title(' hp output');
>
> %windowing
> wn= hann(length(Hp_out));
>
> wn= wn';
> xn= Hp_out .*wn';
>
> %verf is 2.5v
> VdBref *log10(2.5);
> fftout= abs(fft(xn,length(xn)));
> fftout= fftout ./(length(fftout)/2);
> y1 *log10(fftout(1:length(fftout)/2));
> y1=y1-VdBref;
> f1 =[1:1:length(y1)];
> figure;
> plot(f1*fs/length(xn),y1);
> title('FFT asper matlab hp output');
> here my cutoff frequency always 10hz, where as my sampling frequency can vary
> between 2.5kHz to 51.2KHz. if increase the filter tap length spectrum shape is
> verymuch deviating . i hope that i explained the actual scenario.
>
> Regards,
> Ramaraju
>
> Jeff Brower To
> Ramaraju SVS 06/22/2009 09:49 PM cc
> c...
> Subject
> Re: [c6x] High pass filter effect on frequency
> spectrum
>
> Ramaraju-
>
> Here I have some observation with high pass filter implementation.
>
> Suppose if
>
> Sampling frequency is 2560
>
> Cutoff frequency is 10hz.
>
> Tap length is 500.
>
> ADC :24 bit
>
> Vref : 5V
>
> I observed that noise floor level is more in the fft spectrum , in which highpass
> filter is implemented compare to one which is High pass filter is not implemented.
> I am using windowed sinc filters.(hanning) according FDA tool pass-band should
> be proper.
>
> Is that High Pass filter will add any non-linearity in pass-band?
>
> You are implementing on which DSP? Fixed-point or floating-point? If fixed-point,
> what Q-notation are you using for the FIR filter coefficients?
>
> What was the FIR design method you used? Can you post a plot of the filter
> response? As a note, I designed a Kaiser Window type HPF to match your specs using
> Hypersignal software, and to stay within your 500 tap length the maximum stop-band
> attention could be 37 dB and max ripple about 1 dB. Is that what you expect?
>
> -Jeff

_____________________________________
i implemented on TI- OMAP processor (but i am using floating point
operation). coefficient also in float format.
i simulated same scenario with matlab. matlab also gives same kind of
response. here i am giving matlab code
clc;
clear all;
close all;
gain1=1.17044;
FFTLength@96
RPM840;
fs = 16384/1 ; % Sampling frequency
Ts=1/fs;
Ns@960;
%signal freq 1KhZ
SigFreq00;

t=[0:Ts:Ts*(Ns-1)];
inputdata=sin(2*pi*SigFreq*t);
figure;
plot(inputdata(1:4096));
title('Timedomain data');

%take first set
xn=inputdata(1:4096)
xn=xn';

%apply highpass filter
N = 500; % Order
Fc = 10; % Cutoff Frequency
flag = 'noscale'; % Sampling Flag

% Create the window vector for the design algorithm.
win = hann(N+1);

% Calculate the coefficients using the FIR1 function.
b = fir1(N, Fc/(fs/2), 'high', win, flag);
Hd = dfilt.dffir(b);
Hp_out=filter(b,1,xn);
figure;
plot(Hp_out);
title(' hp output');

%windowing
wn= hann(length(Hp_out));

wn= wn';
xn= Hp_out .*wn';

%verf is 2.5v
VdBref *log10(2.5);
fftout= abs(fft(xn,length(xn)));
fftout= fftout ./(length(fftout)/2);
y1 *log10(fftout(1:length(fftout)/2));
y1=y1-VdBref;
f1 =[1:1:length(y1)];
figure;
plot(f1*fs/length(xn),y1);
title('FFT asper matlab hp output');

here my cutoff frequency always 10hz, where as my sampling frequency
can vary between 2.5kHz to 51.2KHz. if increase the filter tap length
spectrum shape is verymuch deviating . i hope that i explained the actual
scenario.

Regards,
Ramaraju

Jeff Brower
06/22/2009 09:49 PM

To
Ramaraju SVS
cc
c...
Subject
Re: [c6x] High pass filter effect on frequency spectrum

Ramaraju-

Here I have some observation with high pass filter implementation.
Suppose if
Sampling frequency is 2560
Cutoff frequency is 10hz.
Tap length is 500.
ADC :24 bit
Vref : 5V
I observed that noise floor level is more in the fft spectrum , in which
highpass filter is implemented compare to one which is High pass filter
is not implemented. I am using windowed sinc filters.(hanning) according
FDA tool pass-band should be proper.
Is that High Pass filter will add any non-linearity in pass-band?

You are implementing on which DSP? Fixed-point or floating-point? If
fixed-point, what Q-notation are you using for the FIR filter
coefficients?
What was the FIR design method you used? Can you post a plot of the
filter response? As a note, I designed a Kaiser Window type HPF to match
your specs using Hypersignal software, and to stay within your 500 tap
length the maximum stop-band attention could be 37 dB and max ripple about
1 dB. Is that what you expect?
-Jeff
Ramaraju-

> It is highly difficult to design whose cutoff frequency is 10Hz and
> sampling frequency is 51.2 kHz.

Yes, it is very difficult. The 'Q' of such a filter is extremely high, and leads to
various issues such as numerical precision and, if you were to use IIR filters,
stability concerns. I didn't look closely at your MATLAB code, but when I did the
design and frequency response measurement using Hypersignal with Fs = 2560 Hz, I got
a decent result (filter response plots posted previously). In that case, 500 taps
(your spec) yielded stopband attenuation of -37 dB. With Fs = 51.2 kHz, Hypersignal
recommended 10001 taps; if I used 4095 taps I got -7 dB stopband attenuation. To me,
these results indicate the "noise floor", as you call it, isn't actually a problem
having to do with noise, but rather to with filter design.

With such extreme specs, I think you should consider going another direction, for
example IIR design methods. Otherwise, you're going to need vastly increased FIR
filter length, and you will be on a path impractical to implement in a real product.

One note: you seem to be using only even-length FIR filters, for example 500 taps in
your code below. For high-pass filters, I suggest using odd length filters. You can
Google this subject to delve into why (one link is here:
http://firdesigner.com/app-notes/high-pass-filters/).

-Jeff

PS. Please post to the group, not to me. My job permits me to only respond to group
posts.

> What I mentioned high-pass filter effect on Frequency spectrum is
> happening t at lower cutoff frequencies( 2 to 10Hz).
> I’ll explain actual scenario. Data acquisition unit acquire data based on
> the machine RPM. It is required to attenuate whose signals in the range of
> DC- to 10Hz. RPM ranges from 30 to 12000 (sampling frequency ranges from
> 51200 to 128Hz).
> It is highly difficult to design whose cutoff frequency is 10Hz and
> sampling frequency is 51.2 kHz.
> I observed one thing. Suppose if I select constant sampling frequency (Fs)
> ,Cutoff frequency fc& vary tap length , as taplenth increases noise floor
> in the spectrum in creasing.
> Here I am giving following details
>
> The following attached files shows the fft output for different
> taplengths.
> Here I am giving matlab code
> clc;
> clear all;
> close all;
> FFTLength@96
> fs = 256 ; % Sampling frequency
> Ts=1/fs;
> Ns@960;
> %signal freq 1KhZ
> SigFreq ;
>
> t=[0:Ts:Ts*(Ns-1)];
> inputdata=sin(2*pi*SigFreq*t);
> figure;
> plot(inputdata(1:4096));
> title('Timedomain data without filter');
>
> %take first set
> xn=inputdata(1:4096);
> xn=xn';
>
> %apply pass filter
> N = 500; % Order
> Fc = 2; % Cutoff Frequency
> flag = 'noscale'; % Sampling Flag
> % Create the window vector for the design algorithm.
> win = hann(N+1);
> % Calculate the coefficients using the FIR1 function.
> b = fir1(N, Fc/(fs/2), 'high', win, flag);
> figure;
> freqz(b);
> Hd = dfilt.dffir(b);
> Hp_out=filter(b,1,xn);
> figure;
> plot(Hp_out);
> title(' hp output');
> %windowing
> wn= hann(length(Hp_out));
> wn= wn';
> wn= wn *2;
> xn2= Hp_out .*wn';
>
> %verf is 2.5v
> VdBref *log10(2.5);
> fftout= abs(fft(xn2,length(xn2)));
> fftout= fftout ./(length(fftout)/2);
> y1 *log10(fftout(1:length(fftout)/2));
> y1=y1-VdBref;
> f1 =[1:1:length(y1)];
> figure;
> plot(f1*fs/length(xn),y1);
> title('FFT asper matlab hp output');
> %windowing
> wn= hann(length(Hp_out));
> wn= wn';
> wn= wn *2;
> xn2= xn .*wn';
> %xn2=xn;
> %verf is 2.5v
> VdBref *log10(2.5);
> fftout= abs(fft(xn2,length(xn2)));
> fftout= fftout ./(length(fftout)/2);
> y1 *log10(fftout(1:length(fftout)/2));
> y1=y1-VdBref;
> f1 =[1:1:length(y1)];
> figure;
> plot(f1*fs/length(xn),y1);
> title('FFT asper matlab without HP');
> I am unable to understand the relationship between tap length verses
> spectrum shape. As tap length increases, as tap length increases spectrum
> should be sharp ( as per my understanding).
> Is there any standard procedure to drive this relation?
> I’ll be very much thankful if you guide me in this regard.
>
> Thanking you.
> Ramaraju
>
> Jeff Brower
> Sent by: c...
> 06/23/2009 09:09 PM
>
> To
> Ramaraju SVS
> cc
> c...
> Subject
> [Fwd: Re: [c6x] High pass filter effect on frequency spectrum]
> Ramaraju SVS-
>
> To clarify one thing, the plots show 3rd, 7th, and 9th harmonics. The 5th
> harmonic
> is missing because 128*5 (SigFreq*5) is an integer submultiple of Fs
> (2560).
>
> -Jeff
>
> -------- Original Message --------
> Subject: Re: [c6x] High pass filter effect on frequency spectrum
> Date: Tue, 23 Jun 2009 03:01:00 -0500
> From: Jeff Brower
> Organization: Signalogic, Inc
> To: Ramaraju SVS
> CC: c...
>
> Ramaraju SVS-
>
>> i implemented on TI- OMAP processor (but i am using floating point
> operation).
>> coefficient also in float format.
>> i simulated same scenario with matlab. matlab also gives same kind of
> response.
>> here i am giving matlab code
>
> If you want to make your f-domain plots look "pretty", try setting SigFreq
> to a power
> of 2 and a submultiple of Fs, and use Hamming window and 50% overlap. With
> a Hanning
> window, you would expect to see some harmonics at 2*SigFreq and 4*SigFreq.
> At this
> link is an example of what I mean:
>
> http://www.signalogic.com/images/kaiser_hpf_hsm.jpg
>
> In the plots, SigFreq = 128, Fs = 2560, STFFT params are [4096, 4096,
> Hanning, 50%
> overlap], and top/bot traces are non-filtered/filtered (filter being
> Kaiser Window
> 500 tap HPF, 10 Hz Fc, -37 db atten, 1 dB passband ripple).
>
> Note that both the filtered and non-filtered waveforms look the same... so
> I'm
> guessing your "noise floor" issue has more to do with understanding
> short-time FFT
> processing and plotting, rather than filtering, which you are probably
> doing fine.
>
> -Jeff
>
>> clc;
>> clear all;
>> close all;
>>
>> gain1=1.17044;
>> FFTLength@96
>> RPM840;
>> fs = 16384/1 ; % Sampling frequency
>> Ts=1/fs;
>> Ns@960;
>> %signal freq 1KhZ
>> SigFreq00;
>>
>> t=[0:Ts:Ts*(Ns-1)];
>> inputdata=sin(2*pi*SigFreq*t);
>> figure;
>> plot(inputdata(1:4096));
>> title('Timedomain data');
>>
>> %take first set
>> xn=inputdata(1:4096)
>> xn=xn';
>>
>> %apply highpass filter
>> N = 500; % Order
>> Fc = 10; % Cutoff Frequency
>> flag = 'noscale'; % Sampling Flag
>>
>> % Create the window vector for the design algorithm.
>> win = hann(N+1);
>>
>> % Calculate the coefficients using the FIR1 function.
>> b = fir1(N, Fc/(fs/2), 'high', win, flag);
>> Hd = dfilt.dffir(b);
>> Hp_out=filter(b,1,xn);
>> figure;
>> plot(Hp_out);
>> title(' hp output');
>>
>> %windowing
>> wn= hann(length(Hp_out));
>>
>> wn= wn';
>> xn= Hp_out .*wn';
>>
>> %verf is 2.5v
>> VdBref *log10(2.5);
>> fftout= abs(fft(xn,length(xn)));
>> fftout= fftout ./(length(fftout)/2);
>> y1 *log10(fftout(1:length(fftout)/2));
>> y1=y1-VdBref;
>> f1 =[1:1:length(y1)];
>> figure;
>> plot(f1*fs/length(xn),y1);
>> title('FFT asper matlab hp output');
>> here my cutoff frequency always 10hz, where as my sampling frequency can
> vary
>> between 2.5kHz to 51.2KHz. if increase the filter tap length spectrum
> shape is
>> verymuch deviating . i hope that i explained the actual scenario.
>>
>> Regards,
>> Ramaraju
>>
>> Jeff Brower To
>> Ramaraju SVS
>>
>> 06/22/2009 09:49 PM cc
>> c...
>> Subject
>> Re: [c6x] High pass filter effect on frequency
>> spectrum
>>
>> Ramaraju-
>>
>> Here I have some observation with high pass filter implementation.
>>
>> Suppose if
>>
>> Sampling frequency is 2560
>>
>> Cutoff frequency is 10hz.
>>
>> Tap length is 500.
>>
>> ADC :24 bit
>>
>> Vref : 5V
>>
>> I observed that noise floor level is more in the fft spectrum , in which
> highpass
>> filter is implemented compare to one which is High pass filter is not
> implemented.
>> I am using windowed sinc filters.(hanning) according FDA tool pass-band
> should
>> be proper.
>>
>> Is that High Pass filter will add any non-linearity in pass-band?
>>
>> You are implementing on which DSP? Fixed-point or floating-point? If
> fixed-point,
>> what Q-notation are you using for the FIR filter coefficients?
>>
>> What was the FIR design method you used? Can you post a plot of the
> filter
>> response? As a note, I designed a Kaiser Window type HPF to match your
> specs using
>> Hypersignal software, and to stay within your 500 tap length the maximum
> stop-band
>> attention could be 37 dB and max ripple about 1 dB. Is that what you
> expect?
>>
>> -Jeff

_____________________________________