Instrument Control Toolbox    

Example: Reading Binary Data

This example illustrates how you can download the TDS 210 oscilloscope screen display to MATLAB. The screen display data is transferred to MATLAB and saved to disk using the Windows bitmap format. This data provides a permanent record of your work, and is an easy way to document important signal and scope parameters.

  1. Create an instrument object -- Create the GPIB object g associated with a National Instruments GPIB controller with board index 0, and an instrument with primary address 1.
  2. Configure property values -- Configure the input buffer to accept a reasonably large number of bytes, and configure the timeout value to two minutes to account for slow data transfer.
  3. Connect to the instrument -- Connect g to the oscilloscope.
  4. Write and read data -- Configure the scope to transfer the screen display as a bitmap.
  1. Asynchronously transfer the data from the instrument to the input buffer.

    Wait until the read operation completes, and then transfer the data to the MATLAB workspace as unsigned 8-bit integers.

  1. Disconnect and clean up -- When you no longer need g, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.

Viewing the Bitmap Data

To view the bitmap data, you should follow these steps:

  1. Open a disk file.
  2. Write the data to the disk file.
  3. Close the disk file.
  4. Read the data using the imread function.
  5. Scale and display the data using the imagesc function.

Note that the MATLAB file I/O versions of the fopen, fwrite, and fclose functions are used.

Because the scope returns the screen display data using only two colors, an appropriate colormap is selected.

The resulting bitmap image is shown below.


  Example: Writing and Reading Text Data Example: Parsing Input Data Using scanstr