Effacer les filtres
Effacer les filtres

Failure to read binary data from a visa instrument using readbinblock or read: Format error detected during binblockread.

19 vues (au cours des 30 derniers jours)
I need to read a binary block from Agilent laser mainframe HP8164A. The binary block is an 8-byte long double in Intel byte order. My main code is shown as below:
instr = visadev("GPIB0::20::INSTR");
str = write(instr,'SOUR0:READ:DATA:BLOCK? LLOG,0,801');
data = readbinblock(instr,"double");
And I keep getting the error as:
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
Things I've tried
  1. Read the original ASCII text from the instrument
str = writeread(instr,'SOUR0:READ:DATA:BLOCK? LLOG,0,801');
and I get
"#464080u±#µ>sùõF$µ>Ü)y$µ>ÈÏç$µ>øñ=U%µ>¶OÀÂ%µ>Ý]v2&µ>}ê=4&µ>'%'µ>rËÆz'µ>X ..."
The format looks good, which follows the #[N][D][A] format,, where N = 4, D = 6408 as where are 801 blocks.
2. Repeating the command
Reading 1 char at a time. But it keeps skipping one character after each read. For example, it first reads '#', and then '6', skipping '4' in between. This is probably why readbinblock does not work.
3. Connect the instrument as a GPIB instrument and tried fread and binblockread. The same thing happens.
4. My code used to work with older versions of MATLAB, but not 2022a
Any idea on what is going on here? Thank you.
MATLAB Version: (R2022a)
Instrument Control Toolbox: Version 4.6 (R2022a)
  1 commentaire
Walter Roberson
Walter Roberson le 4 Fév 2023
as possibly 'char' is reading pairs (if for some reason MATLAB thinks the link is not single-byte character set)

Connectez-vous pour commenter.

Réponses (1)

chrisw23 le 6 Fév 2023
For this instruments a bunch of commands returns data in BinBlock format. i.e.
:RESult:BLOCk? Returns a specified binary block from the data array for the last power meter data acquisition function
:DATA:BLOCk? Returns a specified binary block from either a lambda logging operation...
:SLOT[n]:HEAD[m]:WAVelength:RESPonse? Wavelength Response table as a binary block
The instrument will send the data on cmd request to the outbut buffer and set the MAV bit when the message/data is available to be read. It's a good practice to read the data on MAV and not directly after the cmd request. Therefore you can configure the status subsystem of the device to fire a ServiceRequest event on MAV, which can be handled by an async callback method to read the data without polling the instruments state.
I suggest also to use Keysight Connection Expert with it's toolset to debug communication with InstrControl and IOMonitor.
Check the instrument state on error (:SYSTem:ERRor?)




Community Treasure Hunt

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

Start Hunting!

Translated by