|
Hello Shrey,
From your code, you didn't specify the Terminator character which is by default 'LF' (newline), that means that when you use fprintf, '\n' is by default appended to the message you're sending.
You can simply, specify the Terminator character to be '' by adding the following line to your code:
set(o,'Terminator','');
before
fopen(o);
Note : You could aslo use another functions which send data to the serial port without appending the terminator character like fwrite() "I guess"
You can find more about fprintf in the following link.
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/serial.fprintf.html
Regards,
Walid F. Abdelfatah
"Shrey " <rockingsa1991@gmail.com> wrote in message <hee7bm$l18$1@fred.mathworks.com>...
> I have to move a robot using serial communication. I am accepting 3 bits in my controller. An LED lights up when my controller recieves the 3rd bit.
> This works fine when i use it with X-CTU or FlashMagic to communicate serially. But when i do the following in an m-file, the LED glows after recievng the 2nd bit. Thus, its not waiting for the 3rd bit.
>
> o=serial('COM11','BaudRate',9600);
> fopen(o);
> fprintf(o,'[');
> fprintf(o,'F');
> fprintf(o,'2');
>
> The LED glows after recieving 'F' in matlab. On the other hand, if i use some other software to communicate serially it glows after recievin '2'. Can anyone please tell me why this is happening??? Really need help and quickly. I have an image processing event coming up and need matlab to communicate serially as well.
|