element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Digilent, a National Instruments Company
  • Products
  • Manufacturers
  • Digilent, a National Instruments Company
  • More
  • Cancel
Digilent, a National Instruments Company
Blog Use Analog Discovery 2 to create harmonics and look at its spectrum
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Digilent, a National Instruments Company to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: alexwonglik1
  • Date Created: 12 May 2020 5:52 AM Date Created
  • Views 2234 views
  • Likes 3 likes
  • Comments 1 comment
  • harmonics
  • waveforms
  • signal
  • scope
  • waveform generator
  • test and measurement
  • usb scope
  • digilent
  • fourier
  • test instrumentation
  • fft
  • test instrumentation:
  • analog discovery 2
  • fast_fourier_transform
  • analog discovery
  • instrument
  • oscilloscope.
Related
Recommended

Use Analog Discovery 2 to create harmonics and look at its spectrum

alexwonglik1
alexwonglik1
12 May 2020

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.

image

 

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.

image

 

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

 

image

 

Next, you open Digilent WaveForms and choose WaveGen (Waveform / Signal Generator) in the Welcome Tab.

 

imageimage

 

In the Wavegen tab, you need to go through the following steps to generate harmonics

  1. Choose custom mode and click new.
  2. 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.
  3. 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]);

image

 

Look at the harmonic spectrum through Analog Discovery 2 Oscilloscope

 

First, you choose Scope in the Welcome tab.

image

Then, you pick the following options in the scope

  1. Trigger options : source - Channel 1, condition - rising, level - 0V
  2. Time options : position : 0s, base : 1ms/div
  3. Disable Channel 2 by unchecking its box
  4. Channel options : offset : 0V, range : 500mV/div, Click on the gear button and uncheck the Noise checkbox.
  5. Click on View and choose FFT. Start the FFT from 0Hz to 50KHz. Choose the magnitude from -80dBV to 0dBV

 

imageimage

 

Read the step by step guide and see more examples of signals in Digilent Wiki.

  • Sign in to reply

Top Comments

  • kkazem
    kkazem over 5 years ago +2
    Excellent simulations and discussion of harmonics and Fourier Transforms
  • kkazem
    kkazem over 5 years ago

    Excellent simulations and discussion of harmonics and Fourier Transforms

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube