Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

measurement of AC lin voltage (220V) using pic16f877a

Status
Not open for further replies.
Hi friends!
I want to measure the AC line voltages 220V using pin RA5 of Pic16F877A, and display it on LCD Screen. kindly help me with circuit diagram and code. i also studied the mikrochip application note AN521 bu't cant get any specifice solution. they just add a 5M ohm resistor in series with RA0. kindly tell me how should i get the voltage sample form 220V AC line feed it into the ADC of PIC and display the correct value on LCD screen. i need circuit diagram of voltage sample circuit and a little code for that.

any help will be much appreciated.

thanking you all in anticipation.
 
I would use a small step-down transformer (like a wall-wart) to convert 240V to something like 5V. Follow that with an op-amp precision rectifier circuit to convert that to something the ADC can sample...
 
actually i don't want to use transformer. i want to take sample using resistors or some passive devices. it is to reduce circuit size.
 
actually i don't want to use transformer. i want to take sample using resistors or some passive devices. it is to reduce circuit size.
Is the PIC AC line-powered? Sounds like you are building a death-trap.
 
yes it is ac line powered with a 12v battery backup in case of ac line failure.... i don,t think it is dangerous because i am connecting high value resistors in series with line to drop the voltage value and i am getting round about 5v across variable resistor and still i am increasing the value of variable resistor to decrease the value of voltage on to the pin of micro up to less than 1V.. i don't think it is a death-trap....
 
A transformerless, 240V AC line-powered anything is a death-trap! Not something that should be attempted by a hobbyist that has to ask how to build a resistive voltage divider.
 
A transformerless, 240V AC line-powered anything is a death-trap! Not something that should be attempted by a hobbyist that has to ask how to build a resistive voltage divider.

Correct!

I agree 100%

JimB
 
As others have suggested, use a transformer. Very small ones are available. Or you could use an opto-isolator in linear mode (though I'm not sure how accurate a result you'd get).

Here's one way of using an opto-isolator. It gives a DC output which varies with peak mains voltage (hence with RMS voltage). Or you could use the micro to measure the peak voltage (~proportional to peak mains voltage) across R2. Either option would require calibration.
View attachment 67713
 
Last edited:
Unless the OP is willing to give up on trying to power the PIC/Battery/Charger/Regulator circuitry directly off the 220V AC line without using transformer isolation, there is no point in isolating just the voltage sensing.

I'll say it again: A hobbyist should not be building circuits powered directly from a 120V/240V line. There are just too many ways to slip and get across lethal voltages.
 
If you power the circuit from a transformer power supply (ie not a switcher) then if your load is fairly constant and you dont need to be more than a volt or two accurate then you can just measure the dc rail and scale that back from mains voltage, seen it done before just the cost of 2 resistors.
 
Isolation is important. OP says size is important. Therefore OP should:
1) Wind a small transformer with a 10:1 ratio ( 50 to 5 turns) driven by a properly voltage & wattage rated resistor (10 kohm) in series with the primary coil to permit small gauge (30+ AWG) enameled wiring. A scrap toroid from a PC PSU can be rewound. Or even use some soft iron or ferrite rod.
The 10K primary permits around 22mA (@ 4.8Watts) of current, which will go to about 220mA in the secondary. I'd use 10, 1K, 1W resistors in series if space allows.
2) Rectify and regulate the secondary voltage to 5v for the uC power
3) Tap a 50:1 ratio (off a single turn of the secondary) voltage unrectified power to peak at perhaps +/- 6.2V. Then using a full wave bridge as shown here:
**broken link removed**

do not join the outputs of D1 and D3, instead send them to 2 adc inputs via 50/50 resistive voltage dividers (10k - 10k) for sampling. This permits instantaneous sampling and determination of +ve or -ve going AC with a grounded DC reference that the uC uses.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top