# FIR-Decimation and Low-pass filter (taps vs number of input points vs number of decimation stages)

I am new to digital filters and trying to understand parameters behind them.

Scenario

I am trying to get DC value from signals sampled at 100kHz sampling rate. such high frequency is used due to system hardware limitations. A very sharp low-pass filter is to be used with cut-off frequency at 1Hz. The plan is to capture 10000 ponints first and then FIR-Decimate the income signal with several stages:

1. stage 1: decimation factor 10, FIR cutoff frequency 1/20 (128 taps), 100kHz->10kHz
• income 10000 points, result 1000 points
2. stage 2: decimation factor 10, FIR cutoff frequency 1/20 (128 taps), 10kHz->1kHz
• income 1000 points, result 100 points
3. stage 3: decimation factor 10, FIR cutoff frequency 1/20 (128 taps), 1kHz->100Hz
• income 100 points, result 10 points
4. stage 4: decimation factor 10, FIR cutoff frequency 1/20 (128 taps), 100Hz->10Hz
• income 10 points, result 1 point
5. Then a FIR with cut off frequency will be implemented with cutoff frequency 1/10.

Questions

1. In the FIR decimation, the FIR cut-off frequency is always stricter than the decimation factor to avoid aliasing, is this design necessary?
2. What are the tradeoffs of choosing number of decimation stages and decimation factors?
3. At stage 4, there are only 10 income points. However, FIR has 64 taps... Would the one point result still be valid?

1. You should look at the final decimation factor when designing the earlier filters. Hence, for the first stage you can have a cutoff frequency of 1Hz and stopband frequency of 100000/10 - 1 = 9999 Hz, since this is what is folded/aliased into your band of interest. You would actually prefer to have several stopbands 9999-10001, 19999-20001, 29999-30001, 39999-40001, and 49999-50000 Hz /you'll have to normalize yourself...). This would require a rather low order filters, which is nice since it runs at the highest sample rate. For the next stage, 999-1001, 1999-2001, and so on. Higher order (about ten times), but ten times lower sample rate. And so on.

2. Roughly more stages => fewer multiplications per input sample (given that you do a proper design as above). This holds up to some limit which can be quite straightforwardly determined by searching some combinations.

3. After the first stage you will have $1000 + 2 \times 127$ samples (with 128 taps) and so on.

If you want to get the DC value you can just average the sequence. This is, apart from the possibly obvious observation that the DC level should be the average "offset" of the otherwise AC signal, also what the DC component of the DFT evaluates to.

• Thanks for your reply. However there are two points that are not very clear to me. 1. "You would actually prefer to have several stopbands 9999-10001, 19999-20001, 29999-30001, 39999-40001, and 49999-50000 Hz /you'll have to normalize yourself...)." Do you mean for every decimation stage, the normalized cut-off frequency should be the same? 2. Could you please illustrate more on the third point? It does not seem to answer my question.. – richieqianle Jun 18 '14 at 2:14
• I have not compared averaging or DC of DFT with FIR. I guess FIR is more efficient comparing with averaging, is it? – richieqianle Jun 18 '14 at 2:16
• Sorry for long latency. First comment: Using the same cut-off for every stage means that you spend computational effort keeping data in the early stages which will be removed at later stages. Second comment: Averaging = 9999 additions and one multiplication (with 0.0001) for the whole block. FIR = much much more (128*10000 mult and 127*10000 add for the first stage). You do not have to compute the whole DFT, just the DC bin (which is the same as averaging). – Oscar Jun 23 '14 at 14:06
• Thanks for your reply. But could I get real time values by averaging? Could averaging have better accuracy than FIR? – richieqianle Jun 23 '14 at 14:31
• Well, averaging a length N sequence can in fact be seen as an FIR filter followed by a decimation with N. For this particular FIR filter, the zeros are placed exactly at the frequencies that alias to DC, so it is pretty optimal in that respect. If you want to determine the DC value of a signal of length N, you will obtain the "correct" result by taking the average. This can be seen both from the FIR+decimation as well as the DFT point of view, both resulting in averaging. ("Correct" in the sense that it will be for that sequence and to me it seems like you have continuous signal.) – Oscar Jun 24 '14 at 12:51

With regard to your desire for a real-time output, getting an updated result with every new sample, you may want to consider a simple single-pole filter: y(n) = alpha*x(n) + (1-alpha)*y(n-1), where alpha < 1. This actually has an approximate moving-average equivalent with alpha = (N-1)/(N+1), where N is the effective moving-average length. As long as your signal is stationary, this is a reasonable approach; however, if you expect any transients (spikes) in your signal, the filter described above will get corrupted for some number of samples.