Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxRegisterDoneEvent behaviour

Hello,
I have written some DAQmx  code in LabWindows/CVI 8.0 with NI-DAQ 8.0 which creates and starts a Task for finite samples AO generation. The code uses function DAQmxWaitUntilTaskDone() to wait for data generation completion and then performs subsequent jobs before restarting the same task for a novel AO generation. The program runs perfectly with a PCI-6259 M-Series multifunction card.
During the time the code waits for the task end, any user interface management either is not possible or is very slow.

In order to be able to speed-up the UIR responsivity even during the AO finite sample generation, I tried to re-write the code in order to use function DAQmxRegisterDoneEvent to register a callback responding when the finite sample generation terminates. Really I am not sure this is the best way to obtain a better UIR handling, but nevertheless I tried.

The problem I am encountering is that the code enters into the registered callback with an apprently random timing. This is easy to check since I have put a numeric counter into the UIR which is updated with an increased number as soon as the program enters into the callback. The behaviour is the following:
1) the numeric waits for a certain time to get increased the first time
2) if I do NOT interact with the UIR setting other controls, the numeric gets increased slower than using the "old code" where it was updated after each DAQmxWaitUntilTaskDone, thus indicating that the AO generation is no longer optimized
3) surprisingly to me, if I do interact with the UIR, the numeric gets increased at a rate near that expected (that of the old code). Apparently the more frequently I act on the UIR, the faster is the  numeric update, i.e. the rate of calls to the callback.

Can anybody help me understanding this issue and how to optimize my code ?

Thanks in advance,
Marco
0 Kudos
Message 1 of 3
(3,758 Views)
Hi,
pheraps you can obtain better performance building a multithreading application (see following link for detail):
http://zone.ni.com/devzone/devzone.nsf/webcategories/FE30FBB1046AEFBE862567A900587DAC
Best regards
AmbuA
0 Kudos
Message 2 of 3
(3,737 Views)
Many thanks for your answer.
I will certainly go through your refs and implement a multithreaded application.
However, can you please advice on the "task done" functioning in DAQmx ?
I was supposing that, in case of the generation of a finite samples AO, the callback ruotine registered by means of DAQmxRegisterDoneEvent() receives control *immediately* after the task completion, i.e. immeditaely after the samples generation, but my experience shows a different behaviour, as explained in my previos message. Even stranger is the better timing when I do interact with other UIR controls.
Can you please explain me better about these topics ?
Thanks in advance,
Marco

0 Kudos
Message 3 of 3
(3,722 Views)