# Oversampling then filtering and downsampling

Currently I'm working on a project to record ELF (Extremely Low Frequency) signals from a receiver. The highest frequency of interest is about 30 Hz and the system should have a flat frequency response. I'm looking for a simple solution using an 8 bit ADC and I wonder how the resolution can be improved using oversampling and to alleviate the requirements for the analog low pass filter before the ADC. Without oversampling and a sampling rate of 64 sps a rather steep analog low pass filter is needed to avoid aliasing. With oversampling and a gain of 3 more bits the sampling rate is 2^(2*3) times 64 sps = 4096 sps and the analog filter before the ADC is much easier to realize. The problem is to convert the 4096 sps signal back to 64 sps using a digital low pass filter and downsampling.

From what I read so far, the attenuation needs to be almost 68 dB at 32 Hz for 11 bits but at the same time signals up to about 30 Hz should pass. It seems a very steep digital low pass filter is needed. I tried to do some calculations with filter design software, but the required order is too high to get results. Is this really so hard to realize or am I missing something? Any help would be greatly appreciated.

• You should look at windowing the signal at the aliaing points(dependent on the sampling frequency). – Naresh Apr 22 '13 at 6:12

As you've figured out, for the filter specifications you gave, you need a very high filter. To summarize, you're asking for:

• Passband edge: 30 Hz
• Stopband edge: 32 Hz
• Minimum stopband attenuation: 68 dB

The main determining factor for the filter order that you need to meet the specifications is the width of the transition band as a fraction of the sample rate. In your case, you want a transition band that is 2 Hz wide, at a sample rate of 4096 Hz. That's a very sharp transition!

A better approach is to perform the decimation in multiple filter stages that are cascaded in series. This allows you to meet the overall frequency response requirements that you have without using a single very-high-order filter. You need an overall decimation factor of 64 to be implemented by the cascade of filters. It can be hard to determine the optimal (in terms of total overall computations to apply the filters) arrangement of stages, but I would recommend the following approach as a start:

• Stage 1: Design a filter with a passband edge at 30 Hz and a stopband edge of (512 - 32) = 480 Hz. Decimate the output of the filter by 8. Thus, at the output of this filter, you will have a signal sampled at 512 Hz.

You might notice that this approach yields some aliasing, as the transition band of the stage-1 filter is allowed to extend beyond the new Nyquist frequency of 256 Hz. However, this isn't a problem, because none of the aliasing occurs within the desired passband of the overall cascade. You're allowing some energy to alias through into what will become the stopband of stage 2, where it will be eliminated. Stretching out the transition band of the stage 1 filter allows you to save some computations, because the wider transition will require a lower filter order. Since stage 1 operates at the highest sample rate, this can be a significant benefit.

• Stage 2: Design a filter with a passband edge at 30 Hz and a stopband edge of 32 Hz. Decimate the output of the filter by 8. Thus, at the output of this filter, you will have a signal sampled at 64 Hz with a 30 Hz passband.

While this is still quite a sharp transition band, it should be easier to design because the transition band width is a factor of 8 larger when expressed as a ratio of the filter's sample rate. In addition, the work required to apply the stage-2 filter is reduced further because it operates at the lower 512 Hz rate instead of 4096 Hz.

Using MATLAB's fdatool, the above specifications yield the following filters:

• Stage 1: 29th-order FIR, 0.1 dB passband ripple, 80 dB stopband attenuation

• Stage 2: 852nd-order FIR, 0.1 dB passband ripple, 80 dB stopband attenuation

I just used the default attenuation settings for illustration. You'll notice that with this setup, the second-stage filter is still quite complex. While I've used filters of this length before, it's likely that you might want to break the problem down even further to avoid such long filters. To do so, you would add more stages of decimation. For instance, you might try three stages of decimation by 4, or 6 stages of decimation by 2. The best way forward is dictated by your system's constraints, but you should see the idea of the approach.

• Thank you very much for your reply. Using multiple filter stages didn't occur to me. I'll check how many stages I should use given computational constraints. Your explanation is very helpful, thanks again! – Derk Apr 21 '13 at 16:08
• +1. I would probably do it in 3 stages myself. Decimate by 8, decimate by 4, decimate by 2. – Jim Clay Apr 22 '13 at 1:19

As written this is pretty tough constraint to meet. You have two basic choices:

1. Linear phase filter: preserves the original phase but requires a large bulk delay and smears the time domain both forward and backward in time. Does a very poor job at preserving transients in the time domain
2. Minimum phase filter: does not require a bulk delay and smears only forward in time (causality is mostly preserved). Does a better job at preserving transients but the phase response is severely impacted. In your example a 12th order elliptic filter with 0.1dB pass band ripple would do the job.

In either cases there will be substantial time domain ringing that will drag out for multiple seconds. The steeper the frequency transition, the more time domain ringing you get regardless of filter type or structure.

It would recommend re-evaluating the application constraints again to check whether you really need a filter that steep. How "flat" does it really need to be? How much amplitude and phase ripple can the application tolerate? What's spectrum of the input signal like? Do you really have full scale spectral components that are in the aliasing range or is the signal already attenuated at aliasing frequencies?

• The application is for monitoring Schumann resonances in the ELF-band of the spectrum. I'd like to build a low power system with a small solar panel and battery for use far away from civilization to prevent interference from man-made sources. It should collect data unattended for a long period of time. Analyzing the collected data, it should be possible to detect small changes in frequency and amplitude of the resonances over time. This makes me rethink the specifications, perhaps it can be relaxed. Thank you for your reply. – Derk Apr 21 '13 at 19:35