i am using pic184520 ic it has 10bit adc. In my project i am measuring line voltage using step down transformer, the input of the transformer is 230v 50hz ac and output is 5v ac, my doubt is can i give the ac 5v directly to adc pin and ground are i must use any diode. my next doubt is how to calculate rms of sine wave i am using pic ccs compiler, please send any working c code for conversion,
my adc is 10 bit
kindly help thank you
If you connect one leg of the transformer secondary to ground, then you can apply the other leg to the ADC input; BUT you will need to drop the voltage, since the peak voltage will be over 14 volts (5 volts RMS is about 14 volts peak-to-peak).
You can determine what the peak value of the signal is, and then the RMS value is simply Vpeak/(2*sqrt(2)). How fast you sample will determine how accurate your measurement is.
I doubt you need true RMS for each cycle, so you can rectify with a ratio and precision peak and hold detector or simply an average full wave voltage going into an RC filter. Then conversion of either method has tradeoffs to noise or speed of response. You can scale the output with a resistor ratio or Op Amp rectifier to fit within your ADC range.
peak to rms: multiply peak by .707
peak to average: multiply peak by .637
rms to peak: multiply rms by 1.414
rms to average: multiply rms by .9
average to rms: multiply avg by 1.111
average to peak: multiply avg by 1.567