Welcome Notice

Register Log in

One cycle 50/60Hz RMS Calculation...

S

server

Guest
On Sat, 17 Oct 2020 07:28:55 -0700 (PDT), Gold_Spark
<bluelectronx@gmail.com> wrote:

On Thursday, October 15, 2020 at 11:01:02 PM UTC-4, Gold_Spark wrote:
My question is based on this paper: http://www.eletrica.ufpr.br/edu/artigos/CIL22-012_final_gerson.pdf

They claim to calculate RMS with non-integer number of samples to improve accuracy over half cycle or one cycle RMS.

In my case for one cycle I can\'t have an integer N that matches both 50 and 60 Hz and possible fluctuations. In the microcontroller, the plan I have is to set an ADC triggered by a timer for a fixed sampling frequency, say 6 kHz.. I can also use DMA or double buffer approach if needed.

What do you think of the approach of the paper? I\'m open to other suggestions regarding the proper way to sample the signal for a one cycle RMS. I know that if I increase the number of cycles I can find an integer sample time period that matches both 50/60 Hz, but the point is that I need RMS per one cycle. Does not need to be so precise, even integer RMS is Ok.

Some caveat:
1. In the hardware, the signal is shifted with a DC value to match the ADC positive values. For example, my ADC reads 0-3.3V, then the signal swings around 3.3/2. This DC value is pretty stable so averaging it and subtract from the reading works.

I didn\'t provide much details, but basically my application is to detect leakage currents (earth) in the order of mAs, that\'s why I wanted fast detection. I\'ve seen some methods that use peak detection. It is right that peak detection offers the quickest response, but not necessarily a reliable one. I don\'t know how distorted my current waveforms are, but I certainly would not want to assume they are perfect sine waves in which peak values may not be easy to find. Maybe an average point by point could help get better peak approximation. At the end, that is why I thought of finding RMS per cycle since it could yield a more reliable result.
Why not sample at your 6 KHz and software lowpass filter? Output a new
smoothed value every ADC sample, 6K times a second. That may well be
more representative of whatever process you have that matters. It\'s
easy, too.



--

John Larkin Highland Technology, Inc

Science teaches us to doubt.

Claude Bernard
 
M

Martin Brown

Guest
On 17/10/2020 15:28, Gold_Spark wrote:
On Thursday, October 15, 2020 at 11:01:02 PM UTC-4, Gold_Spark
wrote:
My question is based on this paper:
http://www.eletrica.ufpr.br/edu/artigos/CIL22-012_final_gerson.pdf

They claim to calculate RMS with non-integer number of samples to
improve accuracy over half cycle or one cycle RMS.

In my case for one cycle I can\'t have an integer N that matches
both 50 and 60 Hz and possible fluctuations. In the
microcontroller, the plan I have is to set an ADC triggered by a
timer for a fixed sampling frequency, say 6 kHz.. I can also use
DMA or double buffer approach if needed.

What do you think of the approach of the paper? I\'m open to other
suggestions regarding the proper way to sample the signal for a one
cycle RMS. I know that if I increase the number of cycles I can
find an integer sample time period that matches both 50/60 Hz, but
the point is that I need RMS per one cycle. Does not need to be so
precise, even integer RMS is Ok.

Some caveat: 1. In the hardware, the signal is shifted with a DC
value to match the ADC positive values. For example, my ADC reads
0-3.3V, then the signal swings around 3.3/2. This DC value is
pretty stable so averaging it and subtract from the reading works.

I didn\'t provide much details, but basically my application is to
detect leakage currents (earth) in the order of mAs, that\'s why I
wanted fast detection. I\'ve seen some methods that use peak
detection. It is right that peak detection offers the quickest
response, but not necessarily a reliable one. I don\'t know how
distorted my current waveforms are, but I certainly would not want to
assume they are perfect sine waves in which peak values may not be
easy to find. Maybe an average point by point could help get better
peak approximation. At the end, that is why I thought of finding RMS
per cycle since it could yield a more reliable result.
Low pass filtering on the most recent N values and trip if above some
threshold might be one easy way to go. It seems you don\'t actually care
about RMS values so much as a trigger condition that is not susceptible
to noise spikes. A humble boxcar average over a cycle would probably do
and you can implement that as a cyclic buffer and an accumulator.

BTW if this is for something safety critical beware of the possibility
that the code gets itself into a non-executing state due to a mains
glitch or other electrical interference. I once saw a control system
where the only process left working was the one that pumped the dead
man\'s handle. It didn\'t realise it needed to reboot so it didn\'t :(

In another example arc welding work in a neighbouring bay caused a CNC
machine to ram a tool right through the job, bending the lathe bed.

--
Regards,
Martin Brown
 
R

Ricketty C

Guest
On Saturday, October 17, 2020 at 12:02:13 PM UTC-4, Martin Brown wrote:
BTW if this is for something safety critical beware of the possibility
that the code gets itself into a non-executing state due to a mains
glitch or other electrical interference. I once saw a control system
where the only process left working was the one that pumped the dead
man\'s handle. It didn\'t realise it needed to reboot so it didn\'t :(
Watchdogs are frequently misunderstood and done poorly. Many years ago I worked on a project where we discovered a great many ways to do it wrong. On another project the software team made the watchdog pump an interrupt based routine that could continue to function when everything else was dead. That didn\'t survive design review.


In another example arc welding work in a neighbouring bay caused a CNC
machine to ram a tool right through the job, bending the lathe bed.
That\'s just poor design on many levels. The first level is a PSU that didn\'t detect the poor incoming power and shut everything down. Another big problem was designing a tool in a way that did not protect the tool from itself.

Mains \"glitches\" should never cause a problem. Either detect the \"glitch\" and shut down the process safely, or better... build the PSU so \"glitches\" don\'t disrupt the power, in proportion to the importance of a problem. In other words, don\'t design a CNC tool with the same methodology you would apply to a home router.

--

Rick C.

+ Get 1,000 miles of free Supercharging
+ Tesla referral code - https://ts.la/richard11209
 
B

boB

Guest
On Thu, 15 Oct 2020 20:00:56 -0700 (PDT), Gold_Spark
<bluelectronx@gmail.com> wrote:

My question is based on this paper: http://www.eletrica.ufpr.br/edu/artigos/CIL22-012_final_gerson.pdf

They claim to calculate RMS with non-integer number of samples to improve accuracy over half cycle or one cycle RMS.

In my case for one cycle I can\'t have an integer N that matches both 50 and 60 Hz and possible fluctuations. In the microcontroller, the plan I have is to set an ADC triggered by a timer for a fixed sampling frequency, say 6 kHz.. I can also use DMA or double buffer approach if needed.

What do you think of the approach of the paper? I\'m open to other suggestions regarding the proper way to sample the signal for a one cycle RMS. I know that if I increase the number of cycles I can find an integer sample time period that matches both 50/60 Hz, but the point is that I need RMS per one cycle. Does not need to be so precise, even integer RMS is Ok.

Some caveat:
1. In the hardware, the signal is shifted with a DC value to match the ADC positive values. For example, my ADC reads 0-3.3V, then the signal swings around 3.3/2. This DC value is pretty stable so averaging it and subtract from the reading works.
So, which one AC cycle do you want to measure ?

All of them ? Or just one particular cycle ?

Should be simple as measuring any AC cycle as long as you start and
stop from:to the same point in the cycle.

Square samples, average, take the square root.
 
Toggle Sidebar

Welcome to EDABoard.com

Sponsor

Top