??? 05/30/04 13:46 Read: times |
#71475 - RE: Matlab &8051 Responding to: ???'s previous message |
Programs like Matlab cannot stay in the fscanf(s) function forever until data is ready at the serial port. If no data is available (or not enough data is available) then the input scanner will timeout and return. Many times the timeout perod is adjustable. The trick for you is to arrange it so your program in Matlab will handle the timeout error in an an error trap routine and provide for whatever recovery is necessary in code and then jump back to the input routine again.
You should also look closely at the fscanf(s) function and what it expects to read and return to your Matlab program. It may very well be looking for more than one byte. If so then your external microcontroller will have to be on its toes and ready to send the whole batch of bytes that the ffscanf() function is looking for. I'm not a Matlab programmer, but a similarly named routine in C language expects more parameters than just the file "device" handle. It may need also a format string and/or a variable of some type that tells it where to put the input. The familiar C routine will use the format string to determine how much input to fetch and then will read the device (or COMM port) till the variable is read. Sometimes it will be designed to stop reading it a <cr><lf> or a <NULL> is encountered at the input. Michael Karas |
Topic | Author | Date |
Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051 | 01/01/70 00:00 | |
RE: Matlab &8051![]() | 01/01/70 00:00 |