Agilent Signal Analyzer CXA N9000A

5 views (last 30 days)
Florian
Florian on 20 Jul 2012
Hi,
I want to import data to MATLAB to make a logarithmic graph measurement on a spectrum analyzer Agilent N9000A. Windows XP is installed on the device just like MATLAB and Launch XSA (Signal Analyzer program). As Agilent’s recommendation, we have installed the driver Agilent X-Series. Matlab is now able to “communicate” with the CXA in one direction, we can now set parameters of measurements but we are not able to read “online” the values.
My purpose is very simple: I want to create two vectors of values that the instrument measures. One for a gain value in dB (y) and the other is the value of the frequency (x), then plot as semilogx (x, y).
I found some codes for the CXA in Agilent/MathWorks’website but it doesn’t work.
Find below my Matlab file (issues rise from the function “fprintf”, 2nd part of the code):
% Find a VISA-TCPIP object.
obj1 = instrfind('Type', 'visa-tcpip', 'RsrcName', 'TCPIP0::localhost::inst0::INSTR', 'Tag', '');
% Create the VISA-TCPIP object if it does not exist % otherwise use the object that was found.
if isempty(obj1)
obj1 = visa('AGILENT', 'TCPIP0::localhost::inst0::INSTR');
else
fclose(obj1);
obj1 = obj1(1)
end
% Configure instrument object, obj1
set(obj1, 'InputBufferSize', 20000000);
% Configure instrument object, obj1
set(obj1, 'OutputBufferSize', 512);
Create a VISA-TCPIP object.
interfaceObj = instrfind('Type', 'visa-tcpip', 'RsrcName', 'TCPIP0::localhost::inst0::INSTR', 'Tag', '');
% Create the VISA-TCPIP object if it does not exist % otherwise use the object that was found.
if isempty(interfaceObj)
interfaceObj = visa('AGILENT', 'TCPIP0::localhost::inst0::INSTR');
else
fclose(interfaceObj);
interfaceObj = interfaceObj(1);
end
% Create a device object.
deviceObj = icdevice('Agilent_SA_Driver2.mdd', interfaceObj);
% Connect device object to hardware.
connect(deviceObj);
FreqStar = 100E3;
FreqStop = 10E6;
% Configure property value(s).
set(deviceObj, 'SAFreqStart', FreqStar); set(deviceObj, 'SAFreqStop', FreqStop);
%IQDATA = get(deviceObj,'WavCurrentCapture');
%SampleRate = get (deviceObj,'WavSampleRate'); % % Set the reference level to +10 dBm % fprintf(mxa,':DISP:WIND:TRAC:Y:RLEV 10');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%% IT DID'NT WORK FROM HERE %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set the data trace format to REAL, 32 bits
fprintf(obj1,':FORM:DATA REAL,32');
% Get the nr of trace points
nr_points = str2double(query(obj1,':SWE:POIN?'));
% Get the trace data
fprintf(obj1,':TRAC? TRACE1');
data = binblockread(obj1,'float32');
fscanf(obj1); %removes the terminator character
% data = get(deviceObj,'WavLastCapture'); % binblockwrite(obj1,data,'uint8',':MMEM:DATA "D:\STATE000.STA",'); % create and bring to front figure number 1
figure
Freq = linspace(FreqStar,FreqStop,nr_points);
% Plot trace data vs frequency
semilogx(Freq,data)
xlim([FreqStar FreqStop])
title('Result trace')
xlabel('Frequency [Hz]')
ylabel('Amplitude [dB]')
grid on
Best regards and thank you for your help
Florian

Accepted Answer

Vinod
Vinod on 9 Aug 2012
You might also want to refer to the instrument's programming manual for the SCPI commands necessary to control the instrument for the specific measurements you are interested in.

More Answers (1)

Florian
Florian on 9 Aug 2012
Thank you Mr. Cherian for your answer.
I already resolve the problem with the function:
swapbytes (single (data))
The data which was returned by the instrument were singles in big-endian format whereas MATLAB (or my instrument driver) tried interpreting it as little-endian doubles.
Best regards
Florian

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!