# Averaging voltage

#### gary1wang

Joined Sep 18, 2008
23
Hi guys

I have 200 samples on one voltage. And because there is noise on the voltage and and want to reduce the noise affect on measured voltage and what i did is

add 200 samples together and t then divide 200

Voltage average= (sample1+ sample2+ .......sample200)/200

where sample1 is first sample voltage and sample200 is second sample of voltage. But the result has a some varations. because this applicaiton is very sensitive to small voltage.

I thought another way to calculate the average, use Quadratic mean. or harmonic mean, which is better to get average value and it will give better performance.

Are there any better ways to do it?

I am not good at math, Please give me some idea

#### hgmjr

Joined Jan 28, 2005
9,027
What is the nature of the signal you are measuring?

hgmjr

#### gary1wang

Joined Sep 18, 2008
23
It is DAC output and it contain one voltage level. There is some noise in the signal. say 1.8223 volts, and samples are around between 1.8355 to 1.8194.

#### hgmjr

Joined Jan 28, 2005
9,027
What is the resolution of your DAC?

Maybe what you are seeing is the plus or minus bit uncertainty of your DAC.

hgmjr

#### gary1wang

Joined Sep 18, 2008
23
the DAC voltage range is 0 to 2.6 volts and it has 256 steps, I choose 208. it is in the range. If it is uncertainty bit. How can i deal with it?

#### panic mode

Joined Oct 10, 2011
2,170
if that 2.6V is full scale of the ADC then

(2.6-0.0)/256=0.01015625 V

this is resolution of one bit (~ 10mV or 0.01V).
then 208 counts correspond to
208*0.01015625=2.1125V

but
179*0.01015625=1.81796875V
180*0.01015625=1.828125V
181*0.01015625=1.83828125V
(note ~10mV steps)

if you are trying to measure smaller changes, use higher resolution converter.

for example
12-bit will get you ~0.625mV (2^12=4096; 2.6/4096=0.0625mV)

and
16-bit means 2^16=65536; 2.6/65536=0.03967mV etc.

if you have noise, try to eliminate it in hardware (shielding and filtering for example). the next step is filtering in software...

#### 1chance

Joined Nov 26, 2011
46
Hi guys

I have 200 samples on one voltage. And because there is noise on the voltage and and want to reduce the noise affect on measured voltage and what i did is

add 200 samples together and t then divide 200

Voltage average= (sample1+ sample2+ .......sample200)/200

where sample1 is first sample voltage and sample200 is second sample of voltage. But the result has a some varations. because this applicaiton is very sensitive to small voltage.

I thought another way to calculate the average, use Quadratic mean. or harmonic mean, which is better to get average value and it will give better performance.

Are there any better ways to do it?

I am not good at math, Please give me some idea
You could also do a "trimmed" mean and discard x% (usually 10%) of the data from the top and the bottom (The data must be listed in order from smallest value to largest value in order to do this). This would focus on the 80% of data most closely related to the center (median). This is useful, especially if there is the possibibility of human error in some of the measurements.

#### Eskelvar

Joined Mar 4, 2012
4
Just curious, would you be able to filter out any of the noise you have without loss?

Other then that, it would seem you would need to go with what you have as far as the math is concerned. Perhaps putting it into a spreadsheet and doing some averaging with formulas over the whole span of the measurements and time.

Looking at a graph of it may also give you some insight to any abnormalities. A mathematician friend of mine says to take out the top 10% and bottom 10% before finding your average, but I'm not sure of this either. due to the nature of what you are measuring.