Electronic – Time delay: digital low pass filter VS analog low pass filter

digital filterfilterfirlow pass

I am new on digital filter, hopefully I can get some intuitive insights here. So, here is the question:

A low pass filter with 5Hz cut-off frequency is to be designed. The signals presented have maximum frequency of 1kHz. Therefore a 1MHz sampling rate will fully satisfy the Naquist Sampling theory for the digital filter part.

Analog Filter:

Say I want to implement a 5Hz analog low pass filter, I need to wait at least 0.2s, or even 10 times more time, to get one accurate data, because of the charging time of RC circuits.

Digital Filter:

Are things the same for digital filters?
Say I want to implement a 10 tap(data length) low pass filter with cut off frequency 5Hz. The sampling rate is 1MHz. Can I get a valid data within 1/(1MHz/10) = 10us time? That seems not very reasonable to me….

Comments Needed:

In this application, two filters are to be designed.

In both filters, we only want to know the DC. The DC signal is buried in large noises. A cutoff frequency of 5Hz is chosen, since we want to have valid readings at 5Hz. And lower cutoff frequency means smaller noises, but also longer time needed to get an appropriate reading.

One filter has bandwidth of 6kHz(not 1MHz, which was just an example). And we are planning to over sample it with sampling rate of 36kHz. The other one filter has bandwidth of 60Hz, and we are planning to over sample it at 1kHz.

As can be observed from the filter description, we want lower noises, as low as possible. Therefore the digital filters are expected to have sharp edge at 5Hz. And all other parameters, such as "linear phase, small ripple.. and etc" are not important to us, since we only care about DC readings.

And, I am quite confused by the enormous types of digital filters.. How to choose them? Say, between FIR and IIR?

Best Answer

There is great flexibility in the design of a digital filter. You can design digital filters that behave very similarly to analogue filters (as Andy aka described). You can also build digital filters than can be hard to reproduce in analogue such as a Linear phase filter or a Half-Band filter. Or non-linear digital filters such as Median filters that have no analogue equivalence in LTI systems.

For your requirements of "a sharp, low pass filter" I'd suggest a simple IIR of the form:

out = (1-a)in + aout

the closer 'a' is to 1 the lower the cutoff frequency of your filter.

You may well have a problem with the 1MHz sample rate and 5Hz cutoff because: a = exp(-2*pi*f/fs) where f is the cutoff frequency and fs is the sample frequency. So for your example:

a= exp(-2*pi*5/1E6) = 0.99997

If you really do need a 1MHz sample rate (because your data must be sampled by a 1MSPS ADC for example), then a 3 stage multi-rate filter is more appropriate. For this you would:

  1. Average 32 values at 1MHz and output one sample out of 32 at 1MHz/32
  2. Average 32 values at 1MHz/32 and output one sample out of 32 at 1MHz/32^2 (1MHz/1024)
  3. Implement an LPF as above with a 1MHz/1024 sample rate.

UPDATE BASED ON NEW INFO FROM OP: Based on your information that:

  1. You are interested only in DC
  2. You are not sure about the cutoff frequency because you mention 60Hz and 6kHz bandwidth but also "A cutoff frequency of 5Hz"
  3. You need flexibility in sample rate

I think your best choice is a CIC Decimator.

enter image description here

Basically, its an MA (FIR) digital filter, made up of

  1. an integrator at the input clocked at the ADC sample rate (36kHz shown),
  2. a differentiator at the output clocked at the output rate.

    You can control how much filtering you get by changing the output rate.

For example with an input rate of 36kHz and an output rate of 5Hz this gives you a 36000/5 = 7200 point moving average. In reality you'd like to keep the rates as binary ratios so M=13 gives 36kHz in 36kHz/2^13 out and MA length is 2^M = 8192

The group delay of this will be 2^(M-1)/Fin or 113ms for the above example. That's one of the disadvantages of such a simple circuit but would not be a problem in a system whose DC value varies slowly.