Real-time data acquisition and data plot problem

4 views (last 30 days)
Hare Gospa
Hare Gospa on 14 Mar 2022
Answered: Benjamin Thompson on 14 Mar 2022
I' ve been having problems to acquire data and plot it in real time. I' ve been able to plot a graph that has a moving x-axis with the help of function drawnow nd by translating the x-axis with the help of function xlim. Now I' ve been wondering if there is a way to read acquisited data one by one (bite per bite), and to plot it in real - time using the same method. Also I' m wondering if the same method could be aplied to generate a signal and send it to an analog output(example winsound), but to make it go outside bit by bite.
function pushbutton3_Callback(hObject, eventdata, handles)
handles.StopGenSignal = 0;
% ao=analogoutput('winsound');
% addchannel(ao,1);
% set(ao,'StandardSampleRates',8000);
% set(ao,'TriggerType','Immediate');
% set(ao,'SampleRate',2*8000);
xlabel('Vrijeme [sec]');
ylabel('Amplituda [V]');
title('Generisani signal');
%axis([0 3 -amp-1 amp+1]);
%set(gca,'XLim','auto','YLim',[-amp-1 amp+1]);
axis([0 3 -amp-1 amp+1]);
grid on;
while handles.StopGenSignal==0
axis([t-2.9 t+0.1 -amp-1 amp+1]);
handles = guidata(hObject);
function pushbutton5_Callback(hObject, eventdata, handles)
handles.StopGenSignal = 1;
The given code represents the generated signal, my question is whether there is a way to make an analogoutput object (or analog input) and to send data (or recieve) data bite per bite (with a refresh period) so that I can use the same metod as in the shown while loop to plot date in real time, and to send it to winsound (or mcc). Thanks in advance.

Answers (1)

Benjamin Thompson
Benjamin Thompson on 14 Mar 2022
If the frequency of the signal is maybe 50 Hz or less it might look OK. Windows and Linux processes typically can only handle events every 10-15 ms. For higher sampling rates and more precise timing you need hardware that buffers data for receiving in Windows or for displaying.

Community Treasure Hunt

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

Start Hunting!