1
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ Your concept of "wait" for an analog filter seems misguided. I can see this in terms of a step response, you'd need to "wait" to get the steady state value, but outside that context, I don't understand your question. \$\endgroup\$ – Scott Seidman May 1 '14 at 13:18
  • \$\begingroup\$ How often do you want an output from the filter? How long can you wait for it to settle? \$\endgroup\$ – akellyirl May 1 '14 at 15:10
  • \$\begingroup\$ @ScottSeidman Yeah, that is exactly what I mean.. A stable reading. Since I want to measure DC, and DC changes very slowly, I need stable readings. \$\endgroup\$ – richieqianle May 1 '14 at 15:46
  • \$\begingroup\$ @akellyirl The measurements have frequency of 5Hz, that is 0.2s per reading \$\endgroup\$ – richieqianle May 1 '14 at 15:46
  • \$\begingroup\$ @richiequanle -- It depends on HOW your baseline is drifting. If it varies as a step (which is pretty rare), yes, you have to "wait" for a stable reading. If it drifts around with a long time constant, you can just take a reading. \$\endgroup\$ – Scott Seidman May 1 '14 at 16:51
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Thank you very much. I have updated the system description in more detail. Would you mind having a look? \$\endgroup\$ – richieqianle May 1 '14 at 13:12
  • \$\begingroup\$ @richieqianle I've had a look and added my thoughts. \$\endgroup\$ – akellyirl May 1 '14 at 17:19
  • \$\begingroup\$ Thanks for your reply.. Could I add a bit on my specifications? 1. Actually two filters are two be designed. 2. The input signal of one filter has bandwidth of 6kHz. And the filter cutoff frequency is 5Hz. 3. The input signal of the other signal is 60Hz and the cutoff frequency is 5Hz as well. Therefore, the flexibility is not very important in this application... \$\endgroup\$ – richieqianle May 6 '14 at 3:04
1
\$\begingroup\$

There are many kinds of filters, and the transient (time-domain) response is directly related to the frequency-domain response.

But it doesn't matter whether the implementation is analog or digital; any filter with a given frequency response is going to have the same transient response.

You pick a filter design based on which aspects of its performance are most important in your application. Some architectures have especially flat frequency-domain passbands, others have particularly steep transition bands, and some are optimized specifically for their time-domain response (e.g., no "ringing"). It's a topic that's really too broad to address here.

\$\endgroup\$
  • \$\begingroup\$ Thanks Dave. I have updated the system description in "Comments needed" section. Could I have your opinion on it? Really appreciated. \$\endgroup\$ – richieqianle May 1 '14 at 13:11
1
\$\begingroup\$

Going from a simple RC low-pass filter to a low-pass digital IIR filter is fairly easy: -

enter image description here

This is a 4-step demo that there is no fundamental difference in performance between an analogue filter and a digital IIR filter.

Regards your 1MHz sampling rate and desired cut-off of 5Hz, this makes the factor (T/CR) very, very small. For instance, CR for an analogue 5Hz LP filter will be: -

CR = \$\dfrac{1}{5\times 2\times \pi}\$ = 0.03183.

If you factor in a 1us time step, T/CR becomes 3.183E-8. However, you can sensibly decimate your data by at least 10,000:1 and work with a sample rate that is 100Hz. This makes the numbers easier of course.

If you want to cascade these filters to get a higher order, I wrote a document that might help you get started. It's here.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your reply. I have read your document, which is quite helpful. Do you mean that "The optimum sampling time of the ADC is actually dependent on the RC?" That means I still need to wait at least 0.2second*k(k>1) for a 5Hz digital low pass filter to get a decent result? \$\endgroup\$ – richieqianle May 1 '14 at 12:54
  • \$\begingroup\$ Could I have your comments on the choice of filters? I have updated the system description in "Comments needed". Really appreciated. \$\endgroup\$ – richieqianle May 1 '14 at 13:10
  • \$\begingroup\$ ADC sampling time being really high means you have to deal with floating point numbers of a high accuracy because each sample is multiplied by a very low number and you need to maintain accuracy numerically. Low sampling can be achieved thru decimation (done properly) then the numbers you are dealing with are not really minute like 3 x \$10^{-8}\$. The equiv RC of the filter dictates the settling time of the filter and has nothing to do with the sampling rate. I'd use several cascaded IIR filters as shown in my answer BUT, I'm not a recognized expert on digital filtering. \$\endgroup\$ – Andy aka May 1 '14 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.