# How to filter uniform noise in a microcontroller?

By uniform noise I mean a band of a fixed width, no spikes, etc. This has to be one of the simplest examples. I'm looking for the appropriate theoretical approach as much as something relatively computationally efficient.

The true signal changes slowly (slower than 1Hz, a battery voltage). The noise band remains fairly constant (~50mV noise on a ~4V signal).

Initial ideas:

I'd love to learn more about what I think is a geometric average. I'm not sure I can quantify the time-to-settle/time-to-seed for these options either.

If there are more standard approaches, I'd love to learn about those as well.

• I think you meant arithmetic average: $y_m=\frac{y_1+y_2}{2}$, because geometric is defined as: $y_m=\sqrt[n]{y_1y_2 \cdots y_n} \rightarrow \sqrt{y_1 y_2}$. – jojek Jun 12 '14 at 8:14
• A moving average is a type of low-pass filter. Most practical low-pass filters can be thought of as moving average with the samples closest to the latest sample weighted more than those further back in time. In a simple moving average they are weighted the same. Hope this concept helps. – geometrikal Jun 12 '14 at 13:21
• What microcontroller are you implementing it on, what sample rate, how much memory can you spare? – geometrikal Jun 12 '14 at 13:21
• Can you put some sample data up, showing your noisy signal? – Tarin Ziyaee Jun 12 '14 at 16:13

## 1 Answer

1. You need to check the noise bandwidth using an oscilloscope. By saying noise I mean the hardware noises before digitalization by ADC.
2. If the noises have high frequency component, remove it by analog filters. High frequency is defined as frequency higher than 1/2 of the sampling rate. And in practice, usually a sampling rate of 8-10 times of the pass band of the analog low pass filter is used. You may try simple RC filters.
3. Use FIR in a MCU to manipulate your data. Depends on the speed requirement, you can choose number of taps to use and etc. You should be able to find libraries provided by your chip manufacture, since FIR is very common in use.

Hope it helps!

• It might be worth noting that the cut-off frequency of the FIR filter should be (1 Hz)/sampling frequency – Deve Jun 13 '14 at 11:24