Matlab Interface for HP (or Agilent) 54602

This document describes Matlab code that will download data from a 54602 oscilloscope.  To run the code you need to download the two files Matlab54602.m and Matlab54602.fig to a place on your computer where Matlab can run them.


Transferring data from oscilloscope to computer

Start Matlab.  Run the script called Matlab54602.  This program sends data from the scope to the computer. To run it type:

>> Matlab54602

from the Matlab prompt.

A window similar to the one below appears:

The program is fairly straightforward to use.  You can specify the number of points you want to collect (500 is probably enough for most purposes, but you can increase if you'd like), and you can specify the "baud rate" which is a measure of how fast the communications with the computer will be (faster is generally better, but may cause some errors). 

Set the baud rate to 19200 in the GUI (as shown above), and then make sure it is set the same on the oscilloscope.  To do this, hit the you hit "Print/Utility" button on the scope, and then hit the "I/O Menu" soft-button just below the scope screen.  Make sure the baud rates are equal, and that "Handshake" is set to DTR.

When you are ready to collect data hit the "Get Data" button on the Matlab GUI.  A sample result is shown below with channels 1 and 2 active.

Note the small triangles on the right of the screen that show the location of ground (similar to the ground markers on the oscilloscope screen).

At this point you can save the data (hit the "Save data" button).  You can also print it - there is a black and white printer in the lab called "Apple Laserwriter Select 360."

Loading the data into Matlab

To work with the data from within Matlab, you can open the file you just saved.  Three variables will be created, as shown by the "whos" command.

>> whos
  Name          Size             Bytes  Class
 
  cdata        1x4               8240   cell array
  dstring      1x20              40     char array
  t            1x500             4000   double array
 

The variable "cdata" holds the oscilloscope data, "t" is the corresponding time vector, and "dstring" holds the data and time at which the data was collected (which might be useful). 

To plot the data from channel 1, use the following Matlab command (note that the characters surrounding the 1 are curly braces {}, not parentheses.  This denotes a "cell array" in Matlab - you won't really have to worry about them very much.

>> plot(t, cdata{1})

To plot channel 1 and 2 with axes labeled and a legend enter:

Matlab code section 1:

>> plot(t, cdata{1}, t, cdata{2})
>> legend('Channel 1','Channel 2')
>> title('Data from oscilloscope')
>> xlabel('Time (seconds)')
>> ylabel('Volts')

Note that this looks a little different than the original data because 0 volts is in the middle of the screen, whereas on the oscilloscope, the grounds may be at different locations.

If you want to work with a subset of the data, it may be easier to copy it to another array ("c1" and "c2" in the example below).

Matlab code section 2:

%Find all points where t is equal to or greater than zero.
>> myIndex=find(t>=0);
>> c1=cdata{1};
>> c2=cdata{2};
>> plot(t(myIndex),c1(myIndex),t(myIndex),c2(myIndex))

Known Issues

If you collect data from channels 3 or 4, they are not scaled properly when saved.


email me with any comments on how to improve the information on this page (either presentation or content), or to let me know if you had any particular difficulties with this lab.
You may use any portion of this document for your lab report, but be sure to reference it.

Back