You have no items in your shopping cart.

Subtotal:Rs.0.00
Matlab Tips and Tracks

Serial Communication Using Matlab

serial-communication-using-matlab

Matlab Code to Transmit Data Through Serial Port

% Instrreset Disconnect and delete all instrument objects.
instrreset;
%Construct serial port object.
CreateSerialPort = serial('COM1');
%Set Serial Port Settings
set(CreateSerialPort,'BaudRate',115200,'StopBits',1,'FlowControl','none','Parity','none','DataBits',8,'OutputBufferSize',50000);

%Create Buffer Size

CreateSerialPort.InputBufferSize=65537;

%Time out

CreateSerialPort.TimeOut=60;

CreateSerialPort.Terminator = '';

%Open Serial Port Object

fopen(CreateSerialPort);

%Write to  Serial Port Object

fwrite(CreateSerialPort,'A');

%Close Serial Port Object

fclose(instrfind);

%Clear Instrument Objects

clear CreateSerialPort;

Simplified Version

Steps to follow for using Serial Port Communication:-

%Create a Serial Port Object

CreateSerialPort = serial('COM1','BaudRate',9600);

%Open the serial port for Communication

fopen(CreateSerialPort)

%Send some Characters over Serial Port

fprintf(CreateSerialPort,'Embedded Laboratory');

%Close the serial port

fclose(s)

%Delete the serial port

delete(s)
Tags : matlab code to transmit data through serial portSerial Communication Using Matlab
jeevarajan

The author jeevarajan