+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Member level 5
    Points: 1,237, Level: 7
    Prince Vegeta's Avatar
    Join Date
    May 2012
    Posts
    84
    Helped
    0 / 0
    Points
    1,237
    Level
    7

    How to measure AC Voltage with PIC MCU...

    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

    •   AltAdvertisement

        
       

  2. #2
    Member level 5
    Points: 1,237, Level: 7
    Prince Vegeta's Avatar
    Join Date
    May 2012
    Posts
    84
    Helped
    0 / 0
    Points
    1,237
    Level
    7

    Re: How to measure AC Voltage with PIC MCU...

    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?



  3. #3
    Member level 5
    Points: 1,237, Level: 7
    Prince Vegeta's Avatar
    Join Date
    May 2012
    Posts
    84
    Helped
    0 / 0
    Points
    1,237
    Level
    7

    Re: How to measure AC Voltage with PIC MCU...

    someone please answer, I need the answer quick.



    •   AltAdvertisement

        
       

  4. #4
    Member level 5
    Points: 1,237, Level: 7
    Prince Vegeta's Avatar
    Join Date
    May 2012
    Posts
    84
    Helped
    0 / 0
    Points
    1,237
    Level
    7

    Re: How to measure AC Voltage with PIC MCU...

    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...

    I'm looking to your help.

    thanks.



  5. #5
    Member level 5
    Points: 1,237, Level: 7
    Prince Vegeta's Avatar
    Join Date
    May 2012
    Posts
    84
    Helped
    0 / 0
    Points
    1,237
    Level
    7

    Re: How to measure AC Voltage with PIC MCU...

    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?

    plz answer



    •   AltAdvertisement

        
       

  6. #6
    Advanced Member level 5
    Points: 11,015, Level: 25

    Join Date
    Apr 2012
    Posts
    1,981
    Helped
    637 / 637
    Points
    11,015
    Level
    25

    Re: How to measure AC Voltage with PIC MCU...

    Quote Originally Posted by Prince Vegeta View Post
    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.


    1 members found this post helpful.

  7. #7
    Member level 1
    Points: 644, Level: 5

    Join Date
    Apr 2011
    Location
    Lagos, Nigeria
    Posts
    34
    Helped
    4 / 4
    Points
    644
    Level
    5

    Re: How to measure AC Voltage with PIC MCU...

    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


    1 members found this post helpful.

  8. #8
    Member level 5
    Points: 1,237, Level: 7
    Prince Vegeta's Avatar
    Join Date
    May 2012
    Posts
    84
    Helped
    0 / 0
    Points
    1,237
    Level
    7

    Re: How to measure AC Voltage with PIC MCU...

    Quote Originally Posted by opopson View Post
    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:

    http://images.elektroda.net/99_1332698798.png

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

    http://images.elektroda.net/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 ^_____^



--[[ ]]--