Instrument Control Toolbox | ![]() ![]() |
Example: Using Events and Callbacks
This example uses the M-file callback function instrcallback
to display event-related information to the command line when a bytes-available event or an output-empty event occurs.
s
associated with serial port COM1.
s
to the Tektronix TDS 210 oscilloscope. Because 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.
s
to execute the callback function instrcallback
when a bytes-available event or an output-empty event occurs.
s.BytesAvailableFcnMode = 'terminator';
s.BytesAvailableFcn = @instrcallback;
s.OutputEmptyFcn = @instrcallback;
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.
instrcallback
is called after the RS232?
command is sent, and when the terminator is read. The resulting displays are shown below.
s
, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
![]() | Storing Event Information | Using Control Pins | ![]() |