Why do DAQ listeners kill MATLAB performance?

2 views (last 30 days)
Hi,
I have a recent issue with using listeners for providing and retrieving data on a National Instruments DAQ card (I am running MATLAB 2013a). My program has two parts: (1) image analysis of a video feed from a ccd camera at 500 Hz and (2) control of two devices using the analog outputs of the DAQ card. The image analysis portion works fine, even with two sessions set up to control each device, as long as I use output/inputSingleScan to change or read the voltage.
In order to output more complicated waveforms to the devices, I was hoping to queue several seconds of the output voltage to the card. I used the MATLAB tutorial titled "Generate Continuous and Background Signals Using NI Devices" to set up the listeners to queue new data when required. I was hoping that the "background" element would not interfere with my image analysis. However, after creating the listener I had to reduce the image analysis to under 200 Hz in order to not drop any frames. If I add a listener to retrieve data from the DAQ as well, the code performs even worse.
The curious thing is that even if I do not startBackground() on the device and only use output/inputSingleScan to send/receive data, the performance is still miserable. Only if I comment out the addlistener commands does the performance return to the original speed. Profiling the code still shows the image analysis as the most time consuming part of my program (by a lot).
Any ideas what is causing this, or if the behavior of the listeners can be modified to improve performance, or truly perform in the background/on a different thread? Maybe I could switch to using the legacy interface but I would have to install 32bit MATLAB. Thanks for your help MATLAB community!
-T

Answers (0)

Community Treasure Hunt

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

Start Hunting!