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

Displaying the Frequency Values of the FFT peaks processed by the Spectral Measurements VI

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 shows how to extract the correct frequency values from the output of the Spectral Measurements VI


Description

This VI demonstrates how to display the frequency value(s) of the peaks formed by taking the FFT of a signal(s) with the Spectral Measurements VI.  Using the Detect Peaks VI alone will not always retrieve the correct frequency value, especially when manipulating multiple signals that contain different frequency resolutions (df) and/or different start frequencies (f0).

In the attached example, three sine waves of different frequencies serve as the input signal to the Spectral Measurements VI. The output of the Spectral Measurements VI is an array of clusters; each cluster in the array represents one of the three sine waves.  It is necessary to unbundle each of the sine waves into its respective components (f0, df and magnitude), such that we can represent the correct frequency values that occur for each peak. The Peak Detector VI maps the frequency location at which a peak occurs, but this is not necessarily the correct frequency value represented on the graph. The graph's frequency value is actually equal to the peak location*df + f0.


Requirements: LabVIEW 2012 (or compatible). Hardware: none.


Steps to Implement or Execute Code

  1. Open DisplayFrequencies.vi
  2. Click Run

Additional Information or References:

 

Displaying the Frequency Values of the FFT peaks processed by the Spectral Measurements VI FP.png

 

Displaying the Frequency Values of the FFT sn.png


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

Regards,

Sara Lewandroski
Applications Engineer | National Instruments

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

Comments
sshearman
Member
Member
on

Someone forgot to attach the example code.

Sam Shearman
sm81
Member
Member
on

Can someone please attach the vi file for the above task?

TheGeeze
NI Employee (retired)
on

I have created a copy of the VI and attached it to the thread.

Applications Engineer
National Instruments
Insiderbe
Member
Member
on

The "for loop" has no loop count?

crossrulz
Knight of NI Knight of NI
Knight of NI
on

Insiderbe wrote:


                       

The "for loop" has no loop count?


                   

The Autoindexing Tunnel tells the FOR loop how many times to iterate (the size of the array).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5