PIC to MATLAB interface via serial port

Status
Not open for further replies.

eppemon

New Member
Hi Am trying to send data from PIC16F877A to PC via serial port.

To read the data fro the serail port using matLab i have done the following code.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
v=instrfind
fclose(v);
clc;
clear;
clc;
s = serial('COM1');
s.InputBuffersize=500;
s.BaudRate=9600;
fopen(s);
set(s,'Parity','mark','DataBits',8);
out=fread(s,2,'uint8');
save MyObject s;
load MyObject s;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

But thevariable 'out' is getting different values during each time i run the code eventhough am sending only one value. WHY??

Also am getting only a matrix of decimal value and not Binary...

PLS HELP ME!!

This is really urgent for our project....
 
Last edited:
What is your compiler?
Did you check it in Proteus?
May be I will help you in MikroC Pro if you deal with it
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…