# Using the Analog Discovery 2 to Measure Harmonics in a Signal

Every periodic signal can be described as a sum of sine waves with different frequencies, amplitudes and phase shifts. This raises the possibility of synthesizing signals with sine waves and analyzing all kind of signals to determine the sine waves that makes up those signals. Decomposition of the signal shape (data in time domain) to the sine waves that make up the signal (data in frequency domain) is done by using an FFT (Fast Fourier Transform). This algorithm is implemented in Digilent WaveForms. Frequencies of the sine waves are strictly described. Every periodic signal has its own frequency called a base frequency. It is equal to the frequency of the first sine wave. 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 base frequency. The index of a sine wave is called the harmonic. This guide shows how to measure harmonics in a specific signal with the Analog Discovery 2 using an FFT in Digilent WaveForms.

### Inventory

• A computer with a USB port to run the software

### Set Up

#### Hardware

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).

#### Software

Next, open WaveForms. The WaveGen instrument will be used to generate signals, and the Scope instrument will be usedobserve the shapes of the signal and measure its harmonics (FFT).

1. To launch the waveform generator, click on the WaveGen button
2. Switch to the custom mode
3. Click on New, and paste the code below into the text box
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]);

Different shapes of signals can be generated by modifying the amp and phase values. Click the generate button to generate shapes.

1. To launch the oscilloscope, click on the Scope button.
2. Trigger options : source - Channel 1, condition - rising, level - 0V
3. Time options : position : 0s, base : 1ms/div
4. Disable Channel 2 by unchecking its box
5. Channel options : offset : 0V, range : 500mV/div, Click on the gear button and uncheck the Noise checkbox.
6. Click on View→FFT to show FFT window
7. FFT options : Start : 0Hz, Stop : 50kHz, Top : 0dBV, Bottom : -80dBV

### Measurements

Custom test vector, amplitude values from 0 to 1 (0-100%):

FFT of signal generated in the Analog Discovery 2 Wave Generator:

Results of the FFT broken down into frequency, harmonic, decibel level, voltage and percentage compared to base frequency:

Frequency Harmonic Level[dBV] Voltage[V] Compared to Base frequency[%]
1 1 -2.4 0.76 100.00%
3 3 -12.0 0.25 33.11%
5 5 -16.5 0.15 19.72%
7 7 -19.5 0.11 13.96%
9 9 -21.6 0.08 10.96%

### Examples of Other Waveforms

WaveGen settings are as follows: Simple, Sine, Frequency: 500 Hz, Amplitude: 1 V, Offset: 0 V, Symmetry: 50 %, Phase: 0 degrees

Oscilloscope settings are as follows: Repeated, normal, channel 1, rising edge, 0V

Time settings are position: 0 V and Base: 500 us/div

Channel 1 setting are Offset: 0 V offset and Range: 500 mV/div

FFT settings are Start: 0 Hz, Stop: 50 Khz, Top: 0 dB, Bottom: -80 dB

WaveGen settings are as follows: Simple, Triangle, Frequency: 1 KHz, Amplitude: 1 V, Offset: 0 V, Symmetry: 20 %, Phase: 0 degrees

Oscilloscope settings are as follows: Repeated, normal, channel 1, rising edge, 0V

Time settings are position: 0 V and Base: 1ms/div

Channel 1 settings are Offset: 0 V offset and Range: 500 mV/div

FFT settings are Start: 0 Hz, Stop: 50 Khz, Top: 0 dB, Bottom: -80 dB

WaveGen settings are as follows: Custom waveform

Oscilloscope settings are as follows: Repeated, normal, channel 1, rising edge, 0V

Time settings are position: 0 V and Base: 1ms/div

Channel 1 settings are Offset: 0 V offset and Range: 500 mV/div

FFT settings are Start: 0 Hz, Stop: 50 Khz, Top: 0 dB, Bottom: -80 dB

WaveGen settings are as follows: Custom waveform

Oscilloscope settings are as follows: Repeated, normal, channel 1, rising edge, 0V

Time settings are position: 0 V and Base: 1ms/div

Channel 1 settings are Offset: 0 V offset and Range: 500 mV/div

FFT settings are Start: 0 Hz, Stop: 50 Khz, Top: 0 dB, Bottom: -80 dB

## Next Steps

For more guides on how to use the Analog Discovery 2, return to the device's Resource Center.