How to sample AC signal for RMS level calculation - diyAudio
Go Back   Home > Forums > Design & Build > Software Tools
Home Forums Rules Articles diyAudio Store Gallery Wiki Blogs Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 28th March 2016, 07:25 PM   #1
Wiggle8 is offline Wiggle8  Canada
diyAudio Member
 
Join Date: Jan 2016
Location: Halifax, NS
Default How to sample AC signal for RMS level calculation

I am trying to add an Arduino microprocessor to a power amplifier to display internal temperature and power of output at the speaker terminals on an LCD display.

However, I am having some trouble determining the best way to measure the voltage and current due to them being AC signals. Here is my best guess at a method, let me know if it sounds reasonable:

Use a biasing circuit to make sure all AC signals are translated into a 0-5V measurement range for all operating conditions. Was going to use something such as this: https://openenergymonitor.org/emon/b...sors-interface

I would then convert this measurement to a value by saying:
VALUE=abs((INPUT-2.5))*scalingfactor
(where scalingfactor is the correction factor to convert measurement voltage back to "real" V or A)

Calculating an RMS value for my power calculation is where I am struggling. Is it reasonable to simply collect a good amount of data points (say 20) over a period of 0.25 seconds, store them in an array, square each value and then divide out the number of samples and take the square root?

RMS=sqrt((sum(VALUE[i]*2, i=0..20))/i)
(where i is the number of samples)

Let me know if I am totally confused or on the right track
  Reply With Quote
Old 29th March 2016, 08:53 AM   #2
deanoUK is offline deanoUK  United Kingdom
diyAudio Member
 
Join Date: Oct 2008
Location: Birmingham UK
Rectify the signal to get DC.
  Reply With Quote
Old 29th March 2016, 09:08 AM   #3
Ron E is offline Ron E  United States
diyAudio Member
 
Ron E's Avatar
 
Join Date: Jun 2002
Location: USA, MN
Haven't used arduino for signal processing. I think arduino is pretty slow, maybe 5-10kS/s, you would want at least 40kS/s or you will only read power data below half the sampling rate and could have aliasing issues.

Google for 'RMS to DC converter' - adding arduino to that search reveals quite a few results, but I haven't read any
__________________
Our species needs, and deserves, a citizenry with minds wide awake and a basic understanding of how the world works. --Carl Sagan
Armaments, universal debt, and planned obsolescence--those are the three pillars of Western prosperity. Aldous Huxley
  Reply With Quote
Old 29th March 2016, 09:46 AM   #4
diyAudio Member
 
jan.didden's Avatar
 
Join Date: May 2002
Location: The great city of Turnhout, BE
Blog Entries: 7
Quote:
Originally Posted by Wiggle8 View Post
I am trying to add an Arduino microprocessor to a power amplifier to display internal temperature and power of output at the speaker terminals on an LCD display.

However, I am having some trouble determining the best way to measure the voltage and current due to them being AC signals. Here is my best guess at a method, let me know if it sounds reasonable:

Use a biasing circuit to make sure all AC signals are translated into a 0-5V measurement range for all operating conditions. Was going to use something such as this: https://openenergymonitor.org/emon/b...sors-interface

I would then convert this measurement to a value by saying:
VALUE=abs((INPUT-2.5))*scalingfactor
(where scalingfactor is the correction factor to convert measurement voltage back to "real" V or A)

Calculating an RMS value for my power calculation is where I am struggling. Is it reasonable to simply collect a good amount of data points (say 20) over a period of 0.25 seconds, store them in an array, square each value and then divide out the number of samples and take the square root?

RMS=sqrt((sum(VALUE[i]*2, i=0..20))/i)
(where i is the number of samples)

Let me know if I am totally confused or on the right track
I think you would integrated each area under two consecutive samples, no?

BTW I have a similar project where I use an AD536 AC to RMS converter feeding into a PIC ADC pin. Works like a charm.

Jan
__________________
Music is dither to the brain; lets me think below the usual chaos - me
Linear Audio Vol 12 is out! Check out my Autoranger and SilentSwitcher on Kickstarter!

Last edited by jan.didden; 29th March 2016 at 09:58 AM.
  Reply With Quote
Old 29th March 2016, 01:06 PM   #5
Wiggle8 is offline Wiggle8  Canada
diyAudio Member
 
Join Date: Jan 2016
Location: Halifax, NS
Quote:
Originally Posted by deanoUK View Post
Rectify the signal to get DC.
Will I not lose a big chunk of my signal due to the forward voltage on the rectifiers?
  Reply With Quote
Old 29th March 2016, 01:07 PM   #6
Wiggle8 is offline Wiggle8  Canada
diyAudio Member
 
Join Date: Jan 2016
Location: Halifax, NS
Quote:
Originally Posted by Ron E View Post
Haven't used arduino for signal processing. I think arduino is pretty slow, maybe 5-10kS/s, you would want at least 40kS/s or you will only read power data below half the sampling rate and could have aliasing issues.

Google for 'RMS to DC converter' - adding arduino to that search reveals quite a few results, but I haven't read any
Thanks, yep I am aware of the aliasing issues. But I am not looking to adequately sample the signal, only average out the amplitude of the signal for a rough calculation of output power.
  Reply With Quote
Old 29th March 2016, 01:23 PM   #7
Wiggle8 is offline Wiggle8  Canada
diyAudio Member
 
Join Date: Jan 2016
Location: Halifax, NS
Quote:
Originally Posted by jan.didden View Post
I think you would integrated each area under two consecutive samples, no?

BTW I have a similar project where I use an AD536 AC to RMS converter feeding into a PIC ADC pin. Works like a charm.

Jan
That AD536 looks ideal, sadly at the cost though I'd be spending over $100 for them though for the number of inputs I was hoping to use.
  Reply With Quote
Old 29th March 2016, 01:31 PM   #8
diyAudio Member
 
jan.didden's Avatar
 
Join Date: May 2002
Location: The great city of Turnhout, BE
Blog Entries: 7
Quote:
Originally Posted by Wiggle8 View Post
That AD536 looks ideal, sadly at the cost though I'd be spending over $100 for them though for the number of inputs I was hoping to use.
You could mux the input.
__________________
Music is dither to the brain; lets me think below the usual chaos - me
Linear Audio Vol 12 is out! Check out my Autoranger and SilentSwitcher on Kickstarter!
  Reply With Quote
Old 29th March 2016, 03:57 PM   #9
Ron E is offline Ron E  United States
diyAudio Member
 
Ron E's Avatar
 
Join Date: Jun 2002
Location: USA, MN
https://en.wikipedia.org/wiki/True_R...nic_converters

There is a way to make a "precision diode" (no forward voltage) using an op amp and a diode, and you can buffer the circuit to keep it from loading the source.

http://forum.allaboutcircuits.com/th...ctifier.64943/
__________________
Our species needs, and deserves, a citizenry with minds wide awake and a basic understanding of how the world works. --Carl Sagan
Armaments, universal debt, and planned obsolescence--those are the three pillars of Western prosperity. Aldous Huxley

Last edited by Ron E; 29th March 2016 at 04:11 PM.
  Reply With Quote
Old 29th March 2016, 04:31 PM   #10
cbdb is offline cbdb  Canada
diyAudio Member
 
Join Date: Oct 2008
Location: Vancouver
Find an opamp circuit book or even at the end of some opamp data sheets and you will find a Rams detector built with opamps. Or Google opamp Rams detector.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chip Amplifier input signal calculation tahir4awan Chip Amps 6 1st March 2015 06:46 AM
signal level sakshi Analog Line Level 2 31st December 2012 12:40 PM
How do I turn an high current signal into a line level signal?? sardonx Tubes / Valves 8 27th August 2005 12:16 PM
how to bring down line level signal to preamplifier level deji Solid State 15 15th April 2004 05:13 PM
Calculation of RMS power output? protos Solid State 47 1st February 2003 09:11 AM


New To Site? Need Help?

All times are GMT. The time now is 05:18 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Copyright 1999-2016 diyAudio

Content Relevant URLs by vBSEO 3.3.2
Wiki