Digital Filter Design

Thread Starter

mrn22

Joined Feb 16, 2022
12
I need some insight on how to develop a digital high pass filter with cutoff frequency of 1.1 Hz and sampling frequency of 1MHz. The allowed pass band ripple is 0.2 dB. I am thinking of Butter Worth high pass filter but i am not getting good results (using Matlab design tools), primarily because of High Sampling Rate.
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
hi mrn,
Welcome to AAC.
Post a circuit of the Butterworth circuit, we may be able to duplicate in LTspice.
E
Thank you for your reply.
Unfortunately, i don't have a circuit. I am trying to design a software (digital) Filter. My main goal is to replace an old hardware filter with a software Filter because the company supplying the Filter does not manufacture the filter anymore.
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
A high sampling rate should not adversely affect the characteristics of the filter.
Agreed. For a analog Filter it does not matter at all.

I am trying to implement digital filter for a signal with sampling frequency as high as 1 MHZ and cutoff as frequency as 1.1 Hz, using Matlab, i am not getting correct coefficients.
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
How do you know that the coefficients are not correct?
I ran a signal with frequency components < 1.1 Hz through the filter (coefficients) & found out that the filter did not attenuate the signal at all. Filter equation: y(n) = a0x(n-1) + a1x(n- 2) + a2x(n- 3) - b1y(n- 1) - b2y(n-2)
 

Ian0

Joined Aug 7, 2020
9,816
A high sampling rate should not adversely affect the characteristics of the filter.
For a very low cutoff frequency to sampling ratio it would require filter coefficients that are very small and/or very close to unity. There may not be enough resolution without increasing the number of bits (the TS doesn't state what resolution he is working to )
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
For a very low cutoff frequency to sampling ratio it would require filter coefficients that are very small and/or very close to unity. There may not be enough resolution without increasing the number of bits (the TS doesn't state what resolution he is working to )
I am working with 16 bit ADC , actually -2^15 to 2^15.
 

Papabravo

Joined Feb 24, 2006
21,225
There is not much you can do in a bandwidth of 1.1 Hz. How close to DC did you calculate the attenuation?
I even doubt there is much you could do in the analog domain. You may be fooling yourself.
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
If I put the figures into this coefficient calculator
https://www.earlevel.com/main/2021/09/02/biquad-calculator-v3/
It gives answers that are closer to unity than 1 part in 65536.
With 32-bit internal calculations it might just work.

What does it do? Is it just to remove a DC offset?
Thank you for the link. I will run the coefficients and let you know what it does. I removes DC offset and frequencies below 2 Hz. I subtract mean of the signal from the signal to remove the DC offset but I also need to remove frequencies below 2 Hz.
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
There is not much you can do in a bandwidth of 1.1 Hz. How close to DC did you calculate the attenuation?
I even doubt there is much you could do in the analog domain. You may be fooling yourself.
I actually have an analog filter that works perfectly fine. It's a bandpass filter (1.1 Hz - 3.5 KHz). I just wanted to replace the analog filter with equivalent digital filter as the manufacturer no longer manufactures these filters.
 

Papabravo

Joined Feb 24, 2006
21,225
I actually have an analog filter that works perfectly fine. It's a bandpass filter (1.1 Hz - 3.5 KHz). I just wanted to replace the analog filter with equivalent digital filter as the manufacturer no longer manufactures these filters.
You can use the rolloff on the skirts of the analog filter to estimate the order of the filter you need. Are you intending to use a completely digital approach with no anti-aliasing analog front end. If so, I believe your efforts will be doomed to failure.

EDIT: Do you have a schematic of that analog filter?
EDIT2: Big difference between a highpass filter and a bandpass filter. Which is it?
 
Last edited:

Ian0

Joined Aug 7, 2020
9,816
Thank you for the link. I will run the coefficients and let you know what it does. I removes DC offset and frequencies below 2 Hz. I subtract mean of the signal from the signal to remove the DC offset but I also need to remove frequencies below 2 Hz.
If you want to remove the DC offset, there's not much point in using a second-order filter, it just makes things more difficult.
Low pass filter to get the DC offset value and then subtract it from the data.
You can do it in four instructions in ARM assembler.
Data is in R0, the DC offset is stored in the address indexed by R2
LDR R1,[R2]
SUBS R1,R1,R1,ASR#16
ADDS R1,R1,R0
STR R1,[R2]

Then subtract the DC offset from the data
SUBS R0,R0,R1,ASR#16
and you have data with the DC offset removed.

The cutoff is Fsample/(2π. 2^16) which is 2.4Hz
 

Thread Starter

mrn22

Joined Feb 16, 2022
12
You can use the rolloff on the skirts of the analog filter to estimate the order of the filter you need. Are you intending to use a completely digital approach with no anti-aliasing analog front end. If so, I believe your efforts will be doomed to failure.

EDIT: Do you have a schematic of that analog filter?
EDIT2: Big difference between a highpass filter and a bandpass filter. Which is it?
I don't have the schematic of the analog filter. I tried to split bandpass filter into low pass (cutoff 3.5 KHz, sampling fq 1 MHz) and high pass (cutoff 1.1Hz, sampling fq 1 MHz) . I have low pass filter working perfectly alright. I am trying to implement the high pass filter.
 

Papabravo

Joined Feb 24, 2006
21,225
I don't have the schematic of the analog filter. I tried to split bandpass filter into low pass (cutoff 3.5 KHz, sampling fq 1 MHz) and high pass (cutoff 1.1Hz, sampling fq 1 MHz) . I have low pass filter working perfectly alright. I am trying to implement the high pass filter.
Use an analog lowpass with a corner at 3.5 kHz. and the digital algorithm on the output of the LPF. That's what I would do.
 
Top