Borrar filtros
Borrar filtros

Trying to get serial data from AWR6843AOPEVM

3 visualizaciones (últimos 30 días)
Vinoth Kumar Chandrasekaran
Vinoth Kumar Chandrasekaran el 30 de Abr. de 2024
Respondida: Shubham el 12 de Mayo de 2024
Hi,
I'm using TI radar AWR6843AOPEVM, trying to get the serial data in matlab using below code.
s= serialport("COM5", 921600, 'DataBits',8);
fid=fopen("seriallog.txt",'a');
while(true)
data=readlines(s,200,'string')
fprintf(fid,data);
end
But When i connect this board with arduino IDE it directly display the data in serial monitor.

Respuestas (1)

Shubham
Shubham el 12 de Mayo de 2024
Hi Vinoth,
I have a few suggestions.
The "readlines" function is probably used for reading from a file. You can check the documentation for "readlines" function here: https://www.mathworks.com/help/matlab/ref/readlines.html
For reading data from a serial port, try using "read" or "readline" functions as illustrated in the following documentation: https://www.mathworks.com/help/matlab/import_export/write-and-read-serial-port-data.html
You can try exeption handling to verify if everything is working as desired.
Also, since the "readline" function returns data as a string, you need to adjust the format specifier in "fprintf".
s = serialport("COM5", 921600, 'DataBits', 8);
fid = fopen("seriallog.txt", 'a');
% Check if the file was opened successfully
if fid == -1
error('Failed to open file for writing.');
end
try
while true
data = readline(s);
disp(data);
fprintf(fid, '%s\n', data);
end
catch ME
disp(ME.message);
end
% Close the serial port and the file
delete(s);
fclose(fid);
I would also suggest to use available callback functions as shown in the following documentation: https://www.mathworks.com/help/matlab/import_export/use-events-and-callbacks-for-serial-port-communication.html
You may also find the following MATLAB Answers relevant:
I hope this helps!

Categorías

Más información sobre Instrument Control Toolbox Supported Hardware en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by