Instrument Control Toolbox | ![]() ![]() |
Example: Recording Information to Disk
This example extends Example: Reading Binary Data by recording the associated information to a record file. Additionally, the structure of the resulting record file is presented.
g
associated with a National Instruments GPIB controller with board index 0, and an instrument with primary address 1.
g
to execute the callback function instrcallback
every time 5000 bytes are stored in the input buffer.
g.BytesAvailableFcnMode = 'byte';
g.BytesAvailableFcnCount = 5000;
g.BytesAvailableFcn = @instrcallback;
Configure g
to record information to multiple disk files using the verbose format. The first disk file is defined as WaveForm1.txt
.
g
to the oscilloscope.
Initiate the asynchronous read operation, and begin generating events.
instrcallback
is called every time 5000 bytes are stored in the input buffer. The resulting displays are shown below.
BytesAvailable event occurred at 09:04:33 for the object: GPIB0-1. BytesAvailable event occurred at 09:04:42 for the object: GPIB0-1. BytesAvailable event occurred at 09:04:51 for the object: GPIB0-1. BytesAvailable event occurred at 09:05:00 for the object: GPIB0-1. BytesAvailable event occurred at 09:05:10 for the object: GPIB0-1. BytesAvailable event occurred at 09:05:19 for the object: GPIB0-1. BytesAvailable event occurred at 09:05:28 for the object: GPIB0-1.
Wait until all the data is stored in the input buffer, and then transfer the data to MATLAB as unsigned 8 bit integers.
Toggle the recording state from on
to off
. Because the RecordMode
value is index
, the record filename is automatically updated.
g
, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
The Record File Contents
To display the contents of the WaveForm1.txt record file:
The record file contents are shown below. Note that data returned by the fread
function is in hex format (most of the bitmap data is not shown).
Legend: * - An event occurred. > - A write operation occurred. < - A read operation occurred. 1 Recording on 18-Jun-2000 at 09:03:53.529. Binary data in little endian format. 2 > 18 ascii values. HARDCOPY:PORT GPIB 3 > 19 ascii values. HARDCOPY:FORMAT BMP 4 > 14 ascii values. HARDCOPY START 5 * BytesAvailable event occurred at 18-Jun-2000 at 09:04:33.334 6 * BytesAvailable event occurred at 18-Jun-2000 at 09:04:41.775 7 * BytesAvailable event occurred at 18-Jun-2000 at 09:04:50.805 8 * BytesAvailable event occurred at 18-Jun-2000 at 09:04:00.266 9 * BytesAvailable event occurred at 18-Jun-2000 at 09:05:10.306 10 * BytesAvailable event occurred at 18-Jun-2000 at 09:05:18.777 11 * BytesAvailable event occurred at 18-Jun-2000 at 09:05:27.778 12 < 38462 uint8 values. 42 4d cf 03 00 00 00 00 00 00 3e 00 00 00 28 00 00 00 80 02 00 00 e0 01 00 00 01 00 01 00 00 00 00 00 00 96 00 00 00 00 00 00 00 00 00 00 00 00 . . . ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 13 Recording off.
![]() | The Record File Format | Function Reference | ![]() |