beautypg.com

Agilent Technologies N5183A MXG User Manual

Page 266

background image

256

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

Creating and Downloading Waveform Files
Programming Examples

phaseInc = 2*pi*cycles/points;

phase = phaseInc * [0:points-1];

Iwave = cos(phase);

Qwave = sin(phase);

% 2.) Save waveform in internal format *********************************

% Convert the I and Q data into the internal arb format

% The internal arb format is a single waveform containing interleaved IQ

% data. The I/Q data is signed short integers (16 bits).

% The data has values scaled between +-32767 where

% DAC Value Description

% 32767 Maximum positive value of the DAC

% 0 Zero out of the DAC

% -32767 Maximum negative value of the DAC

% The internal arb expects the data bytes to be in Big Endian format.

% This is opposite of how short integers are saved on a PC (Little Endian).

% For this reason the data bytes are swapped before being saved.

% Interleave the IQ data

waveform(1:2:2*points) = Iwave;

waveform(2:2:2*points) = Qwave;

%[Iwave;Qwave];

%waveform = waveform(:)’;

% Normalize the data between +-1

waveform = waveform / max(abs(waveform)); % Watch out for divide by zero.

% Scale to use full range of the DAC

waveform = round(waveform * 32767); % Data is now effectively signed short integer values

% waveform = round(waveform * (32767 / max(abs(waveform)))); % More efficient than previous two
steps!

% PRESERVE THE BIT PATTERN but convert the waveform to

% unsigned short integers so the bytes can be swapped.

% Note: Can’t swap the bytes of signed short integers in MatLab.

waveform = uint16(mod(65536 + waveform,65536)); %

% If on a PC swap the bytes to Big Endian

if strcmp( computer, ‘PCWIN’ )

waveform = bitor(bitshift(waveform,-8),bitshift(waveform,8));

This manual is related to the following products: