236 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide
Creating and Downloading Waveform Files
Creating Waveform Data
Line
Code—Create I and Q data
1
2
3
4
5
6
7
8
9
10
11
const int NUMSAMPLES=500;
main(int argc, char* argv[]);
{
short idata[NUMSAMPLES];
short qdata[NUMSAMPLES];
int numsamples = NUMSAMPLES;
for(int index=0; index<numsamples; index++);
{
idata[index]=23000 * sin((2*3.14*index)/numsamples);
qdata[index]=23000 * cos((2*3.14*index)/numsamples);
}
Line
Code Description—Create I and Q data
1
Define the number of waveform points. Note that the maximum number of waveform points that you can set is
based on the amount of available memory in the signal generator. For more information on signal generator
memory, refer to
.
2
Define the main function in C++.
4
Create an array to hold the generated I values. The array length equals the number of the waveform points.
Note that we define the array as type
short
, which represents a 16–bit signed integer in most C++ compilers.
5
Create an array to hold the generated Q values (signed 16–bit integers).
6
Define and set a temporary variable, which is used to calculate the I and Q values.
7–11
Create a loop to do the following:
— Generate and scale the I data (DAC values). This example uses a simple sine equation,
where 2*3.14 equals one waveform cycle. Change the equation to fit your application.
— The array pointer,
index
, increments from 0–499, creating 500 I data points over
one period of the sine waveform.
— Set the scale of the DAC values in the range of –32768 to 32767, where the values
–32768 and 32767 equal full scale negative and positive respectively. This example
uses 23000 as the multiplier, resulting in approximately 70% scaling. For more
information on scaling, see
“Scaling DAC Values” on page 210
.
NOTE
The signal generator comes from the factory with I/Q scaling set to 70%. If you
reduce the DAC input values, ensure that you set the signal generator scaling
(
:RADio:ARB:RSCaling
) to an appropriate setting that accounts for the
reduced values.
— Generate and scale the Q data (DAC value). This example uses a simple cosine equation,
where 2*3.14 equals one waveform cycle. Change the equation to fit your application.
— The array pointer,
index
, increments from 0–499, creating 500 Q data points over
one period of the cosine waveform.
— Set the scale of the DAC values in the range of –32767 to 32768, where the values
–32767 and 32768 equal full scale negative and positive respectively. This example
uses 23000 as the multiplier, resulting in approximately 70% scaling. For more
information on scaling, see
“Scaling DAC Values” on page 210
.
Summary of Contents for X-Series
Page 4: ...4 ...
Page 10: ...10 Contents ...