Read Binary Data from Keysight DMM
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to read voltage measurements from a Keysight 34465A digital multimeter. When the data format is set to ASCII I can read data no problem. However, when the data type is set to Binary (REAL), i get a format error using binblockread. How can I read binary data from a Keysight DMM?
Format error detected during binblockread.
binblock data must be in the format:
#[N][D][A], where
'#' is the token marking the start of the binblock.
'N' specifies the number of digits in D that follow.
'D' specifies the number of data bytes in A that follow.
A is the data
My code follows
clear;
close all;
%% Inputs
dataType = 'REAL';
%% Connect
%An easy way to get the address is with the free Keysight Connection Expert
%software
DMMAddr = "USB0::0x2A8D::0x0101::MY57501917::0::INSTR";
try
resources = visadevlist
app.DMM.DMM = visadev(DMMAddr);
disp('Successful Connection')
catch ME
disp('Unsuccessful Connection')
clear app.DMM.DMM
end
%% Read
if ~isempty(app.DMM.DMM)
try
app.DMM.errorlist = {};
writeline(app.DMM.DMM, '*IDN?');
name = readline(app.DMM.DMM);
%set the format
writeline(app.DMM.DMM, ['FORM:DATA ' dataType]);
app = app_readerror_DMM(app);
writeline(app.DMM.DMM, 'FORM:DATA?')
format_data = readline(app.DMM.DMM);
writeline(app.DMM.DMM, ['FORM:BORD NORM']);
app = app_readerror_DMM(app);
writeline(app.DMM.DMM, 'FORM:BORD?')
format_bord = readline(app.DMM.DMM);
if strcmp(dataType,'REAL') || strcmp(dataType,'SWAP')
data_num = [];
writeline(app.DMM.DMM, "MEAS:VOLT:DC?");
data_temp = readbinblock(app.DMM.DMM)';
%data_char = readline(app.DMM.DMM);
%convert data from bytes to single floats
data_channel = swapbytes(typecast(uint8(data_temp),'single'));
data_num = [data_num, data_channel];
elseif strcmp(dataType,'ASCII')
writeline(app.DMM.DMM, "MEAS:VOLT:DC?");
data_temp = readline(app.DMM.DMM);
else
error('Data type not recognize.')
end
catch ME
disp('Programming Error')
disp(ME.message)
clear app.DMM.DMM
end
end
%% Disconnect
clear app.DMM.DMM
disp('DMM Connection Closed')
%%
function app = app_readerror_DMM(app)
%errors are stored in the power analyzer buffer and read out one at a time,
%most recent first. Therefore, it is good practice to read the errors
%after each command.
response = writeread(app.DMM.DMM, 'SYST:ERR?');
idx = length(app.DMM.errorlist) + 1;
app.DMM.errorlist{idx,1} = response;
end
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Instrument Control Toolbox Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!