ΣSigmaStudio Ask AI Русский Log in

Sigma DSP get RMS from 1 second

SigmaDSP & SigmaStudio RafaelGerges Oct 16, 2023 00:00 5 replies Original on forum ↗
Subscribe
RafaelGerges Question
Oct 16, 2023 00:00

Hello everyone

I´m currently using ADAU1761 with the Sigma DSP. My question is, what is the best way to get the RMS value from 1 second. I´m currently using "Running Average" with a TC of 120 dB/s, Hold of 1000 ms and Decay of 120 dB/s.

Consulting the sigma studio documentation, it mentions that the "running average" does not calculate the true RMS. Carrying out the electrical tests, when exciting the input with 1 volt peak at 1000 Hz (sine) it responds with 0.707 volts, which would be adequate. Another question would be when using the Hold parameter, setting it to 1000 ms does it calculate the RMS of 1000 ms or does this parameter have another understanding?

Thanks in advance.

Best regards

Audio Signal Processors

Audio Products

software

SigmaDSP Audio Processors

adau1761

ADAU1761 SigmaDSP

Show More

pastedimage1697464298339v2.png
pastedimage1697464298339v2.png
pastedimage1697464308660v3.png
pastedimage1697464308660v3.png
KJBob Reply
Oct 16, 2023 00:00

Hello,

The Hold parameter sets how long the present RMS reading is held before allowing this reading to decay according to Decay setting. This tends to keep recent high reading until that hold time ends or a higher input comes along. This is often used to help solve a problem common to RMS level detectors whether true RMS or otherwise -- the ripple appearing in the level detector's "DC" output reading. When this level is routed to a multiplier or other variable-gain device to achieve (for example) compression, the gain varying within an audio cycle distorts the audio. The Hold prevents this, allowing the DSP to provide virtually distortionless compression. For this use the Hold is usually set to about 25 mS, enough to stretch between two waveform peaks. Of course, you can set it higher for other uses. In your case, it would provide the highest 'RMS' during the previous one-second interval, not a 1-second average.

The block's decay is linear, not exponential. If for example it's used to drive a VU-like display, it may hang near the high end, then drop like a rock. To understand the block's Decay "k/s" setting, see this post (the same decay setting applies to RMS and peak blocks).

Although the RMS block is advertised as "approximate," as you have found it's perfect with sine waves. Depending on your application, it's most likely fine for waveforms normally found in speech and music. High crest-factor waveforms, not so much. Once I built a true RMS converter from basic blocks -- it works great on a ADAU1452 or higher, but not so well on a -1701 or -1761 because their divide blocks have issues with divisors smaller than (1/16).

Best regards,

Bob

RafaelGerges Reply
Oct 17, 2023 00:00

Hi Bob, thanks for your fast reply.

Yes, I understand that the theses decays parameters are for RMS level detects and compressors. In my application I just need to get the RMS value of a 1 second interval. What I did was to configure the hold parameter to 1000 ms and I read it with the parameter readback with a uC every 1 second. I configure a high number for the TC and Decay because I want a fast responce when the signal amplitude chages.

In my application, I'm reading a broadband signal, pink noise. So yes, we have a big crest factor.

So, what you think about this? You think I´m ok doing this?

Thanks in advance.

Best regards.

KJBob Reply
Oct 17, 2023 00:00

Hi Rafael,

If I understand correctly, your micro is taking a snapshot of the DSP's output once per second. Must the RMS value itself be averaged over the entire second? Or can it be averaged over a much smaller interval just before the uC takes it? Of course, if you're averaging over a whole second interval, your RMS reading may take that long to settle to any abrupt change in input level, So, how fast a response do you need? What sort of accuracy are you looking for -- typical VU-meter-like accuracy, or "laboratory" accuracy? And over what range of input levels? The answers to these questions would help us decide what sort of algorithm is best for your application, or even if it's strictly possible on a -1761.

Certainly, with the stock RMS detector, the louder the input pink noise, the higher the output will be over quite a wide range of input levels. This may very well be good enough. Perhaps you only need calibrate the output to make up for the crest factor. Otherwise, I do have a -1761 eval board so I can try out some ideas floating around in my head. For this I really need to know your application better -- everyone on this forum will find this blog post quite useful: Asking for Helping Yourself. And this being a spare time activity for me, it may take a while.

Best regards,

Bob

KJBob Reply
Oct 19, 2023 00:00

Hello once again,

Try the attached project to see how the RMS Average block works with different inputs. Also included is a TRMS converter made from basic blocks, using an arrangement shamelessly lifted from an old Analog Devices AD636 TRMS-DC converter IC. This chip is still available to buy today, because it works so well! How it does it is explained in its data sheet:

As you can see, the computation includes a division. This is a problem with the ADAU1761 because its division algorithm becomes inaccurate for divisors less than (1/16). (See this thread from the top for more info on this).

The test project is here -- RMS.dspproj

You can select external input via the ADC, sine, pulse, and pink inputs. Note the DC block filter on the external input, this is because the Sigma-Delta ADCs often have a small DC offset which ruins level measurements.

The RMS converter uses the implicit calculation from the AD636. The ABCD comparator and multipliers around the Division block extends the Divide block's lower range by another factor of approximately 16 -- so the lowest RMS value the converter will accurately measure is now 0.004 or -48 dB.

On sine waves, the homebrew RMS converter measures about 0.707, which is the mathematical definition. I'm getting 0.636 from the stock converter, I believe that's because it's calibrated much like averaging AC multimeters. Switch to the pulse wave and the results get interesting -- the crest factor of a 10% duty pulse is the square root of 10, or about 3.16. Its RMS value is the square root of (1/10), or 0.316. Here the homebrew converter does quite well, while the stock converter isn't even close. Finally, the two converters read roughly similarly with pink noise, so it may not matter much which you use.

Best regards,

Bob

AD636.jpg
AD636.jpg
RMS-sch.png
RMS-sch.png
RafaelGerges Reply
Oct 24, 2023 00:00

Hello Bob

How are you? Thanks for the very usefull information. I´m on the road right now but by the end of the week I will send some measurements results for discuttion.

Thanks in advance.

Best regards.