Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

porting GPCTR_Watch to NI-DAQMX

I have an application that performs a double-buffered AI acquisition, and starts the counters at the same time using the following code.  This application communicates with a separate process, and this second process uses the GPCTR_Watch function to determine the timing of certain events.  How do I convert the following code to NI-DAQmx, and does NI-DAQmx even allow a separate process to read a counter that another task created and started running?

 

/**************process 1************/

  GPCTR_Control(1, ND_COUNTER_0, ND_RESET);
  GPCTR_Set_Application(1, ND_COUNTER_0, ND_SIMPLE_EVENT_CNT);
  GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_SOURCE, ND_INTERNAL_100_KHZ);
  GPCTR_Control(1, ND_COUNTER_0, ND_PREPARE);

  GPCTR_Control(1, ND_COUNTER_1, ND_RESET);
  GPCTR_Set_Application(1, ND_COUNTER_1, ND_SIMPLE_EVENT_CNT);
  GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE, ND_OTHER_GPCTR_TC);
  GPCTR_Control(1, ND_COUNTER_1, ND_PROGRAM);

  GPCTR_Control(1, ND_COUNTER_0, ND_ARM);                 //starts the counter
 

 /*************Process 2******************/

  GPCTR_Watch(1, ND_COUNTER_0, ND_COUNT, &count1);
  GPCTR_Watch(1, ND_COUNTER_1, ND_COUNT, &count2);
 

 

 

0 Kudos
Message 1 of 2
(2,241 Views)

DrewH,

 

NI-DAQmx can be accessed by multiple threads in the same process, but it cannot share tasks across processes.  Therefore you cannot create a task in one process (executable) and use it in another.  Legacy NI-DAQ Traditional was single-threaded.  Therefore, the same instance of the library was accessed by every process in the system.  As a result, you could not take advantage of the multiple cores or hyperthreading of modern processors.  When NI-DAQ was accessed from one process it blocked all other processes from running any NI-DAQ code until the process completed with its use of the driver.  NI-DAQmx is multi-threaded, allowing two tasks to be configured and executed in parallel if they do not share hardware resources.  However, with this addition two processes essentially access two completely different instances of the driver.  They must both check out resources from the same resource pool (which makes sure two processes don't step on each other's toes) but they do not share task references.  They are essentially two completely different programs with different memory allocations.

 

NI-DAQmx does provide a way to configure a task and save the settings to disk.  You could have one process configure parameters and save these parameters to disk, then have the other process load the same task and start it. I don't know if that would work for your application but that is one possible workaround.

 

Regards,

 

Neil S.

Multifunction DAQ

Product Support Engineer

National Instruments

 

 

 

0 Kudos
Message 2 of 2
(2,223 Views)