Square waveform generator on multivibrator Fourier decomposition - Page 1
Forum section: electronics / beginners

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 22, 2022, 04:24:34 pm
content: Hello, just getting into electronics without much math background.I now try to understand the principles of square waveform generation in electronics and have a mix of garbage in my mind due to the overwhelming amount of information.First of all - I don't even know how to properly formulate my question and you can see I have a mix of concepts that I can't figure out how to put them together. Help me out please.The concepts that I try to marry are:- Square waveform generation using the multivibrator- Fourie analyses of the generated square waveform- Let's start from the second concept. If we want to generate a square waveform we can apply the harmonic composition principle and by using an infinite number of odd harmonics to approximate the square wave.Is that how the popular waveform generators produce square waveforms? For instance a popular budget UNI-T UTG962E.If so how is the square waveform actually generated? Does UTG962E have (in the IC form) an array of sine wave cascades that produces the square wave by composition of the odd sine wave harmonics?- Now we are up to the first concept. For instance an Astable Multivibrator circuit can produce the square waveform but as far as I understand it has nothing to do with the sine waves composition. What would Fourier analysis show us for this generator?At this point I'm really stuck and I let you get me out of this potentially deep misconception of the whole matter. Hope you can sort it out for me.

author: mag_therm
author_rank: Frequent Contributor
timestamp: September 22, 2022, 04:38:03 pm
content: A diagram of square wave and its components by superposition is here:https://www.mathsisfun.com/calculus/fourier-series.html

author: ledtester
author_rank: Super Contributor
timestamp: September 22, 2022, 04:46:15 pm
content: Function generators like the UTG962E have a DAC -- digital to analog converter -- which take a digital value (like a 8 bit or 12 bit word) and converts it into a voltage. The shape of the wave is stored in memory and the function generator feeds the DAC from this memory at a speed of like 200 MHz.Pseudo code for a table of 8192 values:Code:do forever:for i = 0 to 8191:set DAC input to tableend forend doTo get the different wave forms you just populate the table with the shape of the wave.An explanatory video using an Arduino:Direct Digital Synthesis - How DDS Works and an Arduino Example -- Gadget Reboothttps://youtu.be/WwHouxujrNc

author: MrAl
author_rank: Super Contributor
timestamp: September 22, 2022, 04:52:27 pm
content: Quote from: VSV_electron on September 22, 2022, 04:24:34 pmHello,Square waves can be generated from a mix of harmonics but for the usual generator they would simply turn a transistor on and off.To analyze a square wave using Fourier analysis you would integrate over the wave from start to finish.To generate a square wave using a large number of harmonics you would simply add them together with each having the right amplitude. The harmonics would all be odd.There is one interesting deviation to this though, and that is that the square wave generated by harmonics would not really be a true square wave. It would have 'ears' that never go away no matter how many harmonics you mix.For more information about this check out the Gibbs Phenomenon on the web.I wrote up a more complete reply on this but this forum loses replies sometimes, very strange.

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 22, 2022, 04:53:27 pm
content: A square wave can simply be generated by turning the output on and off repeatedly.It depends on the circuit what the square wave contains in terms of harmonics. Think of capacitance and resistance that is, for instance, in the wires that make the connections, or in the components like mosfets. Charging a capacitor via a resistor takes time. This makes the rounded edges on a square wave when you look at it on a scope. The less rounding, the more harmonics there are.

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 05:09:37 pm
content: The first image is a 1 MHz square wave (more or less) and the FFT. You can see there is no DC component because there is no spike at 0 Hz and, of course, there are spikes at all the odd harmonics out to 50 MHz or so. It was generated with the Digilent Analog Discovery 2.The second image is an FFT of a composite signal (50 Hz and 120 Hz plus random noise) using MATLAB. I expect the code to work in the free GNU Octave as well.I don't learn well unless I can model something with hardware. To that end, the AD2 is the best teaching aid ever invented (IMHO) surpassing even the blackboard.It is well worth the time to get up to speed on MATLAB or Octave.

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 05:45:17 pm
content: Here is a simple example of building a square wave from sine waves. The blue trace contains the 1st, 3rd and 5th harmonics while the red trace adds the 7th harmonic. This is known to work in Octave, I just ran it.Since it is only 8 lines of code, it is worth installing Octave to play with it. Note the difference in amplitudes.Code:cla resett = 0:0.001:2*pi;y = 0.636620 * sin(t) + 0.212207 * sin(3*t) + 0.127324 * sin(5*t);z = 6/pi*sin(t) + 6/(3*pi)*sin(3*t) + 6/(5*pi)*sin(5*t) + 6/(7*pi)*sin(7*t)plot(t,y)hold onplot(t,z)shg

author: ledtester
author_rank: Super Contributor
timestamp: September 22, 2022, 05:59:58 pm
content: Found a Desmos interactive graph you can play around with:Square wave from sine waveshttps://www.desmos.com/calculator/uocla9yrrf

author: RoGeorge
author_rank: Super Contributor
timestamp: September 22, 2022, 06:16:00 pm
content: One can generate many ways a square voltage, for example either by:1. - repeatedly commuting the output between two fixed voltage, Vhigh and Vlow - that's how a square generator works2. - adding an infinit number of infinite sinusoidal voltages with just the right frequency, amplitude and phase - Fourier is almost never used in practice to generate signals of certain shapes. It might be used, but it is not practical.To make it all even more confusing, the two methods above are not the only ones.For example, it can also be:3. - instead of adding sin and cos waveforms (like in the Fourier methode), other function can be used (for example the Wavelet Transform, which is similar with the Fourier Transform in the sense that both WT and FT are using some basic kernel functions that, when added together, they can reproduce any desired waveform, except the WT adds together wavelets in order to produce the desired shape of a waveform).

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 22, 2022, 06:20:08 pm
content: Quote from: RoGeorge on September 22, 2022, 06:16:00 pmThere are music synthesizers that use this principle. One that I know of is the Kawai K5https://www.vintagesynth.com/kawai/kawaik5.php

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 06:32:52 pm
content: Quote from: ledtester on September 22, 2022, 05:59:58 pmDesmos.com (graphing) and Symbolab.com (solving) are my two favorite sites for messing around with math. It appears that Symbolab has embedded Desmos for graphical results.When it comes to learning math, KhanAcademy and 3blue1brown are excellent. KhanAcademy has a separate EE track in addition to their math track.If a small cost ($249/calendar year) doesn't concern you, you won't find better than CalcWorkshop.com. You go at your own speed. The sessions on Limitshttps://calcworkshop.com/limits/finding-limits-graphically/#chapteris free.When compared to the cost of tuition, the additional cost for CalcWorkshop is insignificant.There are many other resources on the web.My favorite tool is MATLAB. It has a toolkit for just about everything! The Home license isn't outrageous and toolkits are inexpensive. The annual renewal is a bit of a hit but if you can do without the updates, it isn't required.Octave is mostly compatible but it lacks the advanced features of MATLAB toolkits.

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 22, 2022, 08:27:47 pm
content: Thank you for all your replies! Let me please elaborate a little on my question above.I found a video on YT where the author demonstrated how to use an O-scope in place of a spectrum analyzer.I even asked a question in the comments but I doubt it'll get many detailed replies there. Let me duplicate my question here below. What I'm still clueless about is what the spectrum analyzer actually shows. Is it the actual decomposition of the square waveform into sinewave harmonics or just a theoretical approximation of the square wave to its representation with the FFT? I hope my question makes sense.So, here is the video:I asked the following question in the comments:"I have a potentially stupid question. What method of square wave signal generation is used in this particular case so that it can be spectrally analyzed using FFT? I must admit I'm not quite knowledgeable and have deep gaps in my education. For instance if a multivibrator is used as a the source of the square wave output signal can it be spectrally analyzed in this way? However I must admit I'm so dumb that I dare ask another question: When using the spectral analyzer does it display the real composition of the square wave input as in this case or does it on the contrary shows a theoretical representation of its input signal based on the Fourier sine wave odd harmonics composition that would give us an equivalent square wave form be that sine wave odd harmonics composition actually implemented to generate the square wave form?"Actually I see the author already answered my question but now I feel myself even more stupid.The square waveform signal that is displayed by both the real spectrum analyser and the O-scope can be generated with the 555 chip as he says. That means the output is a digital timer driven square waveform. How can it actually contain a composition of the sinewave harmonics?Let me please ask it again: does what the spectrum analyser shows us repredent the actual decomposition of the square wave signal or is it just the mathematical approximation of how we can represent the square waveform using FFT with the spectrum analyser?You see I have a fundamental misconseption about what's going on.Let me put it in a different way.A square waveform in its fumdamental pure form contains a series of periodic pulses of a certain frequency. This squre waveform is not directly associated with the sinewave unless it was composed with the Fourier series of sinewaves.So if we spectrally analyze the pure square waveform output of the 555 timer how can we see the presence of sinewave harmonics if essentially this signal was not composed that way?As such I assume the spectrum analyser in this case will show the mathematical representation of such a signal using FFT, not the real sinewave harmonic composition of this signal.Am I too far off in my understanding of the process?

author: Bud
author_rank: Super Contributor
timestamp: September 22, 2022, 08:48:23 pm
content: FFT is a mathematical method of representation of a signal, the square wave in this particular case. There may exist other methods that use different fundamental units other than sinewaves. As an example lets draw a circle on a piece of paper. This curcular shape can be approximated by bunch of little rectangles fit in it, of by bunch of little triangles or hexagons, etc. Do those rectangles, triangles or hexagons physically exist within that circular shape?

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 22, 2022, 08:59:28 pm
content: Quote from: Bud on September 22, 2022, 08:48:23 pmBud, you probably already answered my question but can you probably see where my confusion arises from?

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 09:09:25 pm
content: A square wave IS the sum of the fundamental and all the odd harmonics out to daylight (call it infinity). It's the contribution of the harmonics that square up the corners and decrease the rise/fall time. If you remove all the harmonics, you have a single sine wave at the fundamental frequency.The fact that the square wave can be described by mathematics is interesting but the physical characteristics are what matter. It's the sum of all the odd harmonics...Both displays, the scope and the spectrum analyzer, produce honest outputs within the characteristics. With a 50 MHz scope, you might see harmonics at even 100 MHz but you won't see them at 1 GHz. There are limits to the test equipment.The FFTs are generated by taking samples at some frequency and doing some math to get a measure of the voltage at some frequency.Here's an interesting video but there are dozens more re: FFT on scope:https://youtu.be/u--OsHMGMYcSince you know what to expect from the Arduino tone () function, you can take the FFT of the output, measure it and then put in some RC filtering and watch the harmonics drop off. Maybe start with the 9th harmonic, set a filter at that frequency and expect the level of the harmonic to decrease - probably by 3dB. Then increase the capacitance and watch the lower frequencies disappear until you get down to the fundamental. This does take a scope with FFT capability (and the low cost Rigol DS1054Z has it) and some parts. I would keep the series resistor at or above 1k to prevent loading the Arduino.There are a lot of videos about using scopes for FFTs.BTW, the amplitude of each harmonic is reduced by its harmonic number. You can find references all over the Internet on how to calculate the coefficients for a square wave.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 22, 2022, 09:29:53 pm
content: VSV_electron, to ease your struggle, short answer is no.The sinusoids are not really there building a 555 square wave.To reiterate theBud's explanation, which was the best analogy possible:- take a square piece of paper- you can cut that paper in 4, either:- by diagonals cut (you'll get 4 smaller triangles),- or by a cross cut (you'll get 4 smaller squares)Now, was the original piece of paper made out of 4 triangles? Or it was made out of 4 smaller squares?The answer is neither. The original square was a big square in one piece. We can build such a big square however we want, either using smaller triangles, or using smaller squares, or using some other shape of smaller pieces.Same we do with the original 555 waveform. We can think of it as a sum of sinusoids, or we can think of it as a sum of some other smaller pieces, just like with the big paper square. Fourier happens to use the sinusoidal decomposition, and we like sinusoids only because the sin and cos functions are meaningful in the physical world, and also they have some nice mathematical properties.The 555 square wave is not made out of many sinusoids. It is made out of 0V and 5V repeated over and over, but we can think of it as if it were made out of an infinitely long series of sin and cos function, if we prefer to think about it in the frequency domain.

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 09:31:06 pm
content: Quote from: VSV_electron on September 22, 2022, 08:27:47 pmThe 555 has certain switching characteristics that make it look like it produces a square wave. Well, here's news; it doesn't. A true square wave would have zero rise and fall time. To switch in zero time in the presence of capacitance requires infinite energy and it just isn't possible. We can get close but no cigar!Here is the datasheet for a 555 timer:https://www.digikey.com/htmldatasheets/production/110618/0/0/1/ne555-sa555-se555.htmlNote the rise and fall time of typically 100 ns on page 5 of 20. So the fastest square wave it can produce has a 200 ns period so call it 5 MHz (but it really can't do this!). That like watching paint set! Since it isn't a real square wave (which is only possible mathematically), it will have harmonics that terminate at a much lower frequency.Note Figure 17 on page 11 of 20 - it kind of maxes out at 100 kHz - nowhere close to the maximum based on rise/fall times (for which there really isn't a relationship).I guess the point is, mathematically, a true square wave is possible if you can get harmonics out to infinity to drive the rise/fall times down to 0. Otherwise, you are bound to the real world where things just don't go that fast. And the 555 is a special case of truly slow. There are millions of applications for the chip but generating high speed square waves isn't one of them.

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 22, 2022, 09:32:38 pm
content: Quote from: rstofer on September 22, 2022, 09:09:25 pmThank you but I again feel myself bad...Do you mean that the square wave 'CAN be represented as the sum of the fundamental and all the odd harmonics' or is it what you say and it's from your own words: 'A square wave IS the sum of the fundamental and all the odd harmonics' ?Or does it make no difference in this context?Now please let's talk about it in the context of the YT video I gave a link to above.If the square wave signal is generated by the means of a 555 timer it's a High Level-Low Level digital signal. Essentially it has no sinewave harmonics in it the way it was generated. I understand that it can be represented with the Fourier transform but in this particular case does it make any sense at all?

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 22, 2022, 09:48:00 pm
content: Quote from: RoGeorge on September 22, 2022, 09:29:53 pmSorry I haven't seen your answer while typing in my previous post.That's getting better now!However - what would be the purpose of reprresenting the square wave signal with sinewave harmonics using FFT on spectrum analyser?This is the mathematical representation, right?I probably don't understand something which is a fumdamental knowledge. That was always my problem: I don't want to accept things as they are and I always try to find something that is non-existant.If we have a complex signal, for instance some PAL TV signal would it make sense to use the spectrum analyzer in the FFT mode? Sorry I don't know if what I ask makes sense at all. Can the spectrum analyser be used in a mode other than FFT?I get lost completely.

author: ledtester
author_rank: Super Contributor
timestamp: September 22, 2022, 10:01:03 pm
content: The advantage is that it is easy to compute the effect of filters on sine waves.So if your signal is composed of sine waves, say S1+ S2+ S3, the effect of a filter is simply the sum of the filter's effect on each of the Si.

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 10:01:59 pm
content: The 555 generates something that looks like a square wave but with very slow rising and falling edges. Hence, it isn't a real square wave. The only true square wave takes infinitely many harmonics and that is only possible as a mathematical model. Even then, it requires harmonics out to infinity and there's no definition for where that's at.Don't try to conflate real signals with the mathematical construct. Real signals don't work that way. The 555 timer has a transistor to pull the output high and another transistor to pull the signal low. Q22 and Q24 in the datasheet - page 2 of 20. These alternate between conduction intervals and are certainly not capable of switching in zero time. In fact, on average, they switch in 100 ns and during that time the output voltage ramps up or down. It does not switch in zero time, it is not a true square wave.All the FFT is trying to do is determine where frequencies exist in a signal within the equipment's own bandwidth. These may be important to the designer as shown in the video I linked above. Or, we may want to know how effective a filter was at reducing harmonics. We may want to see that the 5th harmonic is so much reduced or something like that. Or maybe we want to slide another signal in the empty space between harmonics using some form of frequency division multiplexing. In fact, that application doesn't want to see harmonics from other signals. They need to be attenuated and we look at the FFT to see that.Another way to think about the FFT is that it is a mathematical technique for determining the frequency content of a signal but the signal itself is not constructed based on the Fourier series. It's just a math game!OTOH, my Siglent SDG 2082 Arbitrary Waveform Generator can produce waveforms with up to 8 harmonics and those could be the fundamental, 1st, 3rd...out to the 17th (as long as the highest frequency is within the equipment's 25 MHz bandwidth. I can set the amplitude of each harmonic from the Fourier Series. I can also set the phase relationships. This might be a square wave or any other arbitrary waveform. If you search over in Test Equipment, you might be able to find a Valentine's Day heart display on a scope based on an AWG and some clever coefficients.

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 10:28:46 pm
content: I watched the first half of the video re: FFT on spectrum analyzer and scope. First of all, he must have a pretty poor signal source because if the square wave is anywhere near correct, there won't be any even harmonics. This might be just the problem you are looking for when you start to look in the frequency domain! Something in the output spectrum that shouldn't be there. Or should be there and isn't.Second, scopes don't do a very nice job of labeling the FFT plot. In fact, they don't even try. You have to gather up the various units from the switch settings. Look back at the Analog Discovery 2 FFT I posted above. That's what I want to see.

author: rstofer
author_rank: Super Contributor
timestamp: September 22, 2022, 10:45:26 pm
content: Quote from: VSV_electron on September 22, 2022, 09:48:00 pmI don't want to get into the math because it is complex and better tutorials exist but the idea is to take a lot of samples of a signal, run the measurements through a magic FFT box and come out with a representation of the frequencies included in the signal and the amplitudes of each. The math is quite complex but you can find a LOT of videos on the subject. 3blue1brown has a video:https://youtu.be/spUNpyF58BYhttps://youtu.be/h7apO7q16V0https://www.khanacademy.org/science/electrical-engineering/ee-signals/ee-fourier-series/v/ee-fourier-series-introAnd many others...QuoteI don't know what you would see for a fast changing signal like broadcast TV.I'm not aware of any other functionality for a spectrum analyzer. Everybody has a scope, only a few have a separate spectrum analyzer.

author: CaptDon
author_rank: Super Contributor
timestamp: September 22, 2022, 11:07:17 pm
content: I have never been happy with any spectrum analyzer which uses FFT to generate the display. Look at how many different styles of FFT calculations the units give to you to choose from, each with its own anomalies!!! I have always had the best luck with the older style of swept RF and selections of IF bandwidth. We had an old Singer Metrics unit that could drive an X / Y paper plotter and could be slowed to sweep over hours so you could use the tightest IF bandwidth and not suffer from the slow response of the tight bandwidth. That old beast from the 1960's could show things about our 4 tower directional array that no FFT unit could uncover. No sensible Square Wave Generator would be designed to generate endless myriads of odd harmonics to form a square wave. It can be done easily and efficiently with on/off digital logic followed by buffers and impedance matching networks. It is interesting to note that old sinewave function generators sometimes used triangle waves pushed through shaping circuits to come up with a sinewave that was passable. However the best low distortion sinewave generators start with a sinewave and amplifiers with lots of headroom and almost zero non-linearity or THD during the amplification, buffering and impedance matching. Look to the HP line of sinewave generators and distortion analyzers for audio work. The same can be said for the Potomac Instruments line of test oscillators and analyzers. For really fast squarewaves you leave the realm of 'signal generators' and enter the realm of 'Pulse Generators' with a 50/50 duty cycle.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 22, 2022, 11:47:13 pm
content: Quote from: VSV_electron on September 22, 2022, 09:48:00 pmYes, it would make sense.For example, somebody shows you a wiggling waveform on the oscilloscope, which is the waveform of a video signal, and asks you to design a TV broadcasting station. How much radio bandwidth is needed to send that wiggling video signal? Or how far apart (in frequency) should be the next TV channel so they won't interfere with each other?For that, you would look at the spectrum representation of the wiggling waveform, and notice the spectrum goes for example from 0 to 5MHz. Now you know how much radio bandwidth is needed and how to design the TV radio transmitter.Without the Fourier transform would be much harder to know how to design electronics. Talking mostly about radio and telecommunications.However, Fourier can be useful in the digital domain, too. For example, you look at a voice signal wiggling (in time domain), then look at its spectrum (in frequency domain) and that is how you know how fast you need to sample the audio signal in order to record or playback it with a soundcard (ADC/DAC) without degrading the audio quality.Same when you want to check, for example, if an amplifier doesn't add distortions. If you look at the waveform on the oscilloscope, you might not spot any difference between the input and the output signal, but if you look with a spectrum analyzer you'll see a different spectrum at the output when compared with the input spectrum, and that is how you know there are distortions introduced by the amplifier. Even more, there are formulas to calculate the distortions factor by looking at the spectrum of the output and measuring the amplitude peaks of the harmonics.There are many other ways in which Fourier comes handy, or else we wouldn't bother using it, and we wouldn't bother building expensive instruments like spectrum analyzers (SA) or vector network analyzers (VNA).

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 23, 2022, 12:26:29 am
content: Thanks much everyone! I'm really glad there are so many of you who are willing to help me even when you see I have big gaps in my education.I'll read evrything you wrote couple times more and try to digest it. I need to go back to the math and physics fundamentals also.

author: gf
author_rank: Super Contributor
timestamp: September 23, 2022, 10:55:57 am
content: Quote from: VSV_electron on September 22, 2022, 09:32:38 pmIt does not make a difference. Think of a point in a plane. Mathematically it can be represented with e.g. cartesian coordinates, or with polar coordinates. Both representations are equivalent at the end, and describe the location of a point in a plane. Regardless how the point was placed at this location, both coordinate system types still describe the location uniquely, and cartesian coordinates can be converted to polar ones, and vice versa. Neither the one nor the other representation is "better" in general.The abstract thing you are describing here is the "signal". And the two most comon mathematical representations for a signal in EE are intensity as a function of time, or intensity as a function of frequency (-> sum of sin and cos basis functions), where the intesity can be any quantity like voltage, current, or whatsoever. (As mentioned by others, these are not the only possible representations, but there do exist some other decompositions as well, which still can describe the same signal equivalently)And the relation between time domain representation and frequency domain representation is the Fourier Transform (or inverse Fourier Transform).QuoteOne purpose, for instance:Once you recognize that the differential equations, which describe the behavior of capacitors and inductors in the time domain, turn into linear equations in the frequency domain, you'll notice that various calculations can be done much easier in the frequency domain. For instance, filters and electrical networks are predominantly considered in the frequency domain.QuoteBasically it is just a different representation of the same signal. But it is still only an approximation. Note that a Fourier Transform assumes a CONTINUOUS signal in the time- and frequency-domain, and an INFINITE time- and frequency axis. The transform can be calculated analytically for various time domain signals which can be described analytically. But you don't live long enough to observe an arbitrary unknown signal over an infinite time span, and then calculate its Fourier Transform. So in practice you must limit the observation to a finite time window. And even inside a finite time window, a continuous function still has an infinite number of data points, which is not feasible either in practice. This leads us to the the Discrete Fourier Transform (DFT), which assumes finite and discretely sampled time and frequency axes, so that you end up with a finite number of data points and the numeric calculation becomes feasible. But both, the windowing of the time line and the sampling are potential sources of errors. For instance, there will almost always be some spectral leakage (btw, even an analog non-FFT-based sweeping SA cannot have zero RBW). Like always in metrology, it is not sufficient to take any measurements for granted, but you must be always aware of potential measurement errors, and you should be able to quantify them before you decide to neglect them.BTW: FFT is actualy just a fast algorithm to calculate the DFT, but in colloquial speech it is frequently used as a synonym for DFT.

author: MrAl
author_rank: Super Contributor
timestamp: September 23, 2022, 12:00:42 pm
content: Quote from: VSV_electron on September 22, 2022, 08:27:47 pmHello again,You can actually extract the individual harmonics from the square wave by essentially filtering the rest of them out. If you do this for a bunch of single frequencies and you do it fast enough, you can display them as sharp peaks where the peak represents the amplitude of that harmonic. The type of filter you would use would be a band pass filter.This can be done in analog using a tunable analog filter or a digital filter.This can also be done mathematically by sampling the waveform, then use a Discrete Fourier Transform which works on individual samples rather than the entire waveform like an analog filter would do. The results are similar however.So the harmonics are all mixed together but you dont have to add them yourself just generate a square wave.This is a measurement technique for showing the frequency content of the waveform, but in practice some circuits will pick put some frequencies and leave out others automatically without the designer paying too much attention to this. For example, a high pass filter will filter out the lower harmonics of a square wave but pass the high frequency components. Because the high frequencies are responsible for the fast rise and fall times, a high pass filter would produce a blip up on the rise and a blip down on the fall of the square wave.

author: VSV_electron
author_rank: Regular Contributor
timestamp: September 23, 2022, 02:53:05 pm
content: Thanks again for the additional 2 messages! Lot's of food for thought.

author: adeuring
author_rank: Contributor
timestamp: September 23, 2022, 04:03:08 pm
content: Quote from: VSV_electron on September 22, 2022, 08:27:47 pmQuoteFor some purposes it makes sense to think of a square wave as being composed of sine waves, for other purposes it makes more sense to keep the simple "on/off model" for the suqre way. Both "models" can be useful to understand certain effects.An example where it makes sense to think of the square wave as being composed of sine wawes: Radio receivers tune to sinusoidal waves. If you have an AM receiver and if you can find a AM station that is still operating, you could try this with an NE555 square wave generator:1. Tune the AM radio to this still operating station.2. Build an NE555 circuit that generates a square wave with the same frequency as the AM station and connect a somewhat lengthy wire (say, 0.5m or 1m) as a crappy antenna to the NE555 output.3. Set the NE555 frequqncy to 1/3 of the AM radio station frequency and listen again to the radio.4. repeat step 4 with the NE555 set to 1/5 of the AM station's frequency.(steps 2 to 4 may require some tricky fine tuning of the NE555 frequency.)Provided that the NE555 circuit's frequency is properly tuned, the radio station signal wil be seriously distorted because the radio receiver "sees" the sinusoidal components of the square wave generated by the NE555. This happens even though there are no sinusoidal oscillators inside the NE555. Instead, the radio receiver "responds" to the sinusoidal components of the square wave.For other purposes it is better to keep the simple "square model" of the NE555 output. You do this for example when you try to design or understand a digital circuit.QuotePeople familiar with fourier analysis already know how the fourier decomposition of a square wave looks like. I think the main idea of the video is to demostrate what a spectrum analyser or the FFT function of a DSO does

author: TimFox
author_rank: Super Contributor
timestamp: September 23, 2022, 05:52:24 pm
content: In practice, it is much easier to "analyze" a square wave into its fundamental and harmonic components than to "synthesize" a square wave from sinusoidal components.Mathematically, the analysis and synthesis are straightforward.Note that when synthesizing a square wave, the sinusoidal components must be coherent (i.e., synchronized from a common timing source) and the phase relationship between the components is critical to obtain a good square wave.In the middle of the 19th century, Helmholtz was not interested in square waves, but did some important experimental synthesis of complex musical notes from harmonically-related tones.His synthesizer comprised multiple acoustic "Helmholtz resonators" driven by a vibrating needle-mercury contact for coherence.

author: RJSV
author_rank: Super Contributor
timestamp: September 23, 2022, 08:48:06 pm
content: A square wave is created, almost always, by simple timing of a digital switch, meaning the switch goes fully on...or fully off. So, for a 1 hz example, you time 500 millisec, then switch states, so doing that twice will get you one complete cycle.In theory, those turn on and turn off actions are fast, taking 'zero' time, so, of course, a completely perfect generation is not happening.

author: RJSV
author_rank: Super Contributor
timestamp: September 23, 2022, 09:44:23 pm
content: My picture shows two different rise time situations. Fourier was concerned with that rising waveform, saying that a faster rise, or increase in voltage, (seen by load), is characterized by more and more high frequency 'content', to the point where a 'zero' rise time, representing an infinite speed (of change), actually would contain an infinite number of representative frequencies. Notice, on the faster variation, I've put some 'ringing' on the waveform. Intuitively, that could indicate that you've stimulated the receiving SYSTEM, much like striking a metal plate produces ringing.The Fourier folks also like to discuss 'IMPULSES', where an ideal impulse is short (think zero time duration).But I've always seen the Fourier stuff as mostly analysis, of content; that would be a switch generated Square wave, with a content analysis. So the waveform generation is fairly simple (timing), and the analysis of waveforms is where you'd get all those (Fourier) terms, such as 2nd harmonic etc.Now, however, there are some cases where the generation aspect is utilized: See Schober Organ Co.That musical technology uses 'Sawtooth' shaped generators, combined Fourier style, where the multiple sawtooths add together to produce a variety of tone shapes. Those are put together with each starting sawtooth at multiples of the original base note.Such as A-440 plus 880 hz plus 1760 hz etc.But usually, Fourier stuff is for analyzing some existing waveform, for what content is found.As to the 'overshoot and ringing' effects, I believe those are effectively reduced by way of holding a lower limit, on speed of rise. The FCC looks at things related, such as requiring a FERRITE bead or donut. The effect is to control or limit the rise speed, and thus the Frequency energy content. A bead would effectively reduce radio emissions, that interfere with various radio device use.It's counter-intuitive, to be discussing and analyzing some 'Impulse Response', when that impulse is infinitely small. But the mathematics works, partially in that abstract, but with real world results.You might also encounter a lot of Fourier analysis in the application of Vibration Table testing, where the 'signal' is of motion and acceleration parameters.

author: RJSV
author_rank: Super Contributor
timestamp: September 23, 2022, 09:45:43 pm
content: Picture of typical (first part) of square wave.