What is this glitch in my square wave graph? - Page 1
Forum section: electronics / beginners

author: nbritton
author_rank: Frequent Contributor
timestamp: September 18, 2015, 12:04:38 am
content: In the attached screenshot, which is a graph of the Fourier series summation of a square wave to the 999 harmonic, there is a blip at the top center of the waveform, is this a glitch in the software or is this part of the waveform?

author: nbritton
author_rank: Frequent Contributor
timestamp: September 18, 2015, 12:18:20 am
content: Also what is the formula to calculate the period of the sine wave that is riding on top of the square wave for any given harmonic?

author: nbritton
author_rank: Frequent Contributor
timestamp: September 18, 2015, 12:28:25 am
content: Quote from: nbritton on September 18, 2015, 12:18:20 amWouldn't it just be the period of the square wave multiplied by the order of the harmonic. i.e. 25 MHz square wave * 11th harmonic = 275 MHz

author: nbritton
author_rank: Frequent Contributor
timestamp: September 18, 2015, 01:24:53 am
content: Here's a pretty graph I made.

author: rs20
author_rank: Super Contributor
timestamp: September 18, 2015, 01:45:42 am
content: I'm pretty sure the blip that you see is not mathematically correct. I.e., it is a "glitch in your software" (or, a consequence of the way that floating point maths works, which would appear in any software [except, slight differences in how other software works might hide this issue maybe]).

author: tec5c
author_rank: Frequent Contributor
timestamp: September 18, 2015, 08:41:30 am
content: Quote from: rs20 on September 18, 2015, 01:45:42 am+1. As this is not mathematically correct.Which software are you using? If you have access to Matlab then I'm certain you would not see said glitch.

author: RogerRowland
author_rank: Regular Contributor
timestamp: September 18, 2015, 08:51:06 am
content: Quote from: nbritton on September 18, 2015, 12:28:25 amThat's correct, the 11th harmonic of a 25MHz square wave is 25 * 11 = 275MHz. Also, its amplitude should be whatever the square wave amplitude is multiplied by 2/(pi * 11).

author: albert22
author_rank: Regular Contributor
timestamp: September 18, 2015, 12:51:37 pm
content: The gibbs effect /or phenomenon) seems to explain your results.Take a look here:https://en.wikipedia.org/wiki/Gibbs_phenomenon

author: rs20
author_rank: Super Contributor
timestamp: September 18, 2015, 12:54:00 pm
content: Quote from: albert22 on September 18, 2015, 12:51:37 pmNo, we're talking about the spike on the middle of the plot, where it's supposed to be dead flat.

author: albert22
author_rank: Regular Contributor
timestamp: September 18, 2015, 04:02:51 pm
content: Quote from: rs20 on September 18, 2015, 12:54:00 pmI had to look very carefully to saw it, didnt see it before.+1 to a software glitch.

author: onlooker
author_rank: Frequent Contributor
timestamp: September 19, 2015, 12:07:54 am
content: The middle peak is the mathematical result of the given sum at x=0.50.25; it is not software glitch.For x=0.50.25, the formula = 1/pi*(1/1-1/3+1/5-1/7...) >= 1/3*(1-1/3) = 2/9 = 0.22.If we include 2 and 3 more terms, we get the bounds: 0.230 < peak <0.266The mistake is to apply the formula beyond the physically valid domain of 0<=x<0.50.25. This0.50.25 is related to the Nyquist frequency's 1:2 relation or call it the limitation of discrete FT/FFT (Here, x is the frequency to observe; while10.5 (due to 2k in use) is the sample frequency).Edited: Wrong reasoning. x is in time domain. If the plot was extended to x=1.0 to show a full period of the square wave, I would have realized earlier that this is not a spectrum plot.

author: tec5c
author_rank: Frequent Contributor
timestamp: September 19, 2015, 12:31:38 am
content: Quote from: onlooker on September 19, 2015, 12:07:54 amFor x = 0.5, the sum results in 0?

author: onlooker
author_rank: Frequent Contributor
timestamp: September 19, 2015, 12:35:20 am
content: QuoteYou are right and thanks, it is my typo. I should say for x=0.25. That is where the middle peak is. Another typo/mistake is sample frequency. it is 0.5 not 1. since 2k is in use.

author: tec5c
author_rank: Frequent Contributor
timestamp: September 19, 2015, 01:03:55 am
content: Mathematically, I am having a hard time in representing that peak at x = 0.25.For x = 0.1, sum = 0.2499...For x = 0.2, sum = 0.25007...For x = 0.21, sum = 0.25007...For x = 0.22, sum = 0.25008...For x = 0.23, sum = 0.25008...For x = 0.24, sum = 0.25008...For x = 0.25, sum = 0.25008...For x = 0.26, sum = 0.25008......For x = 0.30, sum = 0.25007...

author: tec5c
author_rank: Frequent Contributor
timestamp: September 19, 2015, 01:16:44 am
content: For some reason my copy of Matlab isn't working on this PC so I had to resort to other options (some online graphing tool).

author: onlooker
author_rank: Frequent Contributor
timestamp: September 19, 2015, 01:29:32 am
content: Ya, My mistake again to read the line at vertical to be 0. The calculation was right, but the reasoning was wrong.