필터 지우기
필터 지우기

PC to PIC serial communication using Matlab

조회 수: 1 (최근 30일)
esra
esra 2013년 10월 19일
댓글: esra 2013년 10월 19일
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*

답변 (1개)

Walter Roberson
Walter Roberson 2013년 10월 19일
fwrite(eees, uint8([1 0]))
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 10월 19일
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 2013년 10월 19일
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 .

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by