How to sample AC signal for RMS level calculation
 User Name Stay logged in? Password
 Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read Search

 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
 28th March 2016, 06:25 PM #1 Wiggle8   diyAudio Member   Join Date: Jan 2016 Location: Halifax, NS 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
 29th March 2016, 07:53 AM #2 deanoUK   diyAudio Member   Join Date: Oct 2008 Location: Birmingham UK Rectify the signal to get DC.
 29th March 2016, 08:08 AM #3 Ron E   diyAudio Member     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
jan.didden
diyAudio Member

Join Date: May 2002
Location: The great city of Turnhout, BE
Quote:
 Originally Posted by Wiggle8 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
__________________
Cable: a potential source of trouble interconnecting two other potential sources of trouble - Erik Margan
Linear Audio pubs and articles . The SilentSwitcher now at diyaudio store SilentSwitcher. Keeping in touch with SY.

Last edited by jan.didden; 29th March 2016 at 08:58 AM.

Wiggle8
diyAudio Member

Join Date: Jan 2016
Location: Halifax, NS
Quote:
 Originally Posted by deanoUK Rectify the signal to get DC.
Will I not lose a big chunk of my signal due to the forward voltage on the rectifiers?

Wiggle8
diyAudio Member

Join Date: Jan 2016
Location: Halifax, NS
Quote:
 Originally Posted by Ron E 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.

Wiggle8
diyAudio Member

Join Date: Jan 2016
Location: Halifax, NS
Quote:
 Originally Posted by jan.didden 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.

jan.didden
diyAudio Member

Join Date: May 2002
Location: The great city of Turnhout, BE
Quote:
 Originally Posted by Wiggle8 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.
__________________
Cable: a potential source of trouble interconnecting two other potential sources of trouble - Erik Margan
Linear Audio pubs and articles . The SilentSwitcher now at diyaudio store SilentSwitcher. Keeping in touch with SY.

 29th March 2016, 02:57 PM #9 Ron E   diyAudio Member     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 03:11 PM.
 29th March 2016, 03:31 PM #10 cbdb   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.

 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 Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Site     Site Announcements     Forum Problems Amplifiers     Solid State     Pass Labs     Tubes / Valves     Chip Amps     Class D     Power Supplies     Headphone Systems Source & Line     Analogue Source     Analog Line Level     Digital Source     Digital Line Level     PC Based Loudspeakers     Multi-Way     Full Range     Subwoofers     Planars & Exotics Live Sound     PA Systems     Instruments and Amps Design & Build     Parts     Equipment & Tools     Construction Tips     Software Tools General Interest     Car Audio     diyAudio.com Articles     Music     Everything Else Member Areas     Introductions     The Lounge     Clubs & Events     In Memoriam The Moving Image Commercial Sector     Swap Meet     Group Buys     The diyAudio Store     Vendor Forums         Vendor's Bazaar         Sonic Craft         Apex Jr         Audio Sector         Acoustic Fun         Chipamp         DIY HiFi Supply         Elekit         Elektor         Mains Cables R Us         Parts Connexion         Planet 10 hifi         Quanghao Audio Design         Siliconray Online Electronics Store         Tubelab     Manufacturers         AKSA         Audio Poutine         Musicaltech         Holton Precision Audio         CSS         Dx Classic Amplifiers         exaDevices         Feastrex         GedLee         Head 'n' HiFi - Walter         Heatsink USA         miniDSP         SITO Audio         Twin Audio         Twisted Pear         Wild Burro Audio

 Similar Threads Thread Thread Starter Forum Replies Last Post tahir4awan Chip Amps 6 1st March 2015 05:46 AM sakshi Analog Line Level 2 31st December 2012 11:40 AM sardonx Tubes / Valves 8 27th August 2005 11:16 AM deji Solid State 15 15th April 2004 04:13 PM protos Solid State 47 1st February 2003 08:11 AM

 New To Site? Need Help?

All times are GMT. The time now is 03:40 AM.