05-09-2017 05:41 AM
Is it possible to call DAQmxWriteDigitalLines in different threads for different lines? or will every call have to be thread locked?
DAQmxCreateTask ("", &DOCARD);
DAQmxCreateDOChan (DOCARD, text, "",DAQmx_Val_ChanPerLine);
DAQmxStartTask(DOCARD);
DAQmxWriteDigitalLines (DOCARD, 1, 1, 10,
DAQmx_Val_GroupByScanNumber,
&DOArray[0],
DAQmxStopTask(DOCARD) ;
DAQmxClearTask(DOCARD)
05-10-2017 09:08 AM
There are ways to do this asynchronously that I use in many projects. But asynchronously means that digital output changes will happen at a determined rate, but not instantaneously as might happen if you change bits within the thread.
One method is to write to your digital card each time your analog input interrupts. If you have no analog interrupting, then set up a "permanent" thread, using a while loop with time delay (Sleep(25) as an example) that does nothing but send changes to the DO card. Inside your threads you change bits in the common memory integer that is written to the DO card at regular intervals.
05-10-2017 09:10 AM
In thread One I create a Task for an individual channel write
In thread Two I create a Task for an individual channel write
Each thread will have a different task name and channels will not overlap.
Can daqmx allow two threads to use different task calls at the same time?
05-10-2017 09:16 AM
Thank you for the reply, I will have a look into what you said about the permanent loop and changing bits etc.
05-11-2017 09:22 AM
I use a bit structure as the common memory element when doing digital I/O. I can give you some more info on that if you need.
Regards...