Pure Sine Wave Detection Using PIC Microcontroller?

Discussion in 'Embedded Systems and Microcontrollers' started by umarfarooqleo, Dec 22, 2012.

  1. umarfarooqleo

    Thread Starter New Member

    Dec 4, 2012
    10
    0


    Hi Everyone.....
    my Task is Simple:
    I have to design a Circuit which take 220V AC input n detect whether the AC input is Pure Sine Wave or Modified Sine Wave and display the result.....

    please help me how to detect whether the AC input is Pure sine wave or Modified sine Wave using Pic Micro-controller????
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Well, your question begs three more questions (in reverse order):

    Is it the software you need help with?
    Is it the hardware you need help with?
    Is it the detection method you need help with?

    And for safety's sake, start with a small 6.3V or so transformer to get a safer representation of the line voltage to sample, least you kill yourself doing this.
     
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Do you need to use a PIC?
    If you feed the output from the suggested transformer through a small capacitor (and a resistor to ground) you will get voltage peaks with the modified sine wave which could be picked up with a simple circuit, maybe they could even be directly connected to an LED.

    This is how it works, the inputs are 10V peak to peak square and sine waves. With modified sine wave there would be more voltage spikes and they would be smaller:
    [​IMG]
     
    Last edited: Dec 22, 2012
    umarfarooqleo and absf like this.
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    The RC is nice, but it just changes the problem to a different (albeit easier) problem to solve.

    Using a PIC allows one to run the wave into a digital input and measure the duty cycle; near 50% is "pure," much less is "modified."
     
    absf likes this.
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    That's a nice simple solution Ernie. :) Maybe it could also be done that way in analogue too?

    If using a PIC you could also take X ADC samples over a full mains cycle. If the signal is a sine then there would be a percentage of the samples at each expected aplitude, compared to the peak. So X percent at <10%, Y percent at 10-20%. That is more work but would give a fair indication of the "sine-ness" of the signal.
     
    absf likes this.
  6. Potato Pudding

    Well-Known Member

    Jun 11, 2010
    684
    92
    What makes a sine wave pure?

    You definitely need differential data and that RC filter is the simplest way to get it.

    Then you need to see if values for the tested sine wave and its rate of change (both unitized relative to their max measured values) map to each other; -90 degrees out of phase.

    Good Luck with that. :p

    [​IMG]
     
    Last edited: Dec 23, 2012
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Well the OP didn't really define his constraints, but as a guess from context determining "pure" vs "modified" sounds like the two major ways AC inverters work.

    [​IMG]

    A "modified" sine wave is not a sine at all but a pulse wave.
     
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    I don't think you need to look for a perfect mathematical sine, AC mains sinewaves are very distorted with a flattened top and deformed sides. Using your RC method would give problems with that, where a zoned amplitude system like the one I suggested would match a perfect sine OR a distorted AC mains sine reasonably equally.

    And ErnieM's suggestion is still the easiest to implement and should be pretty reliable.
     
  9. umarfarooqleo

    Thread Starter New Member

    Dec 4, 2012
    10
    0
    Is it the software/hardware/detection method you need help with?
    ans: i need idea how to do it using an electronic circuit. circuit using PIC or electronics components.
     
  10. umarfarooqleo

    Thread Starter New Member

    Dec 4, 2012
    10
    0
    gud idea but i m using outputs of pure sine wave inverter and modified sine wave inverter! n its modified sine wave is not square wave or sooo much distorted!
    will this circuit still help?
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    You could calculate the FFT and look at the harmonics.
     
  12. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    My approach would be to make a simple digitizer where a PIC pin is driven to a logic one when the sine wave is above zero. A very low level signal and a comparator can do this, even an internal comparator in the PIC. Then the period is measured.

    I'm willing to help with ideas or other suggestions. Sorry to say I am not going to design nor program your circuit.
     
    umarfarooqleo likes this.
  13. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    It might be worth a try because it is so simple, especially if you have both types of inverter on hand to test it with.
    The transformer is one that should produce around 10-12V AC output and the diodes shown are red LEDs. They aren't going to be very bright because they only get short pulses with the modified sine, but with a pure sine wave there won't be enough voltage to light them at all.
    If it works at all and you need the LEDs brighter, it should be possible with a little extra circuitry or playing around with the component values.
    [​IMG]
     
    umarfarooqleo likes this.
  14. pspproducts

    New Member

    Jun 18, 2016
    1
    0
    Has anyone resolved this issue?
     
  15. Picbuster

    Member

    Dec 2, 2013
    373
    50
    Use a PIC
    Measure the used frequency first .
    Calculate the power as function of sinus compare this with measured value. (for N periods)
    use approximation ( if measured value is within 0.x% from calculated one you have a sine wave else other type of signal).
    x = tbd
    Picbuster
     
  16. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I don't believe the problem was resolved, so a solution will be indeterminate.
     
Loading...