Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] What is the advantages of Squared Sum over Simple Sum?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
embeddedlaboratory.blogspot.in
Activity points
10,591
Hello!!
I am reading a code for measuring ADC data, and found something strange.

Normally we take multiple readings and then take average of all these readings, but in this code, they have taken squared sums.

The Code is something like this:-


Code C - [expand]
1
2
3
4
5
6
for(i=0;i<LENGTH;i++)
{
    value += ADC_Data[i]*ADC_Data[i];
}
value = ADC_Data/LENGTH;
value = sqrt(value);



where LENGTH is length of the ADC_Data array.

I take dummy values and check it in excel to verify the code, the results are almost identical.
But i want to know why this method, why not normal average method is used.
 

Out of context it is difficult to tell but the most likely reason is the ADC data holds negative values. Squaring them then taking the root ensures all the values are positive.

Brian.
 
Its not only for negative values, but main reason is finding the power.

for example if you have 1 V on a 1 ohm resistor you will have 1 W power, if you have 10v on the same resistor you will have 100W power dissipation so plain average will not help you in power calculations.

example if you are having 1V for half the period and 10 V for remaining period your
average voltage is 5.5V
Rms voltage is √( (100 + 1) / 2) = 7.106V

IF you calculate the power with RMS value you will get the right power value.
 
Thanks for your replies.

Actually, this is used to calculate RMS volatge of AC Signal applied.

AC signal is applied to a Fully Differential Isolated Amplifier IC such as AMC1200, and the output is taken on ADC pin of micro-controller.

But there are no negartive values in ADC measurement.
Can you please elaborate, i think i am quite close.
 

It gives you output in two offset values you can take any input if you subtract the offset you will get the positive and negative values.

for example Capture.PNG

if you have Vref of 3.3 and giving the input signal if you subtract the binary value for 1.29V you will get the array of both ac and dc values. Its all depend on what mechanism actually included in your code and hardware.
 
Hi,
Actually, this is used to calculate RMS volatge of AC Signal applied.

Can you please elaborate, i think i am quite close.

RMS = root mean SQUARE.

It's already in the name that you need to calculate the square...


Klaus
 

It gives you output in two offset values you can take any input if you subtract the offset you will get the positive and negative values.

for example View attachment 110284

if you have Vref of 3.3 and giving the input signal if you subtract the binary value for 1.29V you will get the array of both ac and dc values. Its all depend on what mechanism actually included in your code and hardware.

Vref is 5V.

Can you please provide me an algorithm to measure the AC voltage.


Do we have to measure the ADC Data periodically and then store it in a buffer.
It means there will be a limitation on the lowest and highest frequency measurement.

Please provide me an algorithm, i am confused.
Thanks in Advance.
 

Hi,

Did you read on how to calculate RMS?

Then the algorithm is clear and also how to sample the data.
If you need real time values then storing ADC values in memory may be not good. If you need the value once a second it may be a good solution. It depends on your application.

What especially you don't understand?

Klaus
 
It is depend on your application, there are is alot can be performed by reading AC values, from RMS to FFT.

And also it is depend on your CPU availability ADC resolution ADC frequency (conversion time), the accuracy you need. the scaling you did in the input side.
 
Hi,

Did you read on how to calculate RMS?

Then the algorithm is clear and also how to sample the data.
If you need real time values then storing ADC values in memory may be not good. If you need the value once a second it may be a good solution. It depends on your application.

What especially you don't understand?

Klaus

Yeah I read how to calculate RMS and now it is clear that why Square Values are taken and then divided by number of sample and then square root is taken.

- - - Updated - - -

It is depend on your application, there are is alot can be performed by reading AC values, from RMS to FFT.

And also it is depend on your CPU availability ADC resolution ADC frequency (conversion time), the accuracy you need. the scaling you did in the input side.

I am using arduino mega, whose adc is 10-bit.
Thanks for your help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top