Example Code

Low to mid frequency spectrum analysis of a filter using FGen and Scope

Code and Documents

Attachment

Overview

On several occasions recently, there has been a desire to measure the response of a circuit in the range of a few 10s of Hz to a few MHz. Using a function generator or arb, we can generate the required signals, and capture them with a 'scope card. Remarkably, I couldn't find an appropriate example so I've written the attached example to get people started.

 

Description

The example steps through the chosen frequency range and extracts the response at each specified test frequency. The acquisition rate is varied to ensure that a fixed number of cycles of the current test frequency are acquired and with sufficient samples per cycle, without acquiring too much data at lower frequencies. Inevitably, at low frequency the tests are still slow. With a variety of experiments using multi-tones, broadband noise and chirps, the stepped frequency operation was actually the most realiable.

The scope samples both the input to the DUT and the output. Using the tone analysis VI, the magnitude and phase relationships are acquired. LabVIEW does have the FRF and PSD functions but I found the approach here to be most reliable.

The code acquires data and processes the results in parallel. When the measurement is complete, it writes a simple tab-delimited file into the default data folder. Giving it a ".xls" extension tells Excel to see it as one of it's own and it will import it for you.

Note: The default data in the displayed graphs is the result of running this with a 5MHz low pass filter as the DUT.

Hardware and Software Requirements

LabVIEW 2016 or later. It will also work on an RT target if that is what you have.

An NI Scope. In this case I was using a PXI-5922.

An NI Function Generator. In this case I was using a PXI-5421 Arb'

Steps to Implement or Execute Code

1. Open the top level VI

2. Change the Scope and FGen references to match your devices

3. Connect the FGen output to the input side of the DUT

4. Connect Channel 0 of your Scope to the input as well

5. Connect Channel 1 to the DUT output

6. Choose your frequency range, and frequency step factor

7. Run

Additional Information or References

Front panel.png

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