LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

threading and ni6515

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)  
 

0 Kudos
Message 1 of 5
(2,546 Views)

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.

0 Kudos
Message 2 of 5
(2,496 Views)

 

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?

0 Kudos
Message 3 of 5
(2,495 Views)

hendra@ngms                       

 

Thank you for the reply, I will have a look into what you said about the permanent loop and changing bits etc.

 

0 Kudos
Message 4 of 5
(2,491 Views)

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...

0 Kudos
Message 5 of 5
(2,477 Views)