08-05-2010 03:29 PM
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.
08-06-2010 06:35 PM
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.
08-12-2010 03:25 PM
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?
08-13-2010 07:02 AM
08-13-2010 08:55 AM
Thanks, that's what I thought.
Paul
08-13-2010 09:47 AM - edited 08-13-2010 09:48 AM
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.
03-09-2011 02:36 AM
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
03-09-2011 02:53 AM - edited 03-09-2011 02:55 AM
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.
03-09-2011 10:05 AM
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
04-10-2012 03:20 PM
The only way I've found is to stop the task, clear it, and restart it with the new buffer size in DAQmxRegisterEveryNSamplesEvent