Ieee 488 2 Block Format Essay

»Table of Contents

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Both raw data and binary data can be transferred between the driver and the instrument. Data block transfer is a simple yet powerful formatting technique for transferring waveform data between drivers and instruments.

IEEE 488.2 Binary Data—"%b"

When writing binary data to or reading it from the instrument, you can use %b, %B format codes with length modifiers (h, l, ll, z, and Z). ASCII data is represented by signed integer values. The range of values depends on the byte width specified. One-byte-wide data ranges from –128 to +127. Two-byte-wide data ranges from –32768 to +32767. An example of an ASCII waveform data string follows:

CURVE -109, -110, -109, -107, -109, -107, -105, -103, -100, -97, -90, -84, -80

Examples

This example queries a waveform. The data is in IEEE 488.2 <ARBITRARY BLOCK PROGRAM DATA> format. The number (#) sign specifies the data size. In the absence of length modifiers, the data is assumed to be of byte-size elements.

/* Waveform Query */
ViInt32 totalPoints = MAX_DATA_PTS;
ViInt8 rdBuffer[MAX_DATA_PTS];
viQueryf (io, ":CURV?\n", "%#b", &totalPoints, rdBuffer);

This example shows how to scan the preamble of waveform data returned from a scope, how to determine the number of data points in the waveform, and how to scan the array of raw binary data returned.

/* Waveform Preamble */
ViByte data[MAX_WAVEFORM_SIZE];
ViInt32 i, tmpCount, acqType;
ViReal64 xInc, xOrg, xRef, yInc, yOrg, yRef;

viQueryf (io, "WAV:PRE?\n",

"%*[^,], %ld, %ld, %*[^,], %Lf, %Lf, %Lf, %Lf, %Lf, %Lf",
&acqType, &tmpCount, &xInc, &xOrg, &xRef, &yInc, &yOrg, &yRef);

tmpCount = (acqType == 3) ? 2*tmpCount : tmpCount;
viQueryf (io, "WAV:DAT?\n", "%#b", &tmpCount, data));

Raw Binary Data—"%y"

When transferring raw binary data to or from an instrument, use the %y format code with length modifiers (h, l, and ll) and byte ordering modifiers (!ob and !ol). Raw binary data can be represented by signed integer values or positive integer values. The range of the values depends on the specified byte width:

Byte WidthSigned Integer RangePositive Integer Range
1–128 to +1270 to 255
2–32768 to +327670 to 65535

Examples

This example shows how to send a block of unsigned short integer (16 bits) in binary form to the instrument. In this case, the binary data is an arbitrary waveform. The asterisk (*) specifies the block size to be passed in from the argument. Also, !ob specifies data is sent in standard (big endian) format. Use !ol to send data in little endian format.

/* Create Arbitrary Waveform */
ViInt32 wfmSize = WFM_SIZE;
ViUInt16 dataBuffer[WFM_SIZE]; /* contains waveform data */
dataBuffer[WFM_SIZE-1] |= 0x1000;
/* Add the end of waveform indicator */
viPrintf (io, "STARTBIN 0 %d;%*!obhy", wfmSize, wfmSize, dataBuffer);

This example shows how to send a block of signed integers (32 bits) in binary form to the instrument. The asterisk (*) specifies the block size to be passed in from the argument. Without the presence of a byte order modifier, data is sent in standard (big endian) format.

/* Create FM Modulation Waveform */
ViInt32 dataBuffer[WFM_SIZE];
/*contains waveform data */
viPrintf (io, "%*ly", wfmSize, dataBuffer);

Data Transfer Format

Other topics about Reading-Writing Measurement Data

Overview

When you transfer data using the one of the following commands, you can choose among ASCII transfer format, IEEE 64-bit floating point binary transfer format and IEEE 32-bit floating point binary transfer format.

Set the data transfer format to transfer data of either array or block type. To set the data transfer format, use the following command:

:FORMat:DATA

  • Executing the :SYSTem:PRESet or *RST does not affect the current setting of the data transfer format.

ASCII Transfer Format

When you select the ASCII transfer format as the data transfer format, numbers are transferred as ASCII bytes, each of which corresponds to one of the formats shown below. Note that numbers are separated from one another with a comma (,) in accordance with the IEEE 488.2 specification.

  • Numeric data strings vary in length. Keep this in mind when you extract some data from retrieved numeric data strings in your program.

Integer Format

The figure below shows this format. Numbers are expressed as integers. For example, 201 is expressed as "+201" or "201."

Integer format

 

Floating-Point Number Format

The figure below shows this format. Numbers are expressed with floating points. For example, 1000 is expressed as "+1.00000000000E+003."

Floating-point number format

Binary Transfer Format

You can select the binary transfer format from the IEEE 64-bit floating point format or the IEEE 32-bit floating point format depending on the controller you use.

IEEE 64-bit floating point format

When you select the IEEE 64-bit floating point binary transfer format as the data transfer format, numbers are transferred in the format shown in the figure below.

Binary transfer format

This data transfer format uses a header that consists of a sharp character (#), a number of 7 (which indicates the byte size of the <number of bytes transferred> part), and the <number of bytes transferred> part in this order. The header is followed by the binary data (each number consists of 8 bytes and the total is the byte size indicated by <number of bytes transferred>) and the message terminator <new line>^END.

The binary data is expressed in the IEEE 754 64-bit floating-point number format shown in the figure below.

64-bit floating point format

 

IEEE 32-bit floating point format

When you select the IEEE 32-bit floating point binary transfer format as the data transfer format, numbers are transferred in the format shown in the figure below.

IEEE 32-bit floating point binary transfer format

This data transfer format uses a header that consists of a sharp character (#), a number of 7 (which indicates the byte size of the <number of bytes transferred> part), and the <number of bytes transferred> part in this order. The header is followed by the binary data (each number consists of 4 bytes and the total is the byte size indicated by <number of bytes transferred>) and the message terminator <new line>^END.

The binary data is expressed in the IEEE 754 32-bit floating-point number format shown in the figure below.

32-bit floating point data

Byte order

When you opt to perform binary transfer, you can configure the instrument to transfer the bytes of the data in one of the following two byte orders:

NORMal

Transfer begins with the byte that contains the MSB (Most Significant Bit); that is, the leftmost byte in  64 bit floating point format and 32 bit floating point data.

SWAPped

Transfer begins with the byte that contains the LSB (Least Significant Bit); that is, the rightmost byte in 64 bit floating point format and 32 bit floating point data.

To set the byte order, use the following command:

:FORMat:BORDer

  • Executing the :SYSTem:PRESet or *RST does not affect the current setting of the byte order.

0 Thoughts to “Ieee 488 2 Block Format Essay

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *