AC Voltage Measurement using PIC

Discussion in 'Embedded Systems and Microcontrollers' started by Qual, Aug 5, 2016.

  1. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0
    hi,

    I need help to design a circuit which receives the voltage from AC mains( i.e Line and Neutral) and gives out a low voltage to PIC .
    Where PIC receives this voltage and displays the AC mains voltage on LCD by doing calculations.
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,804
    1,105
    It's called a 'transformer'. This provides isolation from the mains to protect you and the PIC from danger. The transformer low voltage output (e.g. 3V RMS) is a known fixed fraction of the mains voltage input.
    Welcome to AAC!
     
    ErnieM and Qual like this.
  3. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0

    Thank you for welcoming.

    I want to measure this ac mains voltage and display the same on LCD.
    I have seen many articles regarding this where they say isolation is required between mains and pic.
    But i want a circuit which gives output in the range of 0-5V so that it can be fed to PIC.
     
  4. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0



    Alec_t Can i provide isolation using optocoupler from the mains ?
     
  5. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,348
    Hello,

    An optocoupler will not give a linear response.
    A transformer will be almost linear, until you reach saturation.

    Bertus
     
    Qual likes this.
  6. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0
  7. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0
    Here in below pdf designer does not use any transformer or optocoupler but he says he is doing measurement using op amp.

    Can anyone guide me in this matter, as i am getting confused with many circuits which show measurement .


    {Moderator's note: The application note has been removed]
     
    Last edited by a moderator: Aug 6, 2016
  8. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,962
    387
    This circuit is not isolated from the mains - the whole circuit is live. It uses a capacitor input power supply discussion of which is not allowed in here on safety grounds.

    This circuit only measure current. You would need to do some work to convert it to reading voltage. Some of your new circuitry will be at mains potential requiring great care troubleshooting if doesn't work as you expected.

    A 3V transformer would provide around 4.2V of rectified DC which would give you reasonable for higher supply voltages and still keep within the 0V to 5V for the PIC. For higher transformer voltages, you just a potential divider to reduce the voltage to the range the PIC can measure.
    Using a transformer means your mains circuitry is simple and trouble free - connect the mains supply to the primary. Simple and safest.
     
    Qual and bertus like this.
  9. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0
    Thank you AlbertHall for your reply. I got some basic idea. :)

    Is there any other way to provide isolation between mains and pic.

    My aim is to design a circuit which can do measurement of ac voltage

    And in addition current display and power factor too.
     
  10. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,962
    387
  11. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    A transformer is the easiest and best way to read the mains voltage with isolation.
    Why are you resisting that solution?
    It's possible to use an opto coupler circuit for that purpose but it becomes a lot more complex.

    Note that a current transformer goes around only one of the main's wires.

    To determine power factor you will need to determine the ratio of the real power to the apparent power.
    You can't do that by measuring the rectified AC (DC) voltage, it must be measured in the AC form.

    The easiest way to determine the power factor is to simultaneously sample the voltage and current at a high frequency (perhaps a 100 times the main's frequency) with an A/D converter and then calculate the ratio of the real power to the apparent power to get the value of the power factor.
    This will give an accurate power factor, even if the load causes distortion in the current drawn, such as many electronic devices do.
     
    Qual likes this.
  12. NorthGuy

    Active Member

    Jun 28, 2014
    604
    121
    When calculating power, keep in mind that the current transformer will introduce some sort of phase shift, perhaps few degrees. If you're measuring power of a motor with pf around 0.6, this few degree phase shift will produce substantial errors, so you will need to correct it (most likely in your software).
     
  13. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    I would expect the transformer phase shifts for both voltage and current to be very small, but they certainly could be corrected by measuring the power of a resistance load and adjusting the calculations (if necessary) to give a PF of 1.
     
    Qual likes this.
  14. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0

    Thank you for your reply,

    Reason for resisting Transformer was to make my circuit as simple as that !!

    But now after going through through replies from all of you i clear that opto coupler based circuit would be complex.!!!
     
  15. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0
    NorthGuy crutschow

    You both are right transformer provides phase shift in both voltage and current.:)
     
  16. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    Here's a paper on how to deal with that.
     
    Last edited: Aug 5, 2016
    Qual likes this.
  17. BobaMosfet

    Active Member

    Jul 1, 2009
    109
    11
    Unfortunately AAC only allows for transformer isolation, which is a shame because there are cheaper, esier, and equally safe ways to do it without.
     
  18. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    I believe it's allowed here as long as it's isolated by whatever means.
     
    Last edited: Aug 5, 2016
  19. Qual

    Thread Starter New Member

    Aug 5, 2016
    26
    0

    Can you share the that here....
     
  20. DickCappels

    Moderator

    Aug 21, 2008
    2,659
    632
    The relative safety of a given method may be highly dependent upon the experience and skill of the one using the method. Hence, discussion of circuits that are powered directly from the mains are not allowed here and circuits that connect to the mains without isolation are carefully reviewed with respect to safety to not only those immediately participating the the thread but also for inexperienced users who might come across the thread later.
     
    Qual likes this.
Loading...