View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Generating Waveforms on Agilent MXG, ESG, PSG Signal Sources using MATLAB

4.16667
4.2 | 6 ratings Rate this file 27 Downloads (last 30 days) File Size: 2.5 KB File ID: #24048 Version: 1.7.0.1

Generating Waveforms on Agilent MXG, ESG, PSG Signal Sources using MATLAB

by

Vinod Cherian (view profile)

 

08 May 2009 (Updated )

MATLAB® example to download arbitrary waveform data on Agilent MXG, ESG, or PSG signal sources.

| Watch this File

File Information
Description

MATLAB is a software environment and programming language with over 1,000,000 users and is used to generate arbitrary and standard waveforms, configure and control instruments, build automated test applications, and analyze and visualize data from other instruments. MATLAB only supports instrument communication when you use MATLAB with its Instrument Control Toolbox™.
This example uses MATLAB to generate an arbitrary waveform (IQ data), configure the instrument, download the waveform to the Agilent source, and instruct the instrument when to source the waveform.

To execute this example, type ‘Generate_Waveform_Agilent’ in the MATLAB command window. [Note: Change the IP address in the generate_agilent_waveform.m file to the IP address of the signal source.]

This MATLAB example has been tested on an N5182A MXG but should work on other Agilent signal sources including these MXG, ESG, and PSG models: E4428C,E4438C,N5181A,N5182A,N5183A,E8241A,E8244A,E8251A,E8254A,E8247C,E8257C, E8267C,E8257D,E8267D,E8663B,N8211A,N8212A.

To learn more about using MATLAB and Instrument Control Toolbox™ for configuring and controlling instruments, visit:
http://www.mathworks.com/products/instrument

To request a trial of MATLAB and/or Instrument Control Toolbox, visit http://www.mathworks.com/agilent/instrument/tryit.html

For additional information on using MATLAB with Agilent instruments, including MATLAB examples, demos, drivers, and videos, visit:
http://www.mathworks.com/agilent

Required Products Instrument Control Toolbox
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
16 Jan 2017 Mr. Mas

It is worth noting that the module relies upon the Instrument Control Toolbox.

Comment only
16 Jan 2017 Mr. Mas

Nikola, I think it is a little awkward to call twos complement "signed" since it's just a binary representation. However, I believe what they mean is that the Agilent components represent signed data as twos complement. I do not think they're implying that you make twos complement and then awkwardly add a sign bit to the data (not sure how this would be done anyway). I do agree with you that there is an error in the code you indicated.

I believe the intent of the code is to write out unsigned 16-bit integer values, that, when interpreted by the Agilent component as twos complement, will result in the correct values signed values.

Before I discuss issues with the codes implementation of this methodology, I would first question why I wouldn't just scale the data and convert to 'int16' and then write out the signed data using binblockwrite. I expect the binary data would be written out as twos complement and I'd be done. After all the binary representation of 'int16' is the same as data converted to twos complement and cast to 'uint16'.

The conversion from signed to unsigned twos complement, I believe, is making all the data negative, if my assumptions on interpretation on the Agilent component is correct.

The last two lines of this snippet are problematic:
scale = 2^15-1;
scale = scale/tmp;
wave = round(wave * scale);
modval = 2^16;
wave = uint16(mod(modval + wave, modval));

First, the data is scaled to the range [-2^15+1, 2^15-1]. Then the last line moves the range to [(mod(2^16-2^15+1, 2^16), mod(2^16+2^15-1, 2^16)] = [2^15-1, 2^16-1]. If you interpret this range as 16-bit twos complement, I believe all the numbers end up as negative numbers.

Now, the addition of 2^16 is the typical operation for converting a positive twos complement value to it's negative complement (and vice versa) so I can understand how the author ended up doing this. However, I think it should only be done to data that is negative.

Replacing the last line with the following two lines should give the desired result:
wave(wave<0) = modval + wave(wave<0);
wave = uint16(wave)

The modulus operation is no longer necessary.

07 Oct 2015 Vinh LE

Great script. It works for me. One question: how do I compute the I/Q base band signal sample rate? Say I need to send a 1Mhz tone and filter it before sending it to the RF?

Comment only
16 Apr 2014 zhang

zhang (view profile)

does agilent waveform download asisstant do the same work?

05 Mar 2014 hao

hao (view profile)

22 Nov 2013 Ryan

Ryan (view profile)

Great work on connect MATLAB and Agilent instruments.

16 Aug 2012 Attique Ur Rehman

Hello all,
First of all thanks for the script, secondly I tried the code on Agilent N5182A but unfortunately the N5182A display an error i.e. "ERROR_ -275, File name error"

Waiting for a kind response...

18 May 2011 Leow Cheah Wei

MATLAB_WFM is it a file?

Comment only
20 Jan 2010 Nikola Stanchev

Hi,

Thank you for this script. It is very useful except a bug that should be corrected.
I have formatted/scaled waveform by using this script. I was successful to download it to Agilent Signal generator PSG E8267D.

Unfortunately, the PSG output signal (with ARB waveform modulation) was not as suppose to be. I expected to see burst spread spectrum signal but I've got flat signal with a few dB variations.

After a few hours investigation of the problem I found that the cause is the use of Two's complement formatting in the Matlab code.

wave = uint16(mod(modval + wave, modval));

I've got the correct PSG's output signal without 2's complement formatting.

If you go to the Agilent PSG programming guide (E8251-90255) you can see the following sentence "...Data must be in signed, 2’s complement (binary) format..." (very interesting combination, isn't it?)
There is no use of 2's complement formatting in the attached examples script in C/C++.

Best regards,
Nikola

14 Sep 2009 Marco

Marco (view profile)

Hi
I have tried this program in an Agilent Signal Generator E8267D.

However, the instrument displays an error message -275 wrong file name after the line 59:
binblockwrite(deviceObject,wave,'uint16',[':MEM:DATA "WFM1:' ArbFileName '",']);

Comment only
Updates
08 May 2009 1.1

Minor update

14 May 2009 1.3

Update to include VISA and basic interface functionality in example.

19 May 2009 1.4

Minor update.

21 Aug 2009 1.5

Updated description

21 Aug 2009 1.6

Updated description

30 Sep 2009 1.7

Change in copyright.

01 Sep 2016 1.7.0.1

Updated license

Contact us