Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Serial Port Interface

Communication using the serial port interface

Serial communication is the most common low-level protocol for communicating between two or more devices. Normally, one device is a computer, while the other device can be a modem, a printer, another computer, or a scientific instrument such as an oscilloscope or a function generator. For many serial port applications, you can communicate with your instrument without detailed knowledge of how the serial port works. Communication is established through a serial port object, serial, which you create in the MATLAB® workspace. For information about creating the serial object, see Serial Port Object.

Before you can write or read data, both the serial port object and the instrument must have identical communication settings. For information, see Configuring Communication Settings.

Functions

clearRemove instrument objects from MATLAB workspace
deleteRemove instrument objects from memory
fcloseDisconnect interface object from instrument
fopenConnect interface object to instrument
fprintfWrite text to instrument
freadRead binary data from instrument
fscanfRead data from instrument, and format as text
fwriteWrite binary data to instrument
getInstrument object properties
instrhwinfoInformation about available hardware
instrresetDisconnect and delete all instrument objects
propinfoInstrument object property information
readasyncRead data asynchronously from instrument
setConfigure or display instrument object properties
serialCreate serial port object
seriallistList of serial ports connected to your system
stopasyncStop asynchronous read and write operations
binblockreadRead binblock data from instrument
binblockwriteWrite binblock data to instrument
dispDisplay instrument object summary information
flushinputRemove data from input buffer
flushoutputRemove data from output buffer
tmtoolOpen Test & Measurement Tool
fgetlRead line of text from instrument and discard terminator
fgetsRead line of text from instrument and include terminator
instrcallbackDisplay event information when event occurs
instrfindRead instrument objects from memory to MATLAB workspace
instrfindallFind visible and hidden instrument objects
instrhelpHelp for instrument object type, function, or property
instridDefine and retrieve commands that identify instruments
instrnotifyDefine notification for instrument events
inspectOpen Property Inspector
isvalidDetermine whether instrument objects are valid
lengthLength of instrument object array
loadLoad instrument objects and variables into MATLAB workspace
methodsClass method names and descriptions
obj2mfileConvert instrument object to MATLAB code
queryWrite text to instrument, and read data from instrument
saveSave instrument objects and variables to MAT-file
scanstrRead data from instrument, format as text, and parse
sizeSize of instrument object array

Blocks

Query InstrumentQuery or read instrument data
To InstrumentSend simulation data to instrument
Serial ConfigurationConfigure parameters for serial port
Serial Receive Receive binary data over serial port
Serial SendSend binary data over serial port

Examples and How To

Serial Port Object

The serial port object establishes a connection between MATLAB® and the instrument via the serial port.

Configuring Communication Settings

Communication settings are associated with the baud rate and serial data format.

Writing and Reading Data

You can write and read both text and binary data with a serial port object.

Events and Callbacks

Enhance your instrument communication using events and callbacks.

Using Control Pins

The control pins allow you to signal the presence of connected devices and to control the flow of data.

Concepts

Serial Port Overview

Basic features of the serial port.

Instrument Control Toolbox Properties

These properties are available in the toolbox.

Troubleshooting

Troubleshooting Serial Port Interface

Try these tips if you have problems using the toolbox with the Serial Port interface. Includes information about Serial Port supported platforms, adaptor requirements, configuration and connection, and other interface-specific tips.

Was this topic helpful?