binblockwrite

Write binblock data to instrument

Syntax

binblockwrite(obj,A)
binblockwrite(obj,A,'precision')
binblockwrite(obj,A,'header')
binblockwrite(obj,A,'precision','header')
binblockwrite(obj,A,'precision','header','headerformat')

Arguments

obj

An interface object.

A

The data to be written using the binblock format.

'precision'

The number of bits written for each value, and the interpretation of the bits as character, integer, or floating-point values.

'header'

The ASCII header text to be prefixed to the data.

'headerformat'

C language conversion specification format for the header text.

Description

binblockwrite(obj,A) writes the data specified by A to the instrument connected to obj as a binary-block (binblock). The binblock format is defined as #<N><D><A>, where

  • 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

<header>#<N><D><A>

binblockwrite(obj,A,'precision','header') writes binary data, A, translating the MATLAB values to the specified precision, precision. The ASCII header, header, is prefixed to the binblock.

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.

Examples

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);

More About

expand all

Tips

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.

Was this topic helpful?