The objectives that we want to accomplish in this article are to examine the frequency spectrum of signals and emphasize filtering by a second-order filter circuit using the ADALM2000 Active Learning Module connected to a host via Scopy application software and the ADALP2000 Analog Parts Kit.
The frequency spectrum is a representation of a time domain waveform on voltage versus frequency axis. Here we are showing both a 1kHz, 5V amplitude sinewave in the time domain and its representation in the frequency domain (or its frequency spectrum).
This is the voltage versus time graph.
The sine wave with frequency 1kHz and 5V amplitude is represented on the spectrum by a single spike at a frequency of 1kHz, having an amplitude of approximately 5V.
Any single spike on a frequency spectrum represents a sine wave in the time domain.
Now let’s look at a similar, but more complicated waveform. Here we’re adding 2 sinewaves together, a 1kHz, 2V sinewave shown in orange color and a 2kHz, 2V sinewave shown in purple.
The green curve is the summation of both orange and purple curves. So, at any time we can obtain the green curve by adding the 1kHz sinewave amplitude and 2kHz sinewave amplitude.
Here we are showing the spectrum of the sum of the two sine waves (spectrum of the green curve).
You can see, as you might expect, it is composed of two sinusoidal waveforms, one at 1kHz with amplitude 2V and one at 2kHz with amplitude 2V.
The spectrum is indicating that the somehow more complicated waveform is obtained by adding two sinewaves together (one at 1kHz and one at 2kHz).
Here, we are showing both a square wave in the time domain and a partial representation of its frequency spectrum.
Looking at the spectrum of the signal, there will be an infinite number of sinusoidal components that must be combined to give us the square wave in the time domain.
The component at 1kHz is known as the fundamental, the one at 3kHz is the third harmonic (three times the frequency of the fundamental at 1kHz), at 5kHz the fifth harmonic, at 7kHz the seventh harmonic, at 9kHz the ninth harmonic, etc.
Now let’s suppose we have 5 function generators: one generating a 1kHz sinewave with amplitude 5V, one generating 3kHz with a smaller amplitude, one for 5kHz, one for 7kHz and one for 9kHz. We take the output of each function generator and add them with, let’s say an op-amp summing circuit. Then the output will approximate the square wave. We will need many more components to make a better approximation of the desired square wave output.
Here we are showing how increasing the number of sinewaves to generate the approximation affects the shape of the square wave in the time domain.
For example, the orange curve is formed by adding the 1kHz fundamental sinewave with the third and fifth harmonic. You can observe that adding three sinewaves is already a reasonable approximation to a square wave.
The purple curve represents a better approximation by adding the first 5 spectral components. Therefore, by adding further spectral components we can reach an almost ideal square wave.
Now, let’s look at the following circuit schematic:
This represents an op-amp circuit known also as a Relaxation Oscillator. This circuit produces an output with no signal input. The only input to the circuit is the DC voltage to supply power to the op-amp. When the Power Supply is turned on, at the output a square wave will be produced, that oscillates between V+ rail and V- rail of the op-amp. The frequency of the square wave is related to the time constant set by R3 and C1. It is a simple circuit to build and you can determine experimentally the values to produce the square wave of the frequency that you need. The square wave can be used, for example, as input to a MOSFET switch, turning something on/off.
But, let’s say that you want to generate a sinusoidal output voltage instead of a square wave. We can think of the square wave in terms of its spectrum, where it is composed of individual sine wave components. If we apply the square wave to the input of a bandpass filter where we filter out (using an ideal filter) the fundamental component and eliminate the additional spectrum components.
Well, then at the output of the bandpass filter, because the spectrum now consists of a single spike on the frequency spectrum, we know that there will be a sinusoidal waveform. So, by bandpass filtering a square wave we can generate a sine wave. If we bandpass filter the third harmonic, we will obtain a sinewave at 3kHz, for the fifth harmonic we obtain a 5kHz harmonic, and so on.
Now, let’s have a look at the setup that is going to be made. The 1kHz square wave that we generate using the relaxation oscillation will serve as input for a Sallen-Key bandpass filter.
The components of the filter will be determined in such a manner that the central frequency will be 1kHz.
Then we will look frequency spectrum and the signal in the time domain at the input of the filter and we will also look at spectrum and time domain waveform at the output of the filter to see how filtering affects the square wave.
As the measurements are made, we are going to investigate the figure of merit known as the total harmonic distortion (THD). The THD is a numerical indicator of the amount of distortion in a sine wave.
A pure sine wave having a frequency spectrum consisting of a single spike would have a THD equal to 0.
In the formula, v2 is the voltage of the second harmonic, v3 is the voltage of the third harmonic, etc. So, a pure sine wave will have no upper harmonics so the numerator in the formula will be 0, therefore THD will be 0, indicating a pure sine wave with no distortions.
In this application that we are talking about, the conversion of a square wave into a sine wave, we can consider that square wave to be a highly distorted 1kHz sine wave, therefore the THD will be non-zero.
As we filter the fundamental component through one bandpass filter we expect that the harmonic components to be attenuated. Cascading multiple bandpass filters, we expect that the harmonic components to go to zero and the THD of our waveform would approach 0%.
Moving to the experimental analysis, here is the constructed circuit.
On the left side is the relaxation oscillator having the output applied to a Sallen-Key bandpass filter constructed on the right side of the breadboard. At the input of the filter, instead of using a constant resistance value, a good practice is to use a potentiometer in order to adjust the central frequency of the filter.
Let's first use the Network Analyzer from Scopy to generate a Bode Magnitude and Phase plot for a Sallen-Key bandpass filter.
As the Network Analyzer runs, it applies sine waves to the input of the filter, measures the output sine wave and then calculates the gain at each of these frequencies. You can see that magnitude plot is a bandpass filter centered at around 1kHz.
Now let’s examine the output of the relaxation oscillator both on the oscilloscope and using the spectrum analyzer to display the frequency spectrum.
There is the approximatively 1kHz square wave with a peak-to-peak amplitude of around 8V (using an op amp which is not rail-to-rail).
On the spectrum analyzer, the output is the frequency spectrum of the relaxation oscillator.
There is the fundamental component at 1kHz and the upper level harmonics. (at 3kHz, 5kHz, 7kHz, 9kHz).
Now let’s take the relaxation oscillator output and apply it to the input of the bandpass filter and examine the output of the bandpass filter.
In orange is the input of the bandpass filter and the output is in purple. You can see just by filtering through a single second-order bandpass filter centered at 1kHz, the output is approaching the shape of a sine wave.
If we are performing a spectrum analysis on the output of the filter we can see a behavior somehow expected.
On this scale, the fundamental component is already much larger than the distortion components (the 7kHz and 9kHz are almost zero). You can see that the 3kHz and 5kHz components are still present and their effect can be noticed on the time domain plot (distorted sine wave).
If we cascade another bandpass filter with 1kHz central frequency at the output, we can produce a signal much closer to an ideal sine wave. In the frequency spectrum you will essentially have only the fundamental and the THD will reach almost 0%.
To sum up, during this article we looked at how a real circuit can be used to extract a sinusoidal component from a square wave input by introducing the frequency spectrum of signals.
Note: The plots were made using the ADALM2000 - Advanced Active Learning Module and Scopy. The circuits were drawn using LTspice tool.