Plot Agilent E4446A Using VISA/GPIB Connection
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello all:
I am currently trying to to write code that allows me to display the plot of my spectrum analyzer.
analyzer_handle = visadev("GPIB0::18::INSTR"); %visa connection, toolbox required
analyzer_handle.OutputBufferSize = 1000000; %output buffer size in bytes
analyzer_handle.InputBufferSize = 1000000; %input buffer size in bytes
fopen(analyzer_handle);
fprintf(analyzer_handle,'*RST;*WAI');
fprintf(analyzer_handle,'*IDN?');
a=fscanf(analyzer_handle);
disp(a);
fprintf(analyzer_handle,'INIT:CONT OFF'); %Selects single sweep mode.
The above code is what I am using to make and open the connection. This has been working fine.
timeout=30; %timeout in seconds
set(analyzer_handle,'Timeout',timeout); %timeout increased before acquisition to avoid sync errors
fprintf(analyzer_handle,'INIT:IMM;*WAI');
fprintf('Fetching waveform ...\n ');
fprintf(analyzer_handle,':FORM REAL,32');
fprintf(analyzer_handle,':TRAC? TRACE1;*WAI');
data=binblockread(analyzer_handle,'float32');
fread(analyzer_handle,1); %fread removes the extra terminator in the buffer
timeout=2; %timeout in seconds goes back to a normal value
set(analyzer_handle,'Timeout',timeout);
The above code is what I am using to detect data. This has also been working fine.
The issue is that I need code that will find the start frequency and end frequency so that I have a span for the x-axis of my graph. It should be an easy fix, it has just been a struggle for me to figure out. Any and all advice is appreciated. Thank you!
0 Kommentare
Antworten (1)
Garmit Pant
am 14 Sep. 2023
Hello Madeline,
It is my understanding that you are trying to extract the start and end frequency of your “Agilent E4446A spectrum analyser”. This can be achieved using function from the Instrument Control Toolbox.
You can use the function “visadev” and along with it either “read” or ”readline” to find the start and end frequency.
The function “visadev” is used to create a GPIB object as follows:
fgenResource = "GPIB0::5::INSTR";
vfgen = visadev(fgenResource);
You can use “read” or “readline”, as per your requirement, to read the contents of the GPIB object as follows:
% Read five values of string data from the VISA resource "vfgen".
data = read(vfgen,5,"string");
From the data read from the “visadev” object, the start and stop frequency are listed in the following format:
"SOUR1:FREQ:STAR <freq>"
"SOUR1:FREQ:STOP <freq>"
You can find these frequencies to calculate the span of the x-axis.
For further understanding, you can refer the following MathWorks Documentation:
https://www.mathworks.com/help/instrument/transition-your-code-to-visadev-interface.html - Refer to the this to find all the functions related to “visadev”.
https://in.mathworks.com/help/pde/ug/pde.femodel.solve.html#bvizufn-3 - Refer to the “Output Arguments” section.
https://in.mathworks.com/help/instrument/generate-swept-sinusoid-and-capture-waveform.html - Example demonstrating “visadev” and it’s functions.
I hope this helps!
Regards,
Garmit
0 Kommentare
Siehe auch
Kategorien
Mehr zu Instrument Control Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!