When does a square wave become a sine wave? - Page 1
Forum section: electronics / beginners

author: ez24
author_rank: Super Contributor
timestamp: May 20, 2015, 12:36:37 am
content: HiI 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 wavethanks

author: rs20
author_rank: Super Contributor
timestamp: May 20, 2015, 12:42:47 am
content: 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.

author: Asmyldof
author_rank: Regular Contributor
timestamp: May 20, 2015, 12:53:18 am
content: 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.gifCopied from:http://en.wikipedia.org/wiki/Square_waveThe 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.

author: Christe4nM
author_rank: Unknown
timestamp: May 20, 2015, 01:06:42 am
content: 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.

author: w2aew
author_rank: Super Contributor
timestamp: May 20, 2015, 01:11:59 am
content: 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:

author: hamster_nz
author_rank: Super Contributor
timestamp: May 20, 2015, 01:30:10 am
content: 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.

author: rs20
author_rank: Super Contributor
timestamp: May 20, 2015, 02:01:29 am
content: Quote from: hamster_nz on May 20, 2015, 01:30:10 amBut 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.

author: Asmyldof
author_rank: Regular Contributor
timestamp: May 20, 2015, 02:08:24 am
content: Quote from: rs20 on May 20, 2015, 02:01:29 amI 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.

author: Skimask
author_rank: Super Contributor
timestamp: May 20, 2015, 02:27:43 am
content: 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)...

author: rs20
author_rank: Super Contributor
timestamp: May 20, 2015, 02:58:09 am
content: Quote from: Asmyldof on May 20, 2015, 02:08:24 amAnd here I was thinking your signature was a Vanilla Ice reference.

author: ez24
author_rank: Super Contributor
timestamp: May 20, 2015, 03:07:25 am
content: 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

author: rs20
author_rank: Super Contributor
timestamp: May 20, 2015, 03:12:14 am
content: Quote from: ez24 on May 20, 2015, 03:07:25 amNeither? 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.

author: Fsck
author_rank: Super Contributor
timestamp: May 20, 2015, 03:15:00 am
content: Quote from: rs20 on May 20, 2015, 03:12:14 amI'd go with neither as well.

author: ez24
author_rank: Super Contributor
timestamp: May 20, 2015, 03:18:24 am
content: ah I have to go and check the sawtoothbut good to know that it is neither one (I would not have guessed this)thanks

author: amyk
author_rank: Super Contributor
timestamp: May 20, 2015, 04:21:14 am
content: 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.

author: SL4P
author_rank: Super Contributor
timestamp: May 20, 2015, 04:24:22 am
content: ... and I thought this thread was going to head off into complex maths about dissipation of energy, capacitance, inductance, reactance, etc.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: May 20, 2015, 04:51:50 am
content: 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?

author: Skimask
author_rank: Super Contributor
timestamp: May 20, 2015, 04:57:20 am
content: Is it terminated?Probably not.

author: vaualbus
author_rank: Frequent Contributor
timestamp: May 20, 2015, 05:16:05 am
content: Quote from: Skimask link=topic=48145.msg676731#msg676731i date=1432097840Is it 50ohm probably not

author: miguelvp
author_rank: Super Contributor
timestamp: May 20, 2015, 05:22:30 am
content: Quote from: vaualbus on May 20, 2015, 05:16:05 amSeems to me the FG (wavetek 145) is 50 ohms:https://www.eevblog.com/forum/repair/wavetek-145-bad-square-wave-at-high-freqs/msg676698/#msg676698

author: rs20
author_rank: Super Contributor
timestamp: May 20, 2015, 06:45:12 am
content: And, is the probe compensated properly? Doesn't look it, judging from the 2 MHz wave.

author: miguelvp
author_rank: Super Contributor
timestamp: May 20, 2015, 06:48:23 am
content: Quote from: rs20 on May 20, 2015, 06:45:12 amI think he used the scope's probe with the ground clip instead of using a spring ground and proper termination.

author: Zero999
author_rank: Super Contributor
timestamp: May 20, 2015, 01:28:47 pm
content: Quote from: Paul Moir on May 20, 2015, 04:51:50 amI agree. It's quite likely the oscilloscope or probe are filtering out the harmonics.

author: ez24
author_rank: Super Contributor
timestamp: May 21, 2015, 01:34:52 am
content: Have you hacked that 1054z for more bandwidth? --> NoAre you using a probe in 1x mode? --> YesDo you have the 'scope's bandwidth limiter on? --> NoI ordered some 50 ohm gadgets and will test again when I get themthanks

author: rs20
author_rank: Super Contributor
timestamp: May 21, 2015, 01:57:56 am
content: Quote from: ez24 on May 21, 2015, 01:34:52 amWoah, woah, woah... :TLDR; Use your probe in 10x mode (unless you absolutely need extremely low vertical noise and and can tolerate very low bandwidth).

author: miguelvp
author_rank: Super Contributor
timestamp: May 21, 2015, 02:16:27 am
content: Or use a coax cable with proper termination on the scope end, don't use the probes to measure the signal generator.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: May 21, 2015, 07:13:41 am
content: Also note that with an unhacked scope with 50MHz bandwidth, you'll not be able to see enough harmonics on the 20MHz square wave for it to look particularly square. 1st is 20MHz, 3rd is 60, 5th is 100MHz, etc. So you'll only see the first, some of the 3rd and maybe a hint of the 5th.But yeah I'll bet 1x probing is the biggest problem here. 1x sucks...

author: grumpydoc
author_rank: Super Contributor
timestamp: May 21, 2015, 02:28:22 pm
content: Quote from: Paul Moir on May 21, 2015, 07:13:41 amIndeed.There are two discussion threads on this.As well as the measurement issues there is also the fact that the the Wavetek 145 has a rise time of ~20ns so it probably can't manage a very "square" 20MHz square wave

author: hamster_nz
author_rank: Super Contributor
timestamp: May 21, 2015, 06:37:49 pm
content: I did some playing around last night with my 100 MHz scope, 150 MHz probes, along with 4 MHz, 20 MHz and 40 MHz square waves. And as expected at 40 MHz they didn't look like a square wave at all. But one big difference from the OP's screen-grabs was that it looked nothing like a pure sine.So I guess that the making a 100 MHz scope hardware into a 50 MHz scope is achieved through a brick wall 50MHz DSP filter, hence the OP's 'pure' looking sine? If that is the case, then that is a reasonable explanation for his traces...This could be verified by watching the waveform as the frequency is swept. Between 15 MHz and 18 MHz the waveform should change dramatically as the 3rd harmonic gets nuked by the filter, and between 9.5 MHz and 10.5 Mhz when the 5th harmonic gets cut.Between 10.5MHz and 15MHz the waveform should stay pretty much the same shape.