To get an pretty good idea of the maximum frequency of a square wave, calculate with fMAX = 0.45/RT10-90%.
A recent grad was once tasked with analyzing a design and determining the maximum frequency of the system. When he started looking at clocks and the various buses, he was a bit perplexed about how to report the maximum frequency of each signal. Remembering his signals and systems class, he understood that a square wave comprises the fundamental and odd harmonics, except an ideal square wave had infinite odd harmonics, and the maximum frequency of the system is finite. Inquiring, he was advised to "just use 11 harmonics." While this might be a decent approximation, it didn't sit well that he couldn't get a better approximation.
11 harmonics may be a decent estimate if all you have is schematics and datasheets to reference. If one has access to the system, one can make a reasonable estimate of the maximum frequency for each signal based on the 10-90% rise time.
Knowing the maximum frequency of the system becomes important when designing the PCB and going for compliance testing. Knowing the maximum frequency for each bus helps when estimating how much skew can be tolerated, which helps when analyzing timing diagrams and estimating how much of a length mismatch can be tolerated in traces. Quite a bit of emissions testing is based on the bandwidth of the system; knowing the bandwidth, or being able to intentionally limit the bandwidth (for instance, by setting processor pin rise/fall times) can help reduce unintentional emissions in various bands of interest.
A square wave is a non-sinusoidal periodic waveform in which the amplitude of the signal alternates between a minimum and maximum value at a steady frequency. In an ideal square wave, the amount of time spent “high” (at the maximum value) is equal to the time spent “low” (at the minimum value), and the sum of the time spent high and the time spent low is equal to the period. The implication is that when the signal transitions from high to low, or low to high, the process happens instantaneously, or the slope of the transition is infinite. This type of signal is handy for theoretical analysis, though it is not realizable. The bandwidth to create such a signal would be infinite, which requires an infinite amount of time.
A square wave is a special case of a pulse wave that allows for arbitrary durations between minimum and maximum values within the period of one cycle. The ratio of the amount of time the signal is “high” to the period of the signal is the duty cycle, expressed as a percentage of the duty cycle. A square wave is a special case of a pulse wave in which the duty cycle is 50%; that is, the signal spends as much time “high” as it does low.
Real-world square waves have a non-zero transition time between the signal's low-to-high and high-to-low states. Therefore, the bandwidth of the signal is finite; however, given the non-sinusoidal nature of a square wave, there is obscurity around the maximum frequency of the square wave. This article presents a method of estimating the bandwidth of a square wave based on typical parameters measured in electrical/electronics engineering.
Some assumptions are made when applying this formula, such as the signal is a square wave with a 50% duty cycle, and the user only needs to ballpark the spectrum the signal occupies. If you need a precise measurement, take a different approach. This approximation works fantastic when the question is, “what maximum frequency are we looking at, 100MHz, 500MHz, 1GHz?” and not, “is it 498MHz or 502MHz?”
Square Wave Parameters
Some parameters that define the square wave (that will be used throughout this writing) are:
The square wave (denoted Π(t)),
Fundamental Frequency/Frequency of First Harmonic: fo / f1 (see note below)
Rise Time: RT0-100%, RT10-90%, RT30-70%
Amplitude: A0
Maximum harmonic: N.
Number of odd harmonics: n.
A note on the fundamental frequency: Often, the fundamental frequency is referred to as “fo,” (f-naught), that is the inverse of the period of oscillation. In the Foyer transformation of the time domain square wave, f1 is the frequency of the first term, and is equal to f0. For the purposes of this article fo and f1 will both refer to the fundamental frequency of the square wave, fo used when referring to the frequency of the square wave, and f1 when referring to the first term of the Fourier series.
A note on N vs. n: N will be used to indicate the maximum harmonic, whereas n will be used to indicate the number of odd harmonics present in the Fourier transform. While this can be confusing at first, knowing N allows one to quickly calculate the maximum frequency, as fMAX = f0•N, whereas the Fourier series is expressed in a number of odd harmonics, n. Most often, we only care about the bandwidth of the signal (fMAX), but sometimes we want to know the number of odd harmonics present (n).
We start our journey with a review of the formula for the Fourier transform of a square wave.
Examining the Fourier expansion series, the following observations are made:
A square wave is expressed by a sum of scaled odd-integer harmonics.
The amplitude of each harmonic has an inverse relationship to the harmonic number. Therefore I expect a strong inverse correlation between rise time and maximum frequency.
The frequency of the square wave is the frequency of the first term in the Fourier transform, also known as the fundamental frequency.
The highest harmonic in the Fourier transform determines the maximum frequency of the square wave.
The amplitude of the sum of sinusoids is linearly proportional to the amplitude of the square wave. Therefore, the amplitude shouldn’t affect the bandwidth of the square wave.
With this in mind, let’s build a few models to gain some intuition. The first model will focus on building harmonics to match a square wave, the following models will focus on what is learned from the previous model.
First Model
The first model build generates a square wave with a non-zero transition time from low to high and high to low, and overlays the harmonic sum on top of it. The parameters of the model for the square wave include the amplitude (Ao=’A’) frequency of oscillation (f0=’B’), a non-zero rise-time (RT10-90%=’C’). For the harmonic sum, the parameters are the amplitude (4Ao/π), frequency of oscillation (f0), and the highest order harmonic to include (N).
Observations: The more harmonics included in the harmonic sum, the faster the rise time. Given a particular rise time, there is a sum with a number of harmonics that will approximate the rising and falling edges.
Question: What happens when the period (T) is changed, but the rise time (RT) stays the same?
Second Model
The second model holds everything the same as the first, except f0 is increased by a factor of 10 (the period is decreased by a factor of 10).
Observations: With the fundamental frequency increased and the rise time held constant, fewer harmonics are required to approximate the slope of the edges. The observation then is as the ratio of the period to rise time (T:RT) increases, more harmonics are required to create the slope of the rising edge. As the ratio decreases, fewer harmonics are required to create the slope of the rising edge.
Intuition Derived
From examining the equations and the two models, the assumptions to move forward with are:
A square wave is expressed by a sum of scaled odd-integer harmonics.
The frequency of the square wave is the frequency of the first term in the sinusoidal expansion.
The highest harmonic determines the bandwidth of the square wave.
The more harmonics included in the harmonic sum, the faster the rise time.
Given a particular rise time, there is a harmonic sum with a number of harmonics that will best approximate the rising and falling edges.
For a given fundamental frequency, the larger the T:RT ratio, the more harmonics are present in the square wave, which increases the maximum frequency.
The amplitude of the sum of sinusoids is linearly proportional to the amplitude of the square wave. Therefore, the amplitude shouldn’t affect the bandwidth of the square wave.
From the intuition built, there are three parameters to play with for more information: the amplitude (Ao), frequency (fo), rise time (RT10-90%), and the number of harmonics in the harmonic sum (N).
The parameters to explore are:
Changing amplitude with fixed frequency and rise time to rule out amplitude dependence.
Changing rise time with fixed frequency and amplitude to model the number of harmonics vs. the T:RT ratio.
Change the frequency and rise time, keeping the T:RT ratio constant, to verify the model.
Let’s build a model with some real numbers and adjust only the amplitude to see the effect the amplitude on the bandwidth of the signal. The square wave built has the following parameters: Ao=[1, 10, 100], fo=1MHz, RT10-90%=10ps, T:RT=100. Then multiple harmonic sums will be generated, and the least-squares method described above will be used to find the “best-fit” harmonic sum. If the best fit for all 3 includes the same number of harmonics, the conclusion is the amplitude, indeed, does not have an effect on the bandwidth of the signal.
The graphs below show for each of the amplitudes examined, the best fit for a square wave with frequency 1MHz and 10-90% rise time of 10ps, the harmonic sum that best approximates the square wave has odd harmonics out to the 41st harmonic.
The plot for approximation error is derived with the formula below, and shows the most accurate approximation in all three cases is a harmonic sum with a maximum harmonic N=41.
The model uses a square wave with amplitude A0=1, frequencies f0=[1MHz, 10MHz, 100MHz], a RT10-90%=1ps, creating T:RT ratios of 1000, 100, and 10. The graphs below show the best fit harmonic sum for each of the three square waves generated.
Observations:
For f0=1MHz, RT10-90%=1ns (T:RT=1000), N=423 was found to be the best fit, giving BW=423MHz.
For f0=10MHz, RT10-90%=1ns (T:RT=100), N=41 was found to be the best fit, giving BW=410MHz.
For f0=100MHz, RT10-90%=1ns (T:RT=10), N=3 was found to be the best fit, giving BW=300MHz.
The bandwidth appears to have a significant dependency on the rise time, and less on the fundamental frequency.
Examining the three conditions, the 1MHz and 10MHz models appear to have approximately the same spectrum, leaving the 100MHz model as an outlier. However, looking at how well the harmonic sums fit the 1MHz and 10MHz models vs. the 100MHz model may explain the discrepancy.
This model uses a square wave with amplitude A0=1, frequency f0=1MHz, RT10-90%=[1ps, 10ps, 100ps], creating T:RT ratios of 1000, 100, and 10.
Observations:
For T:RT=1000, N=423 was found to be the best fit, giving BW=423MHz.
For T:RT=100, N=41 was found to be the best fit, giving BW=41MHz.
For T:RT=10, N=3 was found to be the best fit, giving BW=3MHz.
In all 3 cases, the rise time is 1ps.
The bandwidth appears to have a significant dependency on the rise time, and less on the fundamental frequency.
This model uses a square wave with amplitude A0=1, frequency f0=[1kHz, 1MHz, 1GHz], RT10-90%=[10us, 10ps, 100ps], creating T:RT=100 for all three models. In each case, the best fit harmonic sum is found to be the same.
Observations:
For f0=1kHz, RT10-90%=10us, (T:RT=100), N=41 was found to be the best fit, giving BW=41kHz.
For f0=1MHz, RT10-90%=10ns, (T:RT=100), N=41 was found to be the best fit, giving BW=41MHz.
For f0=1GHz, RT10-90%=10ps, (T:RT=100), N=41 was found to be the best fit, giving BW=41GHz.
So now there’s evidence to suggest that the bandwidth of the square wave is dependent only on its rise time. That is, the highest frequency component is dependent on the rise time. Perhaps it's time to brute-force a solution with a little more elegance.
Going back to the main formula, some understanding can be derived from analyzing the highest frequency component of an ideal square wave. A few things stand out: The contribution of each next odd harmonic has less influence than the one before it, the highest harmonic is infinite in frequency with zero amplitude, and the only way to get the rise time is to include the contribution from every harmonic.
As with the ideal case, the real-world square wave rise time is set by the highest frequency component in the harmonic sum. Therefore a mathematical relationship between the slope of the rising edge and the number of odd harmonics (and maximum frequency!) should exist. The graph below illustrates the contribution each odd harmonic has on the slope of the rising edge of the signal.
There is a strong inverse relationship between the amplitude contribution of each harmonic to the harmonic number, which leads me to believe there's at least an approximate inverse relationship between the rise time of the signal and maximum bandwidth (I mean, obviously, it's written right there in the Fourier transform).
The code used to generate the harmonics sums above can be modified slightly to generate harmonic sums with known frequency spectrums. The 10-90% rise time can be measured for each sum generated creating a table of relationships between the fundamental frequency, number of harmonics, rise time, and maximum frequency. From this table, the relationship between maximum frequency and rise time can be explored.
Harmonic sums were generated for N=25 through N=501 and there appears to be a close relationship between the maximum frequency and rise time.
From the work done up to this point:
There is a strong correlation between the maximum frequency and rise time of the signal (Generating Models to Reverse-Engineer Spectrum).
The maximum frequency is amplitude-independent (Models for Amplitude Effect on Signal Bandwidth).
There is an outstanding question regarding the dependence on the maximum frequency and the T:RT ratio. It is theorized that the discrepancy was related to the harmonic sum fit for low T:RT ratios (Models for Changing Rise Time).
The dataset above shows a very strong inverse relationship between the maximum frequency and rise time. Now that the automation is worked out (and because I want a break from writing this), what if we generated harmonic sums ranging from N=3 to N=10,001, for f0=1kHz, f0=1MHz, and f0=1GHz to find a relationship and verify the assumption made about the harmonic fit? Well, it turns out the bandwidth of a square wave depends on the rise time alone!
The models generated show a strong inverse correlation between rise time and bandwidth, independent of frequency. However, it's not a perfect inverse relationship. Taking the data and empirically manipulating the coefficient to find a "best fit" inverse relationship leads to the formula:
From the data provided, it's apparent the maximum frequency of a square wave is dependent on the rise time of the signal! A reasonably accurate estimate of the maximum frequency can be determined by measuring the 10-90% risetime and using the formula fMAX = 0.45/RT10-90%.