From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Fourier Series of a Square Wave

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This VI demonstrates Fourier Series, by graphing the Fourier Series Approximation of a Square Wave. The equations used to calculate the Fourier Series were prederived.


Description
Fourier Series is a technique for decomposing any periodic signal into an infinite sum of sinusoids and a constant.  The sinusoids and constant are scaled by the Fourier Coefficients. The exact equations for Fourier Series and Fourier Coefficients can be found on Wikipedia.

Fourier Series Approximation is the reduction the infinite sum of sinusoids to a limited number, specified by the number of harmonics. By increasing the number of harmonics summed, the approximation becomes more similar to original periodic signal.

 

Requirements

Software:

  1. LabVIEW 2012

 

Steps to Implement or Execute Code

  1. Download and extract FourierSeriesEampleProject.zip
  2. Open up FourierSeriesExampleProject.lvproj
  3. Open and Run FourierSeriesOfSquareWave.vi
  4. Increment the Number of Harmonics control
  5. Observe that the Fourier Series Approximation graph more accurately constructs the Target Waveform as Number of Harmonics is increased.

 

Additional Information or References
NI Snippet

1.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Thomas C.
FlexRIO Product Support Engineer
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.