Author Topic: When does a square wave become a sine wave?  (Read 8314 times)

0 Members and 1 Guest are viewing this topic.

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3092
  • Country: us
  • L.D.A.
When does a square wave become a sine wave?
« on: May 20, 2015, 10:36:37 am »
Hi

I have a Wavetek 145 and it puts out a nice square wave at 2 MHZ and a nice sine wave at 20 MHZ (but suppose to be square).

As I go up in freq from 2 to 20 I can see the square get worse and the sine get better.  So I was wondering what is the definition of a square wave.  ie at what freq can I say the wave is a sine wave

thanks
YouTube and Website Electronic Resources ------>  http://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2060
  • Country: au
Re: When does a square wave become a sine wave?
« Reply #1 on: May 20, 2015, 10:42:47 am »
Square waves and sine waves are both ideal mathematical constructs. There's no established definition of how good a real life sine wave has to be to be called a sine wave, similar for square waves. Instead you specify the imperfections/differences from the ideal. For square waves, rise and fall time, ringing/settling time, etc. For sine waves, THD (total harmonic distortion), THD+N and so on.
 

Offline Asmyldof

  • Regular Contributor
  • *
  • Posts: 148
  • Country: nl
  • Freelancer - Persnicketist - Do'er of stuff
    • Asmyldof's Home. It's old, not quite impressive, but it's there.
Re: When does a square wave become a sine wave?
« Reply #2 on: May 20, 2015, 10:53:18 am »
Ah, I remember also answering a question like this one on Electronics Stack a while back.

In stead of looking it up and linking it, I shall just type a new answer, in the hope my sleep deprived brain will say it right and understandably.

The square wave is a sneaky one. Actually any wave that isn't a Sine Wave is sneaky, but they are all sneaky in different orders.

In spectrum speak a squarewave of 2MHz is basically applying a figure of speech, where you actually mean to say "A square wave with a dominant frequency of 2MHz" or "A square wave with a base frequency of 2MHz".
((EDIT: added "in spectrum speak", since a signal that repeats once every 0.5us of any shape is in general engineering speak correctly specified as being 2MHz))

You see, that nice sharp flank that is the edge of the square wave is, on paper, in fact "infinite frequency" (of course, that doesn't exist in the real world and as such nor does the true square wave, they're always a tiny bit not-square).
The funny thing is, that sharp flank implies a set of higher frequencies that we call overtones. Such that when you measure the frequency spectrum of a square wave, you can see 2MHz, but also many frequencies that are a multiple of that frequency, but less powerful.

Because I am not yet aware of nice drawing or simulating tools linked into here, I will link to the wikipedia animation here:
http://en.wikipedia.org/wiki/File:SquareWave.gif
Copied from: http://en.wikipedia.org/wiki/Square_wave

The first frequency is the base frequency, 2MHz, the next frequency is the next odd overtone: 3 times as much, but 3 times as weak, so 6MHz at 1/3 the power. Then the next one is the next odd overtone, so 5 times as high, but 5 times as weak, so 10MHz at 1/5 the power, the next is the 7th, 9th, etc, etc, until some part of the circuitry can't process the overtones anymore and they start cutting out.

From your experiment, the generator apparently has a part of its circuitry cut off somewhere between 20MHz and its 3rd tone, 60Mhz, which is quite normal for analogue generators set at their maximum frequency. So you are only getting the base frequency with maybe some distortion and shift caused by the overtones in stages that actually can handle them, which is just the one sine wave.

EDIT2: See, I said it sort of wrong, I said Overtone, where more correctly it should be Harmonic. Insomnia, it's not fun.
« Last Edit: May 20, 2015, 11:06:32 am by Asmyldof »
If it's a puzzle, I want to solve it.
If it's a problem, I need to solve it.
If it's an equation... mjeh, I've got Matlab
...
...
(not really though, Matlab annoys me).
 

Offline Christe4nM

  • Supporter
  • ****
  • Posts: 241
  • Country: nl
Re: When does a square wave become a sine wave?
« Reply #3 on: May 20, 2015, 11:06:42 am »
To understand what happens you need to know that a square wave can be seen as constructed from many sine/consine waves. Each sine has a frequency that is a multiple of the fundamental frequency, i.e. an harmonic. In addition each sine has a certain amplitude. This idea is known as a Fourier series. And a Fourier transform is an algorithm that derives all those frequencies and amplitudes form a certain signal.

So a 2Mhz squareware can be seen as a 2Mhz sine + a 4Mhz sine + a 6MHz sine and so on to very high frequencies.

However, your signal generator and also your oscilloscoop have a limited bandwidth. Suppose your generator's bandwidth is 20Mhz. If you set it to generate a 10Mhz squarewave you are in for a surprise. Only the second harmonic at 20Mhz gets through, an maybe some signal at 30Mhz, but greatly reduced in amplitide. Those signals together are not near enough to form that square wave. So you get something that's more like a sine wave.

Now just to be clear, a signal generator is not using a lot of sines to create that squarewave. It's just a way to understand what is going on.
You could also view it as follows: the circuit that drives the output is not able to change te voltage fast enough to get a nice sharp edge on the square. Up to the point that the waveform is so fast changing with respect to what the circuit can handle that is falls hopelessly behind and there is no squarewave left.

edit: Asmyldof posted just while I was typing. He says the same.

edit 2: I know that a square wave actually only consists of odd harmonics, I used the even ones too to make the point.
« Last Edit: May 20, 2015, 11:12:33 am by Christe4nM »
 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1715
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: When does a square wave become a sine wave?
« Reply #4 on: May 20, 2015, 11:11:59 am »
As stated above, a square wave consists of energy at the fundamental frequency, and its odd harmonics.  The more harmonics, the faster the rising and falling edges.  If the signal generator output stage doesn't have enough BW to produce the higher harmonics, the square wave becomes more sinusoidal.  Maybe this video of mine will help:

======================================
YouTube channel: http://www.youtube.com/w2aew
FAE for Tektronix
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: nz
Re: When does a square wave become a sine wave?
« Reply #5 on: May 20, 2015, 11:30:10 am »
What I find to be an interesting point to ponder on frequency domain vs time domain.

You can have a wave that has the same harmonic content as a square wave, sounds like a square wave (to the ear) but looks nothing like a square wave on your scope.

But you cannot have a wave that has the same harmonic content as a sine wave, that doesn't look like exactly like a sine wave (possibly with a bit of phase shift)

The spectrum doesn't uniquely identify the waveform, except for a sine wave.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2060
  • Country: au
Re: When does a square wave become a sine wave?
« Reply #6 on: May 20, 2015, 12:01:29 pm »
(possibly with a bit of phase shift)
But therein lies the point: when there's only one fundamental frequency, you can phase shift that one frequency and you're "just moving it sideways". But when you phase shift a harmonic, the sine waves add up in a different way and it ends up "looking different", even though that one harmonic was just moved sideways just like before. So your point boils down to "the way of representing waves as sums of sine waves finds that a sine wave is just the sum of a single sine wave" -- mm, not so surprising perhaps.

Also, the transform (Fourier, of course) the transforms frequency to time is exactly the same as the transform from time to frequency (perhaps modulo a constant). The only apparent differences arrive from the material we often deal with: purely real time domain content, and frequency domain content that is therefore complex yet symmetrical about the vertical axis.
 

Offline Asmyldof

  • Regular Contributor
  • *
  • Posts: 148
  • Country: nl
  • Freelancer - Persnicketist - Do'er of stuff
    • Asmyldof's Home. It's old, not quite impressive, but it's there.
Re: When does a square wave become a sine wave?
« Reply #7 on: May 20, 2015, 12:08:24 pm »
:blah: :blah: :blah:

I fundamentally disagree with you!

(Good) apples are obviously more tasty than oranges!

Now, you can go ahead and change your signature and make me look like a ranting lunatic. I'm that most days anyway, so all fair.
If it's a puzzle, I want to solve it.
If it's a problem, I need to solve it.
If it's an equation... mjeh, I've got Matlab
...
...
(not really though, Matlab annoys me).
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1425
  • Country: us
Re: When does a square wave become a sine wave?
« Reply #8 on: May 20, 2015, 12:27:43 pm »
I don't have a proper method of measuring sine wave distortion, no test equipment capable of it, no nothing.

BUT...what I do have is a couple pieces of transparent plastic with a picture of a sine wave printed on it.
If I've got any doubts as to whether or not a sine wave is good or not, I lay the transparency on top of the screen of the 'scope, and adjust the time base and volts/div to match.
If it matches up, the sine wave being displayed is good, or at least good enough for me.
If not, there's too much distortion.
(Of course this method isn't going to win any awards for accuracy or producing any results of any significance, but it works for me and that's good enough)

In this case though, I have to wonder if the O/P actually means WHY does his output change from square to sine wave while increasing in frequency (eg. why are the edges rounding off)...
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2060
  • Country: au
Re: When does a square wave become a sine wave?
« Reply #9 on: May 20, 2015, 12:58:09 pm »
(Good) apples are obviously more tasty than oranges!

Now, you can go ahead and change your signature and make me look like a ranting lunatic. I'm that most days anyway, so all fair.

And here I was thinking your signature was a Vanilla Ice reference.
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3092
  • Country: us
  • L.D.A.
Re: When does a square wave become a sine wave?
« Reply #10 on: May 20, 2015, 01:07:25 pm »
I have included 3 pics , the Wavetek is set for a square wave for all 3 pics, no changes made to the Wavetek other than changes to the freq.

At 2 MHz it looks like a square (to me) , at 10 MHz ?, and at 20 MHz it looks to me to be a sine wave (I assume the Wavetek is bad and will post a help post in the repair section)

So what is the 10 MHz wave - square or sine ??

thanks

YouTube and Website Electronic Resources ------>  http://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2060
  • Country: au
Re: When does a square wave become a sine wave?
« Reply #11 on: May 20, 2015, 01:12:14 pm »
So what is the 10 MHz wave - square or sine ??

Neither? Again, you're obsessed with this false dichotomy between square or sine, or the false idea that there's some well-defined definition delineating the two.

If you showed me that wave and just asked me to describe it, I'd say it's a lazy, rounded off cross between a square and a sawtooth wave.

EDIT: I notice that there's pretty significant overshoot in your 2 MHz square wave -- have you compensated your oscilloscope probes properly (hook up to test source on oscilloscope, twiddle screw in probe until overshoot is gone)? That might make your 10MHz wave look a lot better.
« Last Edit: May 20, 2015, 01:17:06 pm by rs20 »
 

Offline Fsck

  • Super Contributor
  • ***
  • Posts: 1157
  • Country: ca
  • sleep deprived
Re: When does a square wave become a sine wave?
« Reply #12 on: May 20, 2015, 01:15:00 pm »
So what is the 10 MHz wave - square or sine ??

Neither? Again, you're obsessed with this false dichotomy between square or sine, or the false idea that there's some well-defined definition delineating the two.

If you showed me that wave and just asked me to describe it, I'd say it's a lazy, rounded off cross between a square and a sawtooth wave.

I'd go with neither as well.
"This is a one line proof...if we start sufficiently far to the left."
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3092
  • Country: us
  • L.D.A.
Re: When does a square wave become a sine wave?
« Reply #13 on: May 20, 2015, 01:18:24 pm »
ah I have to go and check the sawtooth  :)
but good to know that it is neither one (I would not have guessed this)
thanks
YouTube and Website Electronic Resources ------>  http://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 5812
Re: When does a square wave become a sine wave?
« Reply #14 on: May 20, 2015, 02:21:14 pm »
Neither and both.

You can think of it as a sine with extra added harmonics, or a square wave that's been rounded off because its higher harmonics have been attenuated.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2034
  • Country: au
  • There's more value if you figure it out yourself!
Re: When does a square wave become a sine wave?
« Reply #15 on: May 20, 2015, 02:24:22 pm »
... and I thought this thread was going to head off into complex maths about dissipation of energy, capacitance, inductance, reactance, etc.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 844
  • Country: ca
Re: When does a square wave become a sine wave?
« Reply #16 on: May 20, 2015, 02:51:50 pm »
Some leading questions regarding your setup:
Have you hacked that 1054z for more bandwidth?
Are you using a probe in 1x mode?
Do you have the 'scope's bandwidth limiter on?

 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1425
  • Country: us
Re: When does a square wave become a sine wave?
« Reply #17 on: May 20, 2015, 02:57:20 pm »
Is it terminated?

Probably not.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline vaualbus

  • Frequent Contributor
  • **
  • Posts: 294
  • Country: it
Re: When does a square wave become a sine wave?
« Reply #18 on: May 20, 2015, 03:16:05 pm »
Quote from: Skimask link=topic=48145.msg676731#msg676731i date=1432097840
Is it terminated?

Probably not.



Is it 50ohm probably not
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: When does a square wave become a sine wave?
« Reply #19 on: May 20, 2015, 03:22:30 pm »
Quote from: Skimask link=topic=48145.msg676731#msg676731i date=1432097840
Is it terminated?

Probably not.



Is it 50ohm probably not

Seems to me the FG (wavetek 145) is 50 ohms:

http://www.eevblog.com/forum/repair/wavetek-145-bad-square-wave-at-high-freqs/msg676698/#msg676698
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2060
  • Country: au
Re: When does a square wave become a sine wave?
« Reply #20 on: May 20, 2015, 04:45:12 pm »
And, is the probe compensated properly? Doesn't look it, judging from the 2 MHz wave.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: When does a square wave become a sine wave?
« Reply #21 on: May 20, 2015, 04:48:23 pm »
And, is the probe compensated properly? Doesn't look it, judging from the 2 MHz wave.

I think he used the scope's probe with the ground clip instead of using a spring ground and proper termination.
 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11045
  • Country: gb
Re: When does a square wave become a sine wave?
« Reply #22 on: May 20, 2015, 11:28:47 pm »
Some leading questions regarding your setup:
Have you hacked that 1054z for more bandwidth?
Are you using a probe in 1x mode?
Do you have the 'scope's bandwidth limiter on?
I agree. It's quite likely the oscilloscope or probe are filtering out the harmonics.
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3092
  • Country: us
  • L.D.A.
Re: When does a square wave become a sine wave?
« Reply #23 on: May 21, 2015, 11:34:52 am »
Have you hacked that 1054z for more bandwidth?  -->  No

Are you using a probe in 1x mode?  -->  Yes

Do you have the 'scope's bandwidth limiter on?  --> No

I ordered some 50 ohm gadgets and will test again when I get them

thanks
YouTube and Website Electronic Resources ------>  http://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2060
  • Country: au
Re: When does a square wave become a sine wave?
« Reply #24 on: May 21, 2015, 11:57:56 am »
Are you using a probe in 1x mode?  -->  Yes

Woah, woah, woah... :



TLDR; Use your probe in 10x mode (unless you absolutely need extremely low vertical noise and and can tolerate very low bandwidth).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf