matlab serial communication with mbed
Ältere Kommentare anzeigen
I am trying to use mbed LPC1768 to read sensors and use matlab to collect the data by serial port. If I use PuTTy, I am able to see the data of serial port perfectly. However, when I try to use matlab, it does not work.
the command on matlab is simple like:
mbed = serial('COM5')
fopen(mbed)
value = fscanf(mbed,'%f')
I can read the first two values but after that, the value will always the same.. I use the LEDs on mbed to debug, the code of mbed does not have problems. However, the LED of the USB connector will not blink if I use matlab. The problem is the the data will not continually be sent. Could anyone help me about this?
Antworten (1)
Walter Roberson
am 2 Jun. 2016
0 Stimmen
You should configure the BaudRate and Terminator properties of the serial object, and probably the FlowControl property as well.
If your data is line-oriented I recommend using fgetl() to fetch a line, and then sscanf() to read from the stored line. fgets() can cause you problems if the data you receive does not have the line boundaries that you expect.
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!