Chapter 3 3-79
Programming Examples
Measuring Harmonic Distortion (RS-232)
• Take a sweep and wait for the sweep completion.
• Check for operation complete.
• Read the marker amplitude in volts, This is the fundamental
amplitude in volts.
• Read the marker frequency.
• Change the center frequency step size equal to the marker
frequency.
• Measure each harmonic amplitude as follows:
• Set the span to 20 MHz.
• Increment the center frequency. The new center frequency should
roughly equal the frequency of the next harmonic.
• Take a sweep and wait for completion.
• Perform a peak search and wait for completion.
• Activate signal track.
• Zoom down to a 100 kHz span.
• Take a sweep and wait for the sweep completion.
• Signal track off.
• Perform a peak search and wait for completion.
• Set Marker Amplitude in volts.
• Query and read the marker amplitude in volts.
• Change the amplitude units to dBm and read the marker
amplitude.
• Calculate the relative amplitude of each harmonic relative to the
fundamental.
• Calculate the total harmonic distortion.
• Display Fundamental amplitude in dBm, fundamental frequency in
MHz, relative amplitude of each harmonic in dBc, and total
harmonic distortion in percent.
• Close the Session.
Example:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>