Pure Sine Wave Detection Using PIC Microcontroller?

Thread Starter

umarfarooqleo

Joined Dec 4, 2012
10


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

ErnieM

Joined Apr 24, 2011
8,415
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.
 

Markd77

Joined Sep 7, 2009
2,806
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:
 

Attachments

Last edited:

ErnieM

Joined Apr 24, 2011
8,415
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."
 

THE_RB

Joined Feb 11, 2008
5,438
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.
 

Potato Pudding

Joined Jun 11, 2010
688
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

 
Last edited:

THE_RB

Joined Feb 11, 2008
5,438
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.
...
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.
 

Thread Starter

umarfarooqleo

Joined Dec 4, 2012
10
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.
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.
 

Thread Starter

umarfarooqleo

Joined Dec 4, 2012
10
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:
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?
 

ErnieM

Joined Apr 24, 2011
8,415
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.
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.
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

Attachments

Picbuster

Joined Dec 2, 2013
1,062
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????
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
 
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
Do you think this would work? We really need a design like this. We are will to pay for the work. Any suggestions as to how I might get this done?
 

BR-549

Joined Sep 22, 2013
4,928
Line frequency is slow. Why not take a sample every millisecond for 16 milliseconds.....and display it. This can be displayed with 8 negative or 8 positive going bars.......16 bars long. 7 bits/pixels negative or positive for instance.

Pure is relative.
 

John P

Joined Oct 14, 2008
2,068
Zombie thread!

But if this is still considered valid, and doesn't violate the Allaboutcircuits rule against mains-connected circuits, I still don't see how the distinction is made between "pure" and "modified" waves. In real life, nothing is ever perfect, so how much deviation do you accept before you want a different output? I think it's possible (as was suggested a few years ago, more or less) to normalize the incoming wave for amplitude and frequency, then compare samples taken at some number of points versus pre-calculated values, and get a figure of merit for the incoming wave. That would be on a fairly arbitrary scale, but it's not too math-intensive, unlike a THD calculation. But it all depends on what's needed.
 
Top