Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SINE WAVE AND SQUARE WAVE DETECTION

Status
Not open for further replies.

vdurgaidass

Junior Member level 3
Joined
Jul 13, 2009
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,525
My requirement is to detect the incoming power freqency and it's shape, wether it is sine wave or square wave and indicate with two LEDs. Frequency measurement no problem. Only detection of Square / Sine Wave.

Can anybody give any idea, any reference or links.

Thanks and regards in advance.

V.Durgai dass
 

Because the input voltage can have various other shapes (e.g. modified square, trapezoid, distorted sine wave), you may
want to specify a clear criterion for the decision. Depending on it's purpose, either the relation of peak to rectified average
voltage or the harmonics level (THD) can be measured.
 

Hi,
is it for only a discrete 50/60Hz frequency or some value in a band?
I would detect some hamonics ; if its a Square-you have a detected signal, but by sinus : dont have it:)...
Can you have FFT_ a calculation can be more simple for you?...
K.
 

It is only for 50Hz Power.
My requirement is if the power is 50Hz+/-1 Hz and Sinusoidal wave no action is required.
If the frequency is outside 49-51Hz or non-sinusoidal , I need to generate an alarm.
Thanks for the reply.
V.Durgai dass
 

Hi,
Even, can you have pls FFT calculation over your signal?
Because you wishes 49-51 Hz excact to know, do you have an frequency counter in system, with i.e. 0.1 Hz resolution & precision?
K.
 

THD measurement (high-pass and rectifier) is the easiest way. But you have to define a non-zero THD limit value
for acceptable "sine" waveform, because the utility network can supply considerably distorted voltage.
 

Hi
I have some knowledge in building frequency counter with 0.1 Hz resolution using micro controller. But I have no knowledge of applying/ implementing Fourier Analysis or Harmonic Distortion.
So I need some guidance to implement FFT or THD , and how to distinguish the Sinusoidal and Non-sinusoidal waves.
Thanks for all replies
V.Durgai dass
 

Hi vdurgaidass,
Im not a uP soul:-(, but if you soluted FFT calculating= you will know, where are the spectral lines & how high is their amplitude... By sinus you have no more as the 50 Hz line, if it will be distorted you becomes everey time more lines_harmonics are coming, lines & amplitudes depend of type the distorting (sawtooth/triangle/square are_distorted sinus too) others sayed signal quality.
Its not simple to calculate, these was reason of my question: can you have it?
If you dont decide to apply FFT (or DFT can be more better for you); maybe you can build/programm digital (band) filter on your uP for 100/200/300Hz and so on and check for your outcoming signal amplitudes...
If you have "sweeped (band)filter" frequency betwen 49 & 51 Hz you dont need more filter for the extrems(49 & 51 Hz), but you check the outgoing amplitudes online= you can check for your distortios too(at the harmonics, and for the concrete frequencies too, then you know your sweeped frequencies controlled/momentan value...
K.

Added after 10 minutes:

A third possibility is to build active band filters for 49,50 &51Hz and measure online (or periodicly) the output amplitudes= you konws the frequency as proportion of the tre signals.
Than much other active filters for the some, application specific for your distortions_or only theoretiacal square version, harmoincs are even to build.
Your "to do" job is "only" to analyze the 5---6 or 7 voltages after all the filter...
K.
 

Thanks. I will try to understand FFT and will try to impliment.

Thanks a lot.
V.Durgai dass
 

I noticed, that you didn't even specify using a uP for the detection. THD measurement can be basically done in
an analog way, just needing a highpass and AC level measurement, because the fundamental level can be assumed almost
fixed in this case. Most information available from a FFT is effectively unnecessary in this application. However, if a uP is
used anyway for frequency measurement, decision and human interface, a digital signal processing method can be meaningful.
FFT would be still "overkill" in my opinion, requiring more processor resources (particularly RAM) than needed for a minimal
solution.
 

Solving this problem is VERY EASY.

Square wave detection

1)
First of all, you need to transform voltage down so it doesn't kill your components. A regular voltage divider can do that, so you get, say +- 5volts out.

2)
Then send the signal through a voltage follower.

3)
Then connect the output from the voltage follower into an capacitor and resistor in series. This will make a very basic hf filter. (resistor to ground)

4)
Now you have to calculate the RC so that it just make a short spike when the signal suddenly goes high (square wave).

5)
The input spikes then is feeded into a monostable circuit that will keep active state just a bit longer than one period of time.


Sine wave detection
This one can be buit almost like the other one, but with a slight change:

Step 1 is the same, but you can skip step 2. Feed the signal into a comparator set to approx 4 volts (or anything above zeero, but not zeero). You can skip the comparator and instead use a regular bjt (but then you need the voltage follower).
Step 4 and 5 is like the other one.


Final fix
Now, if a square wave is detected, sinus detector output will also activate. So you need a little basic logic circuit to make sure only one led is active at same time.
 

HI FvM,
Both FFT & THD are new to me. I have to go through their basics. Is it possible to get some links, algorithm/ schematics.
Hi PROTOTYP,
In my requirement, only one type of wave form is present at a given time (either Sinusoidal or non_sinus). As per your statement Step 4 and 5 are same. That means I will get a spike either from a square or a sinus. Then how to distinguish the spike whether it is due to square wave or from sine wave. Can you guide me to some schematics / circuits.
Thanks for all.
V.Durgai dass
 

Hi,
If you have both on; its surly a square..but if you dont have square on: it must be sinus-or some similar (not strong distorted sinus)...
K.

Added after 4 minutes:

Hi vdurgaidass,
Maybe you can check these parallel topic:
FFT Computing
#1230335
K.
 

You didn't tell yet:
- If you prefer an analog or processor solution?
- Your criterion for non-sine waveform. I assume that it's a practical criterion: The appliance connected to the power supply
doesn'r accept waveform distortion above a certain level.
 

vdurgaidass said:
As per your statement Step 4 and 5 are same. That means I will get a spike either from a square or a sinus. Then how to distinguish the spike whether it is due to square wave or from sine wave.
Like I said: ther will be two outputs, say I name them out.voltage and out.edge

As long as you have alternating voltage out, out.voltage will be logic high. When there is a fast rising voltage (spike or squaree wave) out.edge will go logic high also.
From that you should have all information you need, but to having two led's to not indicate at same time, you have to assume that every fast positive change in voltage is caused by the nature fo square wave. You'l not be able to differ between an spike overlay in sinus voltage and square wave on input, exept from the lenght of the lights (RC). You'll probably not even notice one single spike.

Having only one light on at a time requires some logic gates. The light indicating sine wave input willl have this logic expression:
Code:
out.voltage AND NOT(out.edge)

The light indicating square wave (spike) does'n need any aditional gates, just connect it directly to out.voltage
 

Hallo vdurgaidass,
Because you are not writing enough clear in more your answers, I should ask you pls: is your square a clean square form or can be some other as triangle and so on?
If not; also only sinus or square is to decide & you have a frequency metering parallel/extra: I think the simplest way is to build with a 4x OpAmp a bandpass filter for 3./5.th harmonics of 50 Hz and active(ro better peak) rectify its output with a +op= you have a clear functioning output =1 if square is coming and otherwise a zero... Those circuit needs ca. 3-4cm2 surface if is realized:).
K.
 

This query was for a Student project in which a 230V 50 Hz system was fed power from Commercial Supply and a Inverter. The project was to find out whether the power is 50Hz Sine wave ( from commercial source) or from (Quasi Sine / Square / Non Sinusoidal) Inverter. The problem could not be solved because of time constraint.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top