error while interfacing matlab with agilent PNA

1 回表示 (過去 30 日間)
smriti garg
smriti garg 2014 年 6 月 27 日
コメント済み: Nisha Satia 2021 年 2 月 15 日
Hello everyone,
I am interfacing my laptop with agilent PNA using TCP/IP connection. I am able to successfully link the PNA to the matlab. But, while saving S11 data, it is giving error:-
Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
and terminates without getting any data. What is this error means and how can i rectify it..? Matlab script that i am using is below:
clc;
clear all;
% Find a tcpip object.
obj1 = instrfind('Type', 'tcpip', 'RemoteHost', '192.168.173.248', 'RemotePort', 80, 'Tag', '');
% Create the tcpip object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = tcpip('192.168.173.248', 80);
else
fclose(obj1);
obj1 = obj1(1)
end
% Configure instrument object, obj1.
set(obj1, 'InputBufferSize', 20000);
set(obj1, 'Timeout', 300);
% Connect to instrument object, obj1.
fopen(obj1);
% Communicating with instrument object, obj1.
opc_comp = query(obj1, 'SYST:PRES; *OPC?', '%s\n' ,'%s');
fprintf(obj1, 'CALC:PAR:SEL "CH1_S11_1"');
% Query selected measurement name
meas = query(obj1, 'CALC:PAR:SEL?', '%s\n' ,'%s');
% Set byte order to swapped (little-endian) format
%fprintf(obj1, 'FORM:BORD SWAP');
fprintf(obj1, 'FORM:BORD NORM');
% Set data type to real 64 bit binary block
fprintf(obj1, 'FORM REAL,64');
% Read S2P data back from PNA. A S2P file will return number of points * 9
% data points back.
fprintf(obj1, 'CALC:DATA:SNP? 2');
[data, count, msg] = binblockread(obj1, 'double');
% Flush the buffer
%clrdevice(obj1);
% Disconnect gpib object.
fclose(obj1);
% Reshape data so it is split into columns
data_r=reshape(data, [(length(data)/9),9]);
data_r=data_r';
% Read frequency data back from returned data
freqs=data_r(1,:);
% This assumes that the return format is in log mag, angle pairs in the S2P
% file
S11mag=data_r(2,:);
plot(freqs,S11mag);
title('S11 mag');
xlabel('Frequency');
ylabel('dB');
% Clean up all objects.
delete(obj1);
is there any error in the script...? any help or suggestion is requested.
thanx. smriti
  1 件のコメント
Nisha Satia
Nisha Satia 2021 年 2 月 15 日
I am also facing problem. Not able to get data using binblickread() Can any one give solution

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeInstrument Connection and Communication についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by