Editorís note: I am pleased to have Aubrey Kagan back as a Planet Analog blogger after a brief sabbatical. Aubrey is one of the best tech bloggers I know with a wealth of knowledge on so many interesting Analog topics
Hands up all who remember I did a blog on measuring the RMS (root mean square) value of a signal. Hmmm. Nobody! Well for those of you who donít believe that I wrote one you can find it here: RMS Measurement. In that blog I described different methods that could be used, but I omitted the possible approach where the RMS value is generated using hardware for the mathematics. You could use a Digital Signal Processor (DSP) or an FPGA. I an unfamiliar with both, but as I have become more familiar with the PSoC family the thought niggled at me that perhaps I could create an RMS measurement completely within a PSoC5 device.
For those of you unfamiliar with the PSoC concept from Cypress, the device provides a microcontroller plus hardware blocks to create your own peripheral set. These peripherals are known as ďcomponentsĒ and each component in fact comes with its own data sheet. The concept extends across digital and analog functionality. It may not have the granularity of an FPGA, but the approach can generate some very versatile designs. Full disclosure: I am not, nor have I ever been employed by Cypress or its representatives and distributors, but my employer is a part of the Cypress Design Partner program.
Letís start out with a little background of how I am going to adapt the mathematics to get to a result. The RMS value of a signal is given by the equation:
If we work with discrete measurements and for simplicity letís work with t0=0 we can approximate and sum the measurements as follows:
Where Δt is the sample time and N is the number of samples. Conveniently the Δt cancels out and we are left with
In other words we take N samples, judiciously timed to include a full cycle exactly (technically you can of course go beyond that), sum the squares of the readings and divide by the number of readings- and then take the square root. Thatís pretty much the way it is done in software as well.