Instrument Control Toolbox    

Example: Using Events and Actions

This example uses the M-file action function instraction to display event-related information to the command line when a bytes-available event or an output-empty event occurs.

1. Create an instrument object - Create the serial port object s associated with serial port COM1.

2. Connect to the instrument - Connect s to the Tektronix TDS 210 oscilloscope. Since the default value for the ReadAsyncMode property is continuous, data is asynchronously returned to the input buffer as soon as it is available from the instrument.

3. Configure properties - Configure s to execute the action function instraction when a bytes-available event or an output-empty event occurs.

4. Write and read data - Write the RS232? command asynchronously to the oscilloscope. This command queries the RS-232 settings and returns the baud rate, the software flow control setting, the hardware flow control setting, the parity type, and the terminator.

instraction is called after the RS232? command is sent, and when the terminator is read. The resulting displays are shown below.

Read the data from the input buffer.

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


 Storing Event Information Using Control Pins