This post shows how to create harmonics in a specific signal with the Analog Discovery 2Analog Discovery 2 and look at the spectrum through FFT mode. We will use the Oscilloscope and Waveform / Signal Generator instruments in Analog Discovery 2.
Basic Ideas for Harmonics and Fast Fourier Transform
A harmonic is a signal whose frequency is an integral multiple of the frequency of some reference signal. Every periodic signal has its lowest frequency which is called fundamental frequency. The further sine waves each are the base frequency multiplied by a specific index. For example the second sine wave's frequency is equal to 2 multiplied by the fundamental frequency.
The Fourier transform (FT) decomposes a signal into its constituent frequencies and shows that any signal can be re-written as the sum of sinusoidal functions. It is also a mathematical method for transforming a function of time into a function of frequency , i.e. transforming from the time domain to the frequency domain. The Fast Fourier transform (FFT) computes the Discrete Fourier transform (DFT) of a sequence.
Create Harmonics with Analog Discovery 2 Waveform Generator
The first step is to connect the Analog Discovery 2 to your computer. Connect 1+ (oscilloscope positive input, orange wire) to W1 (waveform generator output, yellow wire) and 1- (oscilloscope negative input, orange and white wire) to GND (ground, black wire).
Next, you open Digilent WaveForms and choose WaveGen (Waveform / Signal Generator) in the Welcome Tab.
In the Wavegen tab, you need to go through the following steps to generate harmonics
- Choose custom mode and click new.
- Choose math tab in the new box. Copy and paste the below javascript code in the script box. Adjust the phase value (ph) and amplitude (amp) to create different shapes of harmonics.
- Push the generate button to create harmonics
waveform generator code var amp = [1,0,0,0,0,0,0,0,0,0]; //amplitude values from 0 to 1 (0-100%) var ph = [0,0,0,0,0,0,0,0,0,0]; //phase values from 0 to 1 (0-360 degrees) Y = amp[0] * sin((1 * 2*PI*X) + 2*PI*ph[0]) + amp[1] * sin((2 * 2*PI*X) + 2*PI*ph[1]) + amp[2] * sin((3 * 2*PI*X) + 2*PI*ph[2]) + amp[3] * sin((4 * 2*PI*X) + 2*PI*ph[3]) + amp[4] * sin((5 * 2*PI*X) + 2*PI*ph[4]) + amp[5] * sin((6 * 2*PI*X) + 2*PI*ph[5]) + amp[6] * sin((7 * 2*PI*X) + 2*PI*ph[6]) + amp[7] * sin((8 * 2*PI*X) + 2*PI*ph[7]) + amp[8] * sin((9 * 2*PI*X) + 2*PI*ph[8]) + amp[9] * sin((10 * 2*PI*X) + 2*PI*ph[9]);
Look at the harmonic spectrum through Analog Discovery 2 Oscilloscope
First, you choose Scope in the Welcome tab.
Then, you pick the following options in the scope
- Trigger options : source - Channel 1, condition - rising, level - 0V
- Time options : position : 0s, base : 1ms/div
- Disable Channel 2 by unchecking its box
- Channel options : offset : 0V, range : 500mV/div, Click on the gear button and uncheck the Noise checkbox.
- Click on View and choose FFT. Start the FFT from 0Hz to 50KHz. Choose the magnitude from -80dBV to 0dBV
Read the step by step guide and see more examples of signals in Digilent Wiki.
Top Comments