Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronous events - DAQmxRegisterEveryNSamplesEvent

Lavio,

The error message indicates that this is a limitation of the DAQ device when utilizing synchronous events.  Your declaration seems to be correct but the first error (-200979) is a result of using DAQmx_Val_SynchronousEventCallbacks as the value one.  (ie. Synchronous events are activated)  To possibly find a work-around to your issue, more detail is needed as to why multiple threads are needed for one DAQmx Task and what exactly you would like to accomplish. 

0 Kudos
Message 11 of 15
(1,248 Views)
Oh well, I have another thread here where I wrote many things about what we have done at Omnimetra using NAT boards.
 
The board being used is the 6220M.
We run up to four aquisitions at the same time, 8 channels (voltage and current each one).
The acquisition and data display (graphically) is real time.
And we use a callback for the AI read running at fixed 30KHz.
By the way... the callbacks in Traditional are much more efficient, faster and without the thread troubles.
 
Start and Stop can happen from the main thread (usually a user button click) as also from other threads running in real time to stop automatically or when aborting a script (that also runs in a thread of course).
 
Thus, the point is that we had a bad surprise (one more... using the nidamx) for porting our software from the Traditional to the nidaqmx when we got the error telling that the thread must start, stop, clear or unreserve from the same thread the event callback was registered.
 
Also, the very cumbersome problem here is that the AI task needs to be stopped, cleared and recreated sometimes, because of GAIN changes the user can input in our software interface.
Using 8 channels with 4 possible input ranges (or gains) each... it is not feasible to create so many tasks in advanced to avoid the recreation in realtime.
 
The documentation is not very useful when talking about the methods of synchronization of the callbacks and how to start/stop them when using several threads. In fact, it says NOTHING.
And as I wrote, it only accepts a zero as the parameter, that the doc says the callback will run on a NAT thread and not in a program thread.
But things do not seem to work as the doc says, because I tested and the task can be stopped from inside the callback.... although as the doc says, the callback calling thread is not the one that created and registered the callback AI task (it is usually the main program thread). There is something wrong in all this stuff.
 
Ok, I can do more programming trickies to fool or bypass the many troubles and difficulties the nidaqmx creates.
After using the Traditional for so many years without problems, I can say I really dislike very much the nidaqmx.
 
Anyway, if you say the device (6220M) is not capable to work using synchronous callbacks, I wonder if there are real advantages to change the Traditional (6023E) for the nidaqmx (6220M) for demanding real time applications.
 
🙂
 
0 Kudos
Message 12 of 15
(1,236 Views)
Lavio,
 
Your card will function with synchronous callbacks but you must make sure to place the start and stop task functions in the same thread that the task was registered.  If multiple threads are used for analog input then stopping the task from anything but the register thread could deallocate resources before other analog reads are completed.  This is due to the fact that synchronous callbacks are non-blocking.  Also, once the GAIN is set for a task, you cannot change it without starting and stopping the task as you suggested.
0 Kudos
Message 13 of 15
(1,211 Views)
> Your card will function with synchronous callbacks but you must make sure to place the start and stop task functions in the same thread that the task was registered. 
 
> Also, once the GAIN is set for a task, you cannot change it without starting and stopping the task as you suggested.
 
 
I know that.
The first is a limitation of nidaqmx I was complaining about and the Traditional does not have.
The second is an old problem all NT boards have.
 
I am having a lot of work because of several incompatibility issues between Traditional and nidaqmx.
It is not easy and good politics to obligate NAT clients to rework again on old projects already running and successfull because of changes in hardware / software or because of stopping selling some boards or systems.
 
Lávio
 
0 Kudos
Message 14 of 15
(1,206 Views)

I am trying to do the same thing with Visual Basic 6.  If I set the Syncronous flag I get a -200077 error:  "Requested value is not a supported value for this property."

 

Is this not supported with my SCXI-1600 board? 

 

lnDAQStatus = DAQmxRegisterEveryNSamplesEvent(mDAQTask, DAQmx_Val_Acquired_Into_Buffer, _
        mScansPerSample, CLng(1), AddressOf TCChannelsMgr_DAQNSamplesDoneEventHandler, Null)

 

Thanks,

 

Mike 

0 Kudos
Message 15 of 15
(1,050 Views)