Continue to Site

How to measure AC Voltage with PIC MCU...

Status
Not open for further replies.

Prince Vegeta

Member level 5
I need to measure 2 220vp/50Hz AC voltages (in an ATS project). I chosen PIC16F877A as the MCU.

my problem is to measure the 220vAC signal. I made a circuit to convert voltages as follows:

+230v -> 5v
0v -> 2.5v
-230v -> 0v

but now how can I feed it to the MCU the proper way?

I can get the ADC but I need to measure the voltage so that if it get less than a certain value (say 200v on both +and-), the MCU will switch to the other supply... and so on.

I'm confused of the -ve half cycle! if it's just DC voltage I would have done it properly.

I hope you help me with the code too.

Here is my measuring circuit (does it need zener?):

THX

Attachments

• ac-measure.bmp
699 KB · Views: 325

I tested the circuit in proteus isis, it gives nearly 4.5v for 230v and -4.5v for -230v....

^ that test was using oscilliscope's channel 1 on AC mode. On DC mode it gave about 9v peak.

the thing I need to do is measuring AC voltage and make sure it's good enough (stays at 220v right?) because I'm designing an ATS.

source1 is the normal grid voltage and source2 is the solar voltage. this should measure solar's voltage to verify is it 220v or not. u get me?

but 220v is the peak value or RMS?

I found an idea to make a voltage divider outputs 220v as 2.5vmax and it will have -2.5v too... now using op-amp or any thing, a +2.5v will be added to make it 0-5v.

^ can anyone help me with that?

If that's done, I still need to measure the RMS voltage to know if the source is at a good level or what...

thanks.

how about my previous post? adding +2.5v to the 2.5vp AC signal to be 0-5v into ADC pin... can anyone give me a circuit that adds this DC voltage to AC voltage?

but 220v is the peak value or RMS?
RMS, if you're talking about mains voltage. Peak is over 300V. If you allow for +-350V, that should cater for any normal mains. Best to have some sort of clamp/limiter at the PIC input anyway in case there's spikes in the KV range.

Prince Vegeta

Prince Vegeta

Points: 2
Pic mcu has an inbuilt adc that can be used as a voltmeter! I advise you use that POC for your work! If u are still having diffculties, let me know the language you program pic with, so I can try develop a code 4 u! But you should try it yourself with the aid of datasheet. Its pretty simple

Prince Vegeta

Prince Vegeta

Points: 2
Pic mcu has an inbuilt adc that can be used as a voltmeter! I advise you use that POC for your work! If u are still having diffculties, let me know the language you program pic with, so I can try develop a code 4 u! But you should try it yourself with the aid of datasheet. Its pretty simple

Hi man... I'm using MikroC IDE.

I have an idea of converting this 350vp AC to 2.5vp AC. now it has a -2.5vp (and negative cycle) which PIC ADC can't measure... so I made the voltage divider circuit shown above (modified than the above one, but the same schematics... 2k is now 1k ohm and +5v VCC is now +2.5v).

That circuit above adds +2.5v to the 2.5vp AC signal to get rid of the negative cycle so that -2.5v now equals 0v....

so, it is like this:

+350vp = +5v
0v = 2.5v
-350vp = 0v

^ this signal can be easily transferred to PIC ADC and it can read it easily right?

now my problem is how to calculate the RMS value of it. Can u help in it? If you have then post the code here with Proteus ISIS simulation file (for testing it)... Thank you.

RMS, if you're talking about mains voltage. Peak is over 300V. If you allow for +-350V, that should cater for any normal mains. Best to have some sort of clamp/limiter at the PIC input anyway in case there's spikes in the KV range.

Hmm.. for protection I read that adding a 5.1v Zener Diode just before the ADC pin is a great thing to protect the PIC MCU. like this image from a blog here:

https://obrazki.elektroda.pl/99_1332698798.png

and the same blog suggested adding a voltage follower (analogue buffer) to the circuit like this:

https://obrazki.elektroda.pl/18_1332698878.png

this is to enhance the impedance.. I don't quite understand it.

Any suggestions u have?

______

I look forward to your help ^_____^

Status
Not open for further replies.