Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

Back
Top