Differences

This shows you the differences between two versions of the page.

Link to this comparison view

test-and-measurement:analog-discovery-2:demos:measuring-harmonics [2022/09/12 15:52] – changed forum.digilentinc.com to forum.digilent.com jeff.greenberg_ni.comtest-and-measurement:analog-discovery-2:demos:measuring-harmonics [2022/10/04 11:38] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Using the Analog Discovery 2 to Measure Harmonics in a Signal ======
 +
 +~~TechArticle~~
 +
 +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.
 +
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_1.jpg?400 |}} {{ :learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_2.jpg?400 |}}
 +
 +----
 +
 +==== Inventory ====
 +
 +  * A computer with a USB port to run the software
 +  * [[https://digilent.com/shop/software/digilent-waveforms/|WaveForms Software]]
 +  * [[https://digilent.com/shop/analog-discovery-2-100ms-s-usb-oscilloscope-logic-analyzer-and-variable-power-supply/|Analog Discovery 2]]
 +
 +
 +----
 +
 +
 +==== Decomposition of the square wave ====
 +
 +<WRAP group> <WRAP column half> 
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_3.jpg?600 |}}
 +</WRAP> </WRAP>
 +
 +
 +----
 +
 +==== Set Up ====
 +
 +=== Hardware ===
 +<WRAP group> <WRAP column half>
 +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).
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_4.jpg?400 |}}
 +</WRAP> </WRAP>
 +----
 +=== 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).  
 +
 +<WRAP group> <WRAP column half>
 +  -To launch the waveform generator, click on the //WaveGen// button
 +  -Switch to the //custom// mode 
 +  -Click on //New//, and paste the code below into the text box
 +<code>
 +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]);
 +</code>
 +Different shapes of signals can be generated by modifying the amp and phase values. Click the generate button to generate shapes. 
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_7.jpg?600 |}}
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_8.jpg?600 |}}
 +</WRAP></WRAP>
 +<WRAP group> <WRAP column half>
 +  -To launch the oscilloscope, click on the //Scope// button.
 +  -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->FFT** to show FFT window
 +  -FFT options : Start : //0Hz//, Stop : //50kHz//, Top : //0dBV//, Bottom : //-80dBV//
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_11.jpg?300 |}}
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_21.jpg?800 |}}
 +</WRAP></WRAP>
 +
 +----
 +====Measurements====
 +
 +<WRAP group> <WRAP column half>
 +Custom test vector, amplitude values from 0 to 1 (0-100%):
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_20.jpg?400 |}}
 +</WRAP> </WRAP>
 +
 +<WRAP group> <WRAP column half>
 +FFT of signal generated in the Analog Discovery 2 Wave Generator:
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_19.jpg?400 |}}
 +</WRAP> </WRAP>
 +
 +<WRAP group> <WRAP column half>
 +Results of the FFT broken down into frequency, harmonic, decibel level, voltage and percentage compared to base frequency: 
 +</WRAP> <WRAP column half>
 +^ 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%        |
 +</WRAP> </WRAP>
 +
 +
 +----
 +==== Examples of Other Waveforms ====
 +----
 +<WRAP group> <WRAP column half>
 +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
 +
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_15.jpg?600 |}}
 +</WRAP> </WRAP>
 +----
 +<WRAP group> <WRAP column half>
 +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
 +
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_17.jpg?600 |}}
 +</WRAP></WRAP>
 +----
 +<WRAP group> <WRAP column half>
 +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
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_16.jpg?600 |}}
 +</WRAP></WRAP>
 +----
 +<WRAP group> <WRAP column half>
 +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
 +</WRAP> <WRAP column half>
 +{{:learn:instrumentation:tutorials:analog_discovery_2_measuring_harmonics:analog_discovery_2_fft_18.jpg?600 |}}
 +</WRAP></WRAP>
 +
 +----
 +===== Next Steps =====
 +
 +For more guides on how to use the Analog Discovery 2, return to the device's [[test-and-measurement/analog-discovery-2/start|Resource Center]].
 +
 +For more information on WaveForms visit the [[software:waveforms:waveforms-3:reference-manual|WaveForms Reference Manual]].
 +
 +For more information of FFT's visit [[http://www.bores.com/courses/intro/freq/3_ft.htm|Bores Signal Processing]]
 +
 +For technical support, please visit the [[https://forum.digilentinc.com/forum/8-test-and-measurement/|Test and Measurement]] section of the Digilent Forums.
 +
 +{{tag>learn instrumentation project analog-discovery-2 ad2 }}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +