Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need corrections for the lowpass filter design

Status
Not open for further replies.

patan.gova

Full Member level 3
Full Member level 3
Joined
Dec 19, 2011
Messages
172
Helped
4
Reputation
8
Reaction score
0
Trophy points
1,296
Visit site
Activity points
2,776
Hello, I am acquiring pulse signal from micro controller sampled at a rate of 100Hz. I want to filter the lowfrequency components pulse signal below 4Hz. I tried like this but it is not working perfectly. Can someone guide me with the lowpass design

the data1 here is used is attached below in the text file.

d = fdesign.lowpass('N,Fc',31,4,100);
Hd1 = design(d);
data2 = filtfilt(Hd1.Numerator,1,data1);

The filter reponse using was this

filtered_image.JPG

The data for 1 second sampled at a rate of 100Hz with the incoming pulse signal being 6Hz ia attched below.

can someone help me out with the implemenatation as I am not sure which oen to use FIR or IIR fitler type.
Thanks.View attachment pulse_data5000.txt
 

Your lower waveform looks as though it is averaging the pulses, and the pulses are positive polarity.

I guess you expected the lower waveform to look like a 6 Hz sine wave? That would be the case if your pulses were both positive and negative.

However the averaging waveform will be low amplitude, since your 6 Hz pulses are brief pulses.
 

It looks like the filter is working correctly, since it's doing a good job of removing the 6Hz pulses, while passing the slowly changing DC average.

Presumably that's what's wanted, since you've specified a low-pass filter with a response that rolls off sharply above 4Hz.
 

It looks like the filter is working correctly, since it's doing a good job of removing the 6Hz pulses, while passing the slowly changing DC average.

Presumably that's what's wanted, since you've specified a low-pass filter with a response that rolls off sharply above 4Hz.
Apart form counter-intuitive display of filter response with Matlab filtfilt "zero-phase" function, the output looks expectable. I would prefer to see the causal FIR output signal.

Referring to a post in your previous thread, I have to mention that a 31 tap FIR is still rather short for fs/fc = 100/4. I suggest to call filtz(Hd1) to view the frequency response.
 

thanks for your explanations,
BradtheRad :I guess you expected the lower waveform to look like a 6 Hz sine wave?
No,I expected it to be a DC line because if we theoretically assume that we are removing freq greater than 4Hz in this case its 6HZ freq so it should give out a DC line isn't it.

FvM :I have to mention that a 31 tap FIR is still rather short for fs/fc = 100/4.
Can I know what can be the best tap value that suits this requirement.

Can someone suggest me the best FIR filter design in terms of the
1) type-equiripple,butterworth or if any other types
2)the order
that can do the filtering job best for fc=4Hz and sampling rate=100Hz for the above attached data.
thanks.
 

I didn't yet hear a word about application related filter requirements. So any answer would be pretty arbitrary.
 

I am planning to remove the pulse signals above 4Hz.I need to design matlab filter for this: where the signal is being sampled at 100Hz.
For testing this matlab filter working I am feeding a pulse signal from function generator with an amplitude of 2.5V by varying the freqeucny in the range of 2hz to 6Hz,When the freq of the input signal is >4Hz the output of the filter should be filtered.

Main application of the filter:Actually I will implement the digital filter on microcontroller by using the coefficients generated from this matlab desiged filter.
 

Basic facts about low-pass filters

No filter will exactly remove a signal component, it's attenuating it by a specific amount. A filter specification involves beside a cut-off frequency a stop-band attenuation at a specific frequency respectively a stopband slope. Also an acceptable passband ripple (level variation below the cut-off frequency) and possibly a time domain specification.

The filter order and other parameters will be selected according to this specification.
 

No,I expected it to be a DC line because if we theoretically assume that we are removing freq greater than 4Hz in this case its 6HZ freq so it should give out a DC line isn't it.

Your waveform will be more like a DC line if you install a diode, which creates a peak detector.

Its operation combines aspects of (a) a low-pass filter, (b) an averager, (c) a pulse extender.

Anyway it may provide the kind of output you're expecting.

6580460200_1393541738.png
 

I tried to check the filter with different cutoff frequencies as shown below

Lowpass fc=4Hz

Hf = fdesign.lowpass('N,Fc',31,4,100);
Hd =design (Hf);
Coeff= Hd.Numerator;
data3= filtfilt(Hd.Numerator,1,a);

Lopass fc=8Hz

Hf = fdesign.lowpass('N,Fc',31,8,100);
Hd =design (Hf);
Coeff= Hd.Numerator;
data2= filtfilt(Hd.Numerator,1,a);

plot (a);hold on;plot(data3,'-r');plot(data2,'-g')

**broken link removed**


when I use fc=8Hz it is allowing the 6Hz freq components but they are attenuated and they output looks like sine waveform instead of pulse signal as input.

Can someone suggest a better filter design that doesn’t attenuates when frequencies are below fc I mean the filter output should give the same or nearly same input (pulse signal).
 

I think you are misunderstanding filters. To reproduce a pulse signal, you need to pass at least the 5th harmonic
 

Sorry, the image above attached is not showing so here it is


LP_filter_fc_chnages.JPG.

can somone suggest a filter deisgn that will be atleast better than what I designed because there is much difference in the output of the fitler when the fc is changed, which should more or less pass the input signal when they are less than fc and should atleast attenaute the input when they are above fc(4Hz)
Thanks.
 

There's a nice Falstad fourier series tool which allows you to visualize the effect if filtering harmonics from a square wave or pulse signal. https://www.falstad.com/fourier/

I suggest to play around with it a bit to understand your problem with filtering pulse waveforms. Of course you can do the same with Matlab, but it's much more easy this way.

In the example, up to fourth harmonic passes the filter.

 
Thanks.
Can I know will there be any improvement with filter output if the IIR fitler is used instead of FIR fitler.
can somone suggest an IIR filter to filter this input pulse signal with Fc=4Hz and sampling frequency =100HZ as attached here.
 

Attachments

  • pulse_data5000.txt
    4.6 KB · Views: 108

It is impossible for any filter to do what you are asking for. Look at what you have found in your testing:

when I use fc=8Hz it is allowing the 6Hz freq components but they are attenuated and they output looks like sine waveform instead of pulse signal as input.
That is inevitable. The reason is simple - The 6Hz pulse signal contains frequencies of 12Hz, 18Hz, 24Hz, 30Hz etc as well as 6Hz. Those higher frequencies are what gives the waveform it's shape. If you remove the higher frequencies, the output will look like a sine wave, as you have found.
 
Thanks for the explanation but how to visualise or analyse prctically that 6Hz input pusle signal was containing 12Hz, 18Hz, 24Hz, 30Hz etc as well as 6Hz.which then passed through Lowpass fitler of 8Hz removes all freq components >8Hz (I mean it removes 12Hz, 18Hz, 24Hz, 30Hz) while leaving only 6Hz freq componets in the output which will be the sine wave as I got.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top