Real time acquisition using drawnow
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I tried to read data from AD8232 ECG Module using HC-05 and plot the signal in real time. But when I try drawnow it give a sample rate of 40-60 Hz and with drawnow limitrate it gives some random data and the final results its nothing like the ecg from arduino ide even if i have 500 Hz sample rate. I then tried to pause for 0.001 s and the sample rate is good 160 Hz, the signal is ok, but its with 1 minute delay and its not stopping even when i press ctr+c.
The code implemented is below:
b = instrfind('Type', 'bluetooth', 'Name', 'Bluetooth-HC-05:1', 'Tag', '');
if isempty(b)
b = Bluetooth('HC-05', 1);
else
fclose(b);
b = b(1);
end
fopen(b);
figure
h = animatedline;
ax = gca;
ax.YGrid = 'on';
i=1;
x = zeros();
stop = false;
startTime = datetime('now');
while ~stop
x(1,i) = str2double(fscanf(b));
t = time2num((datetime('now') - startTime),'seconds');
if isnan(x(1,i))
x(1,i) = 0;
end
addpoints(h,t,x(1,i))
ax.XLim = [t-3 t];
i = i+1;
drawnow limitrate
pause(0.001)
end
Please is there a function beside pause to slow down the drawnow limitrate without delaying the acquisition?
Below is the acquisition with pause and without it.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/621333/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/621338/image.jpeg)
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!