I am working on a GUI that displays in realtime data acquired from a high-speed digitizer card. I'm finding that in some cases that my code cannot keep up with the data acquisition and that some data is lost. I'm wondering if anyone might have some ideas on how I might be able to speed up the display side of things.
The digitizer card receives data every 100-200ms depending on the experiment. My software grabs a waveform, adds it to a variable for saving to file later, and displays it in a plot. Sometimes it takes too long to plot the waveform, and it misses the next acquisition. I think the plotting is the part that is causing me problems, but of course speeding up the rest would be helpful also.
Here is some pseudocode for the acquisition part:
%Initialize data with zeros: clear data for a=1:Nwaveforms; data(a).wf=zeros(1,Npoints); %wf to be saved to file later data(a).st=''; %structure obtained from digitizer card with settings end
%Set up plot figure(1);clf h=plot(nan,nan,'k-');
%obtain data for a=1:Nwaveforms; %acquire data from digitizer [dummydata, dummystruct, dummyerror]=Get12bitDataFromDigitizerMEX(digitizerHandle, Nwaveforms);
%set data for saving later data(a).wf=dummydata; data(a).st=dummystruct;
%update plot set(h,'xdata',timevector,'ydata',data(a).wf); drawnow; end
The above is written just to give an idea what the code is doing. I'm actually acquiring two or four 100000 point waveforms per acquisition (I'm going to increase to 8) and have up to 3 plots to update (which I'd like to increase also if feasible). There is also some simple analysis being done on the data that is displayed on the plot, and it checks for errors and whether the user hits a "stop" button.
Does anyone have any thoughts on how I might be able to display the data more efficiently?
Or maybe there is some way to make the display part a low priority that would be skipped/aborted if it takes more than some amount of time? Or some way to use more than one processor?