Effacer les filtres
Effacer les filtres

PC to PIC serial communication using Matlab

1 vue (au cours des 30 derniers jours)
esra
esra le 19 Oct 2013
Commenté : esra le 19 Oct 2013
Hi, all. I'm a work in project using PIC 16f877A and dc motor where dc motor represent door . In the project I use Matlab to send out signal (bit )(zero or one ) through Maxim232cpe and then PIC picked up the signal, if signal one bit the green LED will lighted where this lighted represent door open , if signal zero bit the green LED not light where represent door stile closed My codes are listed below:
eees=serial('COM3');
set(eees,'BaudRate',9600);
fopen(es);
fwrite(eees,1);
fwrite(eees,0);
fclose(eees);
delete(eees);
clear eees;
PIC code
if(UART1_Data_Ready()=1) then
es_pic=UART1_Read()
if(es_pic=1)then
portb.0=1 'signal to work motor
if(es_pic=0)then
portB=0
the problem when send 1 bit from matlab to PIC via Max232cpe and USB to serial adapter,the green LED will light 23 times where should be light only one time thanks ,sorry for bad English*

Réponses (1)

Walter Roberson
Walter Roberson le 19 Oct 2013
fwrite(eees, uint8([1 0]))
  3 commentaires
Walter Roberson
Walter Roberson le 19 Oct 2013
What is the LED monitoring? Is it monitoring the USB wires? Is it monitoring the serial data that is being unpacked from the USB data packet? Do you have a USB driver on your PIC?
I recall reading that the first two bytes of each serial USB packet are reserved for indicating virtual pin status, but I do not seem to be finding that page at the moment.
esra
esra le 19 Oct 2013
i have matlab code this code find matching between images in folder A and B, when i insert new image in folder B, matlab code will Comparing new image with images stored in folder A , the matlab will send (zero or one ) as bit to PIC (microcontroller 16F877A) if PIC received 1 , the green LED was connect with PIC will lighit,if PIC received 0 will no action.
where LED represent if there any matching .

Connectez-vous pour commenter.

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by