To practice DSP algorithm on MSP430 microcontroller, i am working on a project “Mains Monitor” which is basically a spectrum analyser which will monitor AC mains voltage using Fast Fourier Transform (FFT) and show spectrum frequency domain on a graphical LCD , the spectrum can be used to view if any harmonics present in the mains voltage which will ultimately determines the quality of the supply.

measuring True RMS voltage and frequency is part of that project, alongside of spectrum the LCD screen will display True RMS Voltage and frequency of AC mains line. most of the normal AC mains voltage meter measure average/peak voltage and then adjust the voltage a little considering sine wave input waveform. average measurement technique works well till input is pure sine wave but as soon as you input other waveform like square wave from backup UPS, normal meter will not read them correctly. so if you want real effective voltage level you have to calculate true RMS voltage. but calculating true RMS is not very easy it need a decent amount of calculation to be performed. small microcontroller are not generally meant for these calculation but MSP430 is mixed signal microcontroller , it has few very advanced peripherals to support some light weight DSP operations. we will see in a minute how to calculate True RMS of a signal and what are the challenges doing this on a small microcontroller.

this project is directly involved with high voltage AC which may cause sever damage. proceed with caution.

i will not be responsible for any risk involved, you are on you own.

**True RMS**

** **The term “RMS” stands for “Root-Mean-Squared”. Most books define this as the “amount of AC power that produces the same heating effect as an equivalent DC power”, or something similar along these lines, but an RMS value is more than just that. The RMS value is the square root of the mean (average) value of the squared function of the instantaneous values. The symbols used for defining an RMS value are VRMS or IRMS.

In practical you have to take few samples of the input wave at a fixed interval ,square each sample result, add all of the result, calculate mean of the results and then finally to get final RMS value calculate square root of the mean.

lets see graphically how to calculate true RMS.

in the software rms calculation is done exactly same way ,

**The Hardware **

hardware consist of few basic components , at the core we have MSP430FR5969 microcontroller which is actually mounted on TI Launchpad board and i have built a booster pack pcb around this board which consist all necessary components to interface this board to mains AC.

as shown in the image above at the input side we have isolation / step down transformer which will step down mains AC to around 20 V peak to peak (at 300V main input) around 7 Vrms . then we have simple potentiometer to further attenuate 20 V peak to peak to around 2.5 V peak to peak ( microcontroller ADC reference voltage is 2.5V ). after attenuation we have standard AC coupled sallen key low pass filter cutoff frequency at 800Hz , output of the filter goes directly to microcontroller ADC input pin for voltage measurement and internal comparator input pin for frequency measurement ,ADC trigger(triggering at same point every time helps to get more stable results).

the isolation , attenuation , and filtering happen on the the board shown in the image above, display is also mounted on same board. display is quite common nokia 5510 / 3315 display , i have having this display from very old project and it is also available in on ebay and other small hobby shops fairly low price. it give resolution of around 84*48 pixels which is okey for our current purposes.

**The Software **

as always all the magic happens in the software. the the software is written in with code composer studio Version: 6.0.1.00040 free edition.

all the source files are available on github. or you can download from this link (may not be latest) .

www.github.com/circuitvalley

if you have any questions please ask

Read more Here