Borrar filtros
Borrar filtros

Serial communication with Arduino microphone signal and matlab

6 visualizaciones (últimos 30 días)
Mark Chertoff
Mark Chertoff el 8 de Abr. de 2019
Respondida: Mark Sherstan el 12 de Abr. de 2019
We are trying to use matlab to read a microphone signal from a microphone attached to an Arduino microcontroller. When we program the controller to putout specific numbers, matlab reads the data fine through the USB port. If we now send the microphone signal, matlab reads the signal but the signal is not correct. It looks like it is missing many of the voltage changes from the microphone.
Here is the code
% Find a serial port object.
obj1 = instrfind('Type', 'serial', 'Port', 'COM8', 'Tag', '')
set(obj1,'BaudRate',115200)
if isempty(obj1)
obj1 = serial('COM8');
else
fclose(obj1);
obj1 = obj1(1);
end
% Connect to instrument object, obj1.
fopen(obj1);
i = 1;
count = 0;
x = 0;
while i == 1
x = x+1;
count = count+1;
tempdata = fscanf(obj1);
data(count,1) = str2num(tempdata)
end
plot(data)
fclose(obj1)

Respuestas (1)

Mark Sherstan
Mark Sherstan el 12 de Abr. de 2019
Look at my solution for another question here: https://www.mathworks.com/matlabcentral/answers/452211-how-to-make-arduino-receive-data-sent-from-matlab#answer_367687. You my be running into bottle necks with the MATLAB/serial connection depending how fast you are sampling and how much data is being transferred. If you have further questions after trying my code please post both your MATLAB and Arduino code. Good lcuk!

Categorías

Más información sobre Arduino Hardware en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by