PNSU? command on Lecroy oscilloscope using GPIB

1 visualización (últimos 30 días)
Hugues DE CARVALHO
Hugues DE CARVALHO el 8 de Feb. de 2019
Comentada: Malte Rodeheger el 25 de Feb. de 2021
Good afernoon,
I am trying to settup a GPIB communication with a Lecroy oscilloscope using the Instrument control toolbox.
I managed to open the GPIB connection, to send basic commands and to receive some data. However a specific command can't seem to work on Matlab (I've had it work with an Excel macro). This command is used to configure recall a previously saved configuration, I would have to send the command in config.txt.
Here is my code :
%% Instrument Connection
% Find a GPIB object.
obj1 = instrfind('Type', 'gpib', 'BoardIndex', 0, 'PrimaryAddress', 6, 'Tag', '');
% Create the GPIB object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = gpib('NI', 0, 6);
else
fclose(obj1);
obj1 = obj1(1);
end
% GPIB configuration
obj1.timeout = 0.1; %is 10s by default
obj1.OutputBufferSize = 75000; %Set buffer size to 75000 so that we can send a config
% Connect to instrument object, obj1.
fopen(obj1);
clrdevice(obj1);
flushinput(obj1);
%% Save conf
fprintf(obj1, 'PANEL_SETUP?'); %Ask oscilloscope for its setup. (sends back the command in config.txt)
data_temp = 1; %data_temp init
i=1;
while (~isempty(data_temp)) %multiple 512 bytes reads
data_temp = fscanf(obj1);
if ~isempty(data_temp)
data{i} = data_temp;
end
i=i+1;
end
data_comp = cell2mat(data);
disp(['length data comp = ', num2str(length(data_comp))]);
%% Saves data_comp in config.txt
fileID = fopen('config.txt','w');
fprintf(fileID,data_comp);
fclose(fileID);
% Sends conf to oscilloscope
A=obj1.ValuesSent;
fprintf(obj1, data_comp);
disp(['number of bytes sent = ', num2str(obj1.ValuesSent-A)]);
The console returns:
length data comp = 70427
number of bytes sent = 67751
And the oscilloscope displays an error message "error: command <PNSU> at token <PNSU>: end of block of data found before byte count exhausted"
I think that the issue is that the oscilloscope is expecting 70427 butes but only receives 67751 bytes because all CR are considered as terminator!
I have tried changing the EOSCharCode and EOIMode without success. Changing the terminator (EOSCharCode) doesn't change anything and disabling EOIMode just makes the oscilloscope not react at all.
I have also monitored the GPIB transmission using "NI SPY" and noticed that the last 'f' isn't sent! weird
Would anyone have any recommendation? I'm running out of ideas.
  1 comentario
Malte Rodeheger
Malte Rodeheger el 25 de Feb. de 2021
I'm encountering the same problem. Did you find any solution to this porblem? That would really help me.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Instrument Control Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by