LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Does DAQmxRegisterEveryNSamplesEvent(..) handle more than one function?

DAQmxRegisterEveryNSamplesEvent(...) registers event handlers for DAQmx acqusition tasks. Can it handle more than one hander at a time?

what happens if I need to change N; do I have to close the task and reload it? I can find no way to simply remove previous handler before installing a new one.

0 Kudos
Message 1 of 11
(4,478 Views)

This function can only have one taskhandle per call.  However, you can register one event per handle, you just have to call this function multiple times.

Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 2 of 11
(4,462 Views)

Wrong way around. Can I call DAQmxRegister.... with more than one Event handler function? For instance, I have to do one, or both, of two things with an acquired buffer of data: display it to the screen, and write it to a file after further processing. These are handled in two completely different parts of the program, while the control of the DAQmx functionality is in a third.

 

Right now, the display and write dll's each have their own event handler routine (very short); these routines are registered with my DAQ handler dll, which in turn registers its own event handler callback routine with the DAQmxRegister.... function. When the data is acquired, DAQmx calls my event handler, which in turn calls the display and/or write callback routines (or not) as required. Needless to say, the mechanism for doing this takes time, and since I'm trying to do all of this in realtime it sometimes fails.

 

So: can I simply call DAQmxRegister.... twice in succession, with two separate routines - and it then calls both of them in order?

0 Kudos
Message 3 of 11
(4,430 Views)
Short answer: No. The second call would overwrite the first.
-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 4 of 11
(4,415 Views)

Thanks, that's what I thought.

Paul

0 Kudos
Message 5 of 11
(4,408 Views)

If you are having issues with the processing time required by the DAQ callback you might want to move the actual processing of the data out of the DAQ callback.  You can do this by using the DAQ callback to place the aquired data block into something like a threadsafequeue. The queue can have it's own callback routine or you can use another method to handle the processing of the datablock in the queue.  What this does is it removes the need to handle all the processing directly in realtime from the DAQ callback.  You can use different queues, or other structures as needed to handle the different needs of your data flow.

Message 6 of 11
(4,403 Views)

Hi, The original poster pblase also asked:

 

what happens if I need to change N; do I have to close the task and reload it? I can find no way to simply remove previous handler before installing a new one.

 

I have this requirement also = how to change N for a continuous AI task.  If I have to hack this by creating an intermediate buffer with the new N and feeding the new data in as it arrives, I can do that but it sure is ugly.  If I can change it at the driver level, life is good.

 

I'm using the NIDAQmx C API from VB6.  I've tried stopping the task, changing the input buffer size and then calling DAQmxRegister....  but I get this error:

-200966: Every N Samples Acquired Into Buffer Event registration has failed because the event is already registered within the task.

Unregister the event before registering it again.

 

I don't know how to unregister the event.  Clearing the task would be a hassle.  Can't find anything in the help file.

 

Thanks,

 

Van

0 Kudos
Message 7 of 11
(4,127 Views)

HI, I never tried this, but searching in the forum I have found this post from Jeff that explains how to unregister the event in order to register a new one afterwards. You can easily test it in your code.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 11
(4,123 Views)

Perfect!  This works great.  For other VB6 people out there, to pass a null pointer you pass "ByVal 0&" eg

     

DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent_VB6(AITaskHandle, DAQmx_Val_Acquired_Into_Buffer, _
               mNumPointsPerAIRead, 0&, ByVal 0&, 0&))

Just passing zero 0& crashes.  Immediately follow this call with the same call with the AddressOf yourcallbackfunction and everything just works.

 

Thanks

 

Van

 

0 Kudos
Message 9 of 11
(4,095 Views)

The only way I've found is to stop the task, clear it, and restart it with the new buffer size in DAQmxRegisterEveryNSamplesEvent

 

0 Kudos
Message 10 of 11
(3,805 Views)