Filter löschen
Filter löschen

Get data from COM port

3 Ansichten (letzte 30 Tage)
paul kaam
paul kaam am 18 Mai 2015
Bearbeitet: Walter Roberson am 26 Jun. 2015
Hi everyone,
data is send to my laptop by a device through a usb port. How often the data is send depends on de sample time that i choose, it can vary from very 0.05s to ones very 30s.
i want matlab to get the data every time that the device sends it to my laptop. I am not that familiar with matlab and hope you can help me out a bit.
this is what i have so far...:
board = serial('COM3', 'BaudRate', 38400, 'DataBits',8);
fopen(board);
S = fscanf(board);
with S I get (I think) the oldest value stored in the input buffer every time i run fscanf
Thanks in advance!
Paul

Antworten (1)

Walter Roberson
Walter Roberson am 18 Mai 2015
Set a BytesAvailableFcn callback on the serial port object.
  5 Kommentare
Guillaume
Guillaume am 24 Jun. 2015
No, that would be a violiation of Mathworks copyright.
You can access the same documentation from within matlab by typing:
web(fullfile(docroot, 'matlab/matlab_external/bytesavailablefcn.html'))
and
web(fullfile(docroot, 'matlab/matlab_external/events-and-callbacks.html'))
paul kaam
paul kaam am 26 Jun. 2015
many thank!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by