Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

multithreaded application using NIDAQmx

Hi,

     I intend to use NIDAQmx driver for PCI-6251 card in Linux environment for a multithreaded application. That is, I want to Process buffer 1 while transmitting/receiving buffer 2 and so on. I just installed Nidaqmx driver and found that example programs don't quite do that.

Could someone suggest how to implement the aforesaid functionality ?.

 

Malik

 

0 Kudos
Message 1 of 8
(3,972 Views)
How many analog inputs and outputs are you working with? The 6251 multiplexes the analog inputs, so there isn't anything like buffer 1 and buffer 2. What exactly is it that you are trying to do?
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 8
(3,968 Views)

Hi,

   Thanks for the reply. I am developing an application on Linux using NIDAQmx in which I send a buffer via analog output channel 0 and at the same time receive the same buffer at AI I/P channel 0 (both the analog output and analog input tasks are synchronised and I use only two channels). Once I receive the buffer I process that and then go back in a while loop to transmit & receive the next buffer. So the structure is like this:

 

While (for iteration 'i')

{

 transmit(Buffer i);

 receive (Buffer i);

 process (Buffer i);

 }

 

The processing of buffer i takes a finite time so I want to implement a parallel functionality such that while 'transmitting and receiving Buffer i', I could also process buffer i-1. In this way I intend to keep on acquiring data without any delay while also outputting processed data without any delay. Since the time to process a buffer is less than the time to transmit/acquire the buffer, I think the while structure as shown in the NiDAQmx examples is not right for this and we may need to implement the data acquisition and processing as separate threads.

 

Malik

 

0 Kudos
Message 3 of 8
(3,959 Views)
If I understand you correctly, you are right. We have a design pattern in LabVIEW which is known as the Producer/Consumer design pattern. You can have a look at a template by navigating to (File -> New..) and looking in Design Frameworks. You can have your DAQ done in the producer loop and have the data processed in the consumer one. If you still have doubts, be sure to post an example application and we can help you out over here.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 8
(3,945 Views)
As I need to implement the aforesaid functionality on Linux using gcc compiler (and not Labview), I was looking for some ansi_c example aplications in Nidaqmx folder. I couldn't find any particular example there that implements 'producer' and 'consumer' threads in parallel. Since i haven't install LabVIEW, is it possible to have a look at the code template that you mentioned so that I could modify it to compile with gcc and run on linux machine.
0 Kudos
Message 5 of 8
(3,931 Views)

2009-06-11_191820.jpg

 

Regards,

Glenn

Applications Engineer

National Instruments


Regards,
Glenn
0 Kudos
Message 6 of 8
(3,919 Views)

Hi Glenn,

             Thanks for the reply. Is it possible if you could post the underlying C-code (that uses NIDAQmx driver API functions) to perform the same producer/consumer design pattern ?.

 

cheers,

Adeel

0 Kudos
Message 7 of 8
(3,911 Views)

Hello Adeel,

 

The Producer/Consumer loop we provide in LabVIEW utlizes the same layout as c programmers using semaphores and multiple threads. Just include the DAQmx API in the following code I found online utilizing multithreads. A simple web search of "producer consumer c" populated the following links.

 

http://procrastinationrising.com/pthread-producer-consumer-example-in-c/

http://www.cs.arizona.edu/~greg/mpdbook/programs/pc.sems.c

 

-Glenn

 


Regards,
Glenn
0 Kudos
Message 8 of 8
(3,881 Views)