Code algorithm – Agilent Technologies N5183A MXG User Manual

Page 223

Advertising
background image

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

213

Creating and Downloading Waveform Files

Creating Waveform Data

Code Algorithm

This section uses code from the C++ programming example

“Importing, Byte Swapping, Interleaving,

and Downloading I and Q Data—Big and Little Endian Order” on page 249

to demonstrate how to

create and scale waveform data.

There are three steps in the process of creating an I/Q waveform:

1.

Create the I and Q data.

2.

Save the I and Q data to a text file for review.

3.

Interleave the I and Q data to make an I/Q file, and swap the byte order for little- endian
platforms.

For information on downloading I/Q waveform data to a signal generator, refer to

“Commands and

File Paths for Downloading and Extracting Waveform Data” on page 206

and

“Downloading Waveform

Data” on page 218

.

1. Create I and Q data.

The following lines of code create scaled I and Q data for a sine wave. The I data consists of one
period of a sine wave and the Q data consists of one period of a cosine wave.

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

“Waveform Memory” on page 198

.

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.

Advertising
This manual is related to the following products: