LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithread (TSQ) DAQ and Plotting

I developed a small app to test out the use of a TSQ to acquire data from a device (mass spec), and pass it to the main thread for plotting on an X-Y graph (AMU vs Measured Intensity). In the small app, the plotting keeps up with the data acq and gives a smooth continuous moving graph from start amu to the final amu (x-axis)as the daq scan progresses and overall the technique works very well. Note: the data scan takes about 4-5 secs to scan ~500 points and feeds data asynch back to my PC during the scan, so it's not an overly fast daq.

However, when I integrate the app into my much larger app, I find that the plotting is very choppy, plotting about 1/4 of the graph, pause, graph 1/4 of the graph, pause...

The secondary thread has o
nly one func to read data and put in the TSQ. I don't have any timers running in either thread, I put a ProcessDrawEvents() inside the plot function to update each point as it's plotted, I've modified my sleep policy in both threads with no effect. I know that plotting individual points is slower than the entire graph, but I thought that it should work in the large app similar to the small app since it's multithreaded. BTW, this pausing occurs when I call the plotting function inside the secondary thread as well. But it seems that the main thread is somehow delaying the graphing update.

Any suggestions how I can get the daq/plotting in the large app to be similar to the small app?
0 Kudos
Message 1 of 3
(3,108 Views)
Because the TSQ does all the "locking" of the data internally, while maintaining the length of your array, it may be that this is causing your delay as you go through the larger app. Also, as you have mentioned, there is a possiblity that the delay is being caused by the fact you are plotting on point at a time onto a graph. Have you considered using a Strip Chart to see if you are able to "smooth" your execution?
You could also attach your source code to a post here, and I can check it out to see how it is going, and maybe we can find something that could be causing the delays.
0 Kudos
Message 2 of 3
(3,108 Views)
Here's the small app attached. You can put a random # generator in to test instead of the data acq. I wonder if the update of the main screen in the larger app is controlled by the main thread and therefore causes the slowdown. Can I put the update of just that control in another thread? How would I do that? Load it using loadpanel() in another thread?
Download All
0 Kudos
Message 3 of 3
(3,108 Views)