Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

simultaneous ansi-c read

Hi,

Is the ansi-c api thread safe? Shall I use threads to do simultaneous read/write or is there an other way (like combining actions to the same task?)

Thanks...
0 Kudos
Message 1 of 7
(3,449 Views)
Hi pm100,
   actually I don't know about thread safety of ansi-c functions, I think that ANSI-c standard does not care about thread safety.

   Anyway, can you explain better your measurement task? Because with a "smart" use of DAQ driver you can, in most cases, perform all operations from a single thread.

  Please, let me know!

graziano

PS.: if anyone has infos on ANSI-c/thread safety, he's wellcome!
0 Kudos
Message 2 of 7
(3,405 Views)
The NI-DAQmx ANSI C API, like all NI-DAQmx APIs, is thread safe.

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
Message 3 of 7
(3,399 Views)
Hi,

Thanks for the answers. What is the correct approach to read signals say from two analog channels /Dev1/ai0 and /Dev1/ai1? Execute the Read commands one after each other in the same thread or divide the program into couple of threads and each thread manages seperate read?


0 Kudos
Message 4 of 7
(3,393 Views)
Well, in this case, you can't use multiple threads. Since there is only a single AI timing engine on the device, both channels must reside in the same task. In this case, I would simply read both channels at the same time with a single read command.

geoff
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 5 of 7
(3,328 Views)
I see, so there is no general method that would fit to every simul. case. Is there a document you would recommend for programming tips on this. Because I don't want to ask every time I have a different case like read and write at the same time, analog read/write + digital read/write at the same time etc....

Thanks again.
0 Kudos
Message 6 of 7
(3,324 Views)
Hi pm100,

I'm not sure if you've seen these already, but there are a few ANSI C examples that are installed with the DAQmx driver.  More specifically, there are some synchronization examples that install by default to the directory "C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Synchronization".  These should give you a good idea of where to start. 

There are also a couple of excellent tutorials that discuss synchronizing DAQmx tasks.  These are linked below:

Timing and Synchronization Features of NI-DAQmx

Advanced Data Acquisition Series - Synchronization with NI LabVIEW and NI-DAQmx

Though the examples are written in LabVIEW, the same concepts will apply to an application written in C.  Also, since the DAQmx driver is very consistent between API's, there is essentially a one-to-one correlation between the LabVIEW functions and the C functions. 

I hope this information helps!

Best regards,
0 Kudos
Message 7 of 7
(3,320 Views)