# AC voltage measurement using pic microcontroller

1. ## AC voltage measurement using pic microcontroller

Hello,

I am new to microcontrollers and am making a project to read ac mains voltage using pic microcontroller (pic 16f72).
But I am unable to find the circuit to step down the ac voltage to DC and that too to the max. level of 5 volts and what will be the ratio of input ac and the input to the ADC of the pic ,for the calculation in pic code for display purpose.

Can anybody help me with this .....

2. ## AC voltage measurement using pic microcontroller

simply put a diode & a resistor divider but this is not a proper method for good & accurate results use a step down transformer & then precision rectifier. search on net for precision rectifier.

3 members found this post helpful.

3. ## Re: AC voltage measurement using pic microcontroller

here it is

set the values of R1 & R2 by measuring Vx across capacitor

5(R1 + R2) = R2 Vx

0 volts means 0v main supply
5 volts means 220v main supply

2 members found this post helpful.

4. ## AC voltage measurement using pic microcontroller

hameeds01 i think there's slight problem with your circuit....with this method, due to diode, the minimum AC voltage that will be displayed will be somewhere around 30 volts below that till zero it will show "0" because the diode will eat up 0.7v

1 members found this post helpful.

•

5. ## Re: AC voltage measurement using pic microcontroller

Originally Posted by garg29
hameeds01 i think there's slight problem with your circuit....with this method, due to diode, the minimum AC voltage that will be displayed will be somewhere around 30 volts below that till zero it will show "0" because the diode will eat up 0.7v
Transformer secondary voltage = 6v & the peak voltage will be more than that

6. ## Re: AC voltage measurement using pic microcontroller

Thanks hameeds01 for a promt reply
Can you please mention the value of R1 and R2.

1 members found this post helpful.

7. ## Re: AC voltage measurement using pic microcontroller

measure the value of vx via digital volt meter
for eg if vx = 7v
then select
R1 = 1k , R2 = 2.5k

1 members found this post helpful.

8. ## Re: AC voltage measurement using pic microcontroller

hameeds01

there is one point where I have a doubt is when the ac will varry from say 160V- 250Volts AC then will the input to the microcontroller's ADC will vary or not ?

1 members found this post helpful.

9. ## Re: AC voltage measurement using pic microcontroller

here it has assumed that the Maximum Main AC voltage is 255v
u can change the max limit according to ur requirments

Main_max_volt = 255

for eg::

if present_main_volt = 0v then
5/255x0 = 0.0v & ADC = 000

if present_main_volt = 160v then
5/255x160 = 3.137v & ADC = 160

if present_main_volt = 200v then
5/255x200 = 3.921v & ADC = 200

if present_main_volt = 220v then
5/255x220 = 4.313v & ADC = 220

if present_main_volt = 250v then
5/255x250 = 4.901v & ADC = 250

now u don't need any calibration just simply convert the ADC Register value to ASCII & display it on ur screen thatz it

Don't forget to press helped me button

hameeds01@yahoo.com

6 members found this post helpful.

10. ## Re: AC voltage measurement using pic microcontroller

Hi there,

This circuit is very interesting, I will give it a try. Now a question if I wanted to measure a maximum of 350VAC ( a seocndary of a transfomer for example), what would you do in that case? Also, if I wanted then to masure the rectified voltage of that secondary (PSU for example) of around 480VDC, woudl you use a voltage divider?

Thanks for the insight,
Ronald;

•

11. ## Re: AC voltage measurement using pic microcontroller

For AC voltages above 220 use two transformers with the primary in series.(see attachment)

In the second case the divider would not work...

12. ## Re: AC voltage measurement using pic microcontroller

Originally Posted by hameeds01
measure the value of vx via digital volt meter
for eg if vx = 7v
then select
R1 = 1k , R2 = 2.5k
What the code of D1 and D2?

Tks.

13. ## Re: AC voltage measurement using pic microcontroller

can u post ckt + code hear.

14. ## Re: AC voltage measurement using pic microcontroller

it is surjeet
first i have to tell you that pic 16f72 has 8bit adc ,so u will get 255volt maximum, about to 300volt ac u should use 10bit adc,
which u will get in pic16f676

1 members found this post helpful.

15. ## Re: AC voltage measurement using pic microcontroller

i connect the circuit, but in ADC value is varied continuously , but the DC voltage is not varied

16. ## Re: AC voltage measurement using pic microcontroller

The original circuit presented by hameeds01 implements a RC discharge time constant of 35 ms (10 uF * 3.5k). The will discharge to about 56 % of it's maximum value during each 20 ms period. This behaviour is by design, although not further discussed in the present thread. You have to manage it in your software somehow, e.g. by averaging the measurements.

It should be also mentioned, that the circuit is measuring Vpeak rather than Vrms. You can correct it for a sine voltage, but if the AC voltage is distorted, the result won't be correct.

1 members found this post helpful.

17. ## Re: AC voltage measurement using pic microcontroller

Any one please give the embedded c code and circuit diagram for the above A/D conversion... Plzzz...

•

18. ## Re: AC voltage measurement using pic microcontroller

Originally Posted by lijoppans
If you only want to measure AC mains voltage, it is better to first step down (300/5 or any other ratio). Then add a capacitor filter. The output DC will be equal to Max value of the AC. Then divide it by (square root of 2) to get (secondary voltage) rms AC voltage. Multiply it by 300/5 to get mains voltage.
can u post a circuit of this?

also, is this better than taking samples of the AC voltage?

19. ## Re: AC voltage measurement using pic microcontroller

what should i do for measurement of 500V without transformer??????????

in that case i want to measure current upto 20A so how can i measure this both parameters?????????

20. ## Re: AC voltage measurement using pic microcontroller

Originally Posted by jignesh doshi
what should i do for measurement of 500V without transformer??????????

in that case i want to measure current upto 20A so how can i measure this both parameters?????????
500v? in that case your voltage divider circuit will be made to convert 500v to 5v peak. I don't know about current really.

--[[ ]]--