Write binblock data to instrument
An interface object.
The data to be written using the binblock format.
The number of bits written for each value, and the interpretation of the bits as character, integer, or floating-point values.
The ASCII header text to be prefixed to the data.
C language conversion specification format for the header text.
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 written to the instrument.
For example, if A is given by [0 5 5 0 5 5 0], the binblock would be defined as [double('#') 1 7 0 5 5 0 5 5 0].
binblockwrite(obj,A,'precision') writes binblock data translating the MATLAB® values to the precision specified by precision. By default the uchar precision is used. Refer to the fwrite function for a list of supported precisions.
binblockwrite(obj,A,'header') writes a binblock using the data, A, and the ASCII header, header, to the instrument connected to interface object, obj. The data written is constructed using the formula
binblockwrite(obj,A,'precision','header','headerformat') writes binary data, A, translating the MATLAB values to the specified precision, precision. The ASCII header, header, is prefixed to the binblock using the format specified by headerformat.
headerformat is a string containing C language conversion specifications. Conversion specifications are composed of the character % and the conversion characters d, i, o, u, x, X, f, e, E, g, G, c, and s. Type instrhelp fprintf for more information on valid values for headerformat. By default, headerformat is %s.
s = visa('ni', 'ASRL2::INSTR'); fopen(s); % Write the command: [double('#14') 0 5 0 5] to the instrument. binblockwrite(s, [0 5 0 5]); % Write the command: [double('Curve #14') 0 5 0 5] to the % instrument. binblockwrite(s, [0 5 0 5], 'Curve ') fclose(s);
Before you can write data to the instrument, it must be connected to obj with the fopen function. A connected interface object has a Status property value of open. An error is returned if you attempt to perform a write operation while obj is not connected to the instrument.
The ValuesSent property value is increased by the number of values written each time binblockwrite is issued.
An error occurs if the output buffer cannot hold all the data to be written. You can specify the size of the output buffer with the OutputBufferSize property.