Matlab Serial Port Example

Mar 04, 2015  Send data to Serial Port in MATLAB Its a quite simple project in which I am gonna send character over the serial port in MATLAB. In order to do so first of all, I am gonna create an object and assign it to serial port object in MATLAB.

Active6 years, 1 month ago

I am using Matlab to read data from a serial port coming through a microprocessor. The data is in hexadecimal format with each sample of 4 bytes(32 bits). When I read this data, I get some random sequence of numbers which don't match the transmitted data. Below is my code

Please tell me what I am doing wrong do that I can get the correct heart sound.thanks

Portdsolimano
7,6923 gold badges41 silver badges57 bronze badges
KhushbooKhushboo
6565 gold badges16 silver badges29 bronze badges

Matlab Serial Read

2 Answers

You can lower the baudrate to something more standard, like 115200.

Matlab Serial Port Example Free

You can also try with a terminal program.

HebeleHododoHebeleHododo
3,5511 gold badge24 silver badges37 bronze badges
chiraag d. panchalchiraag d. panchal

Not the answer you're looking for? Browse other questions tagged matlabserial-port or ask your own question.

The Serial Port Session

This example describes the steps you use to perform any serial port task from beginning to end.

The serial port session comprises all the steps you are likely to take when communicating with a device connected to a serial port. These steps are:

  1. Find your serial ports — Display a list of serial ports on your system using the serialportlist function.

  2. Connect to a serial port device — Connect to a device for a specific serial port using the serialport creation function.

    Configure properties during object creation if necessary. In particular, you might want to configure properties associated with serial port communications such as the baud rate, the number of data bits, and so on. Alter the necessary device settings by configuring property values, read data, and write data.

  3. Configure properties — To establish the desired serial port object behavior, assign values to properties using dot notation.

    In practice, you can configure many of the properties at any time including during, or just after, object creation. Conversely, depending on your device settings and the requirements of your serial port application, you might be able to accept the default property values and skip this step.

  4. Write and read data — Write data to the device using the writeline or write function, and read data from the device using the readline or read function.

    The serial port object behaves according to the previously configured or default property values.

  5. Disconnect and clean up — When you no longer need the serial port object, remove it from the MATLAB® workspace using the clear command.

The serial port session is reinforced in many of the serial port documentation examples. To see a basic example that uses the steps shown above, see Query a Serial Port Device.