Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 283
Creating and Downloading Waveform Files
Programming Examples
Calculating the RMS Voltage for a Waveform Programming Using C++
This example calculates the RMS voltage value of a waveform segment stored
as 16-bit alternating I/Q twos complement DAC values. Refer to the User’s
Guide. This example is named: “calculate_rms+.txt” and is not
included on the Documentation CD.
#include <math.h>
#ifndef WIN32
typedef long long int int64;
typedef long long unsigned uint64;
#else // WIN32
typedef __int64 int64;
typedef unsigned __int64 uint64;
#endif // WIN32
static const int NUM_DAC_BITS=16;
static const int DAC_MAX=(1 << NUM_DAC_BITS);
//-----------------------------------------------------------------
// calculates the rms of a chunk of a waveform stored as 16-bit
alternating
// I/Q twos complement DAC values.
// NOTE: short must be a 16 bit quantity.
// Also NOTE: For 4Gsa or more, samples must be an int64.
double
calcRmsWaveformSegment(const signed short* iq_data, unsigned
samples)
{
// a double cannot hold the full number accurately for very long
waveforms
// This type can handle up to (but not including) 8Gsa.
For a short the value must be a 16 bit quantity.
For waveforms of 4 Gsa or more, samples must be an int64.
Internally, the MXG ignores two or more zeros in a row when calculating
RMS voltage values.
There is no interface version of this example in the Programming Examples
chapter.
Summary of Contents for X-Series
Page 4: ...4 ...
Page 10: ...10 Contents ...