PC to PIC serial communication using Matlab
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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*
0 commentaires
Réponses (1)
Walter Roberson
le 19 Oct 2013
fwrite(eees, uint8([1 0]))
3 commentaires
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.
Voir également
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!