6 years, 7 months ago.

Analog In - Is it consistent or statistic?

Hi, I'm using an AnalogIn pin to get the voltage of a battery. But, the analog input has many interferences and I'm forced then to sample many times and to make an average.

Is it normal? Shall the analog input be consistent and robust, or that I really have to use statistic sampling?

Thanks!

1 Answer

6 years, 7 months ago.

I guess it depends on how much noise you are seeing. Generally there is always some amount of noise on AD reads. Various techniques can be used to minimize the noise depending on how important accuracy is for your application.

I would normally use software filtering on analog values to ensure a single bad read doesn't impact my program. A pretty good strategy is to do 5 reads, discard highest and lowest and average the middle three. But sometimes if you need to act quickly you will not have to to do any filtering and will have to use the raw value.

Most devboards use Vdd as the AD reference voltage (probably with some filtering). Any noise on the 3.3V rail then can affect the AD result. For more accurate results, connect a dedicated voltage reference to the ADC Vref pin so you have a nice stable reference point. And then of course you can use hardware filtering to smooth out the actual signal you're trying to measure. The hardware filters will have a time constant associated with them. You would usually try to plan your hardware filter so it is smoothing the signal in between AD reads you are doing in software. So in softaware if you will sample once per second, in hardware you would LPF the signal so it represents an average of about 1 second.

Graham

Accepted Answer

Thank you very much for the detailed answer!

posted by Hillel Vidal 21 Oct 2017