Voltage reading and displaying advice

I have 200 mSec timing available in my code. I need to take a voltage reading and display it on the LCD. I have read that it's a good practice to take multiple readings, average it and then display it. I have multiple options and I would like advice on which option should be used.

  1. Take 20 readings every 200ms, average it (divide by 20) and display on lcd
  2. Take 1 reading every 200ms for 1 sec(5 readings/sec), average it (divide by 5)and display on lcd
  3. Take 20 readings in 200ms, average it. Do it 5 times. Add the readings, divide the total by 5 then display it every 1 second on lcd.

It depends on the noise but since noise is generally random the timing of the 20 reads should not matter.

If the voltage is "rock solid" (no variation/noise) you don't need to take multiple readings.

It is a good idea to hold the display (maybe for more than 200ms) so you can read it and "make sense" of the reading.

you can use leaky integration to average each 200 msec reading against the current average. there will be some delay when there are significant changes

avg += (samp - avg) / N;

red N=4
orange N=8
yellow N=16

1 Like

What is N?

the filter coefficient, very comparable to an RC time constant.

the output will be close to 1 for a step input of 1, after 3 N iterations

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.