Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Start multiple analog input tasks simultaneously using DAQmx C API

I need to synchronize the start of 8 analog input tasks using DAQmx C API.

TaskHandle* task_handles = new TaskHandle[8];
float64 sample_size = 40000;
float64 rate = sample_size * 100;
for (int i = 0; i < 8; ++i) {
  // initialize task
  DAQmxCreateTask("", &task_handles[i]);
  std::stringstream resource_name;
  resource_name << "PXI1Slot1" << i << "/ai0:3";
  DAQmxCreateAIVoltageChan(task_handles[i], resource_name.str().c_str(), "",
                           DAQmx_Val_Cfg_Default, -1.0, 1.0, DAQmx_Val_Volts,
                           NULL);

  // configure task details
  DAQmxCfgDigEdgeStartTrig(task_handles[i], "What trigger should I use?",
                           DAQmx_Val_Rising);
  DAQmxCfgSampClkTiming(task_handles[i], "OnboardClock", rate, DAQmx_Val_Rising,
                        DAQmx_Val_ContSamps, sample_size);
  DAQmxRegisterEveryNSamplesEvent(task_handles[i],
                                  DAQmx_Val_Acquired_Into_Buffer, sample_size,
                                  0, EveryNCallback, this);
}

// start tasks
for (int i = 0; i < 8; ++i) {
  DAQmxStartTask(task_handles[i]);
}

I tried to set a start trigger for the 8 tasks but I could not identify the correct trigger:

http://zone.ni.com/reference/en-XX/help/370466V-01/mxcncpts/termnames/

 

For example, PFI0 is not what I need because I do not intend an external source for synchronization.

 

I know this is a rather simple question, but how can I start the 8 tasks simultaneously?

 

You may suggest me to combine the 8 input tasks into a single task. I have tried it. It works but the data acquisition becomes incredibly slow. So let's assume that the merging of tasks is not an option.

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

Hello MisplacedPouch,

 

Which hardware are you using? 

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

I am using eight PXIe-6124 modules connected to a PXI Chassis PXIe-1075.

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

After going through many kinds of documentation, I have finally figured out a fix.

The solution is to export the StartTrigger of any one task using DAQmxExportSignal.

Then all the other tasks should be configured to start upon the exported signal using DAQmxCfgDigEdgeStartTrig.

 

I will post a more detailed version of the solution later.

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

The solution is to export the StartTrigger of any one task using DAQmxExportSignal.

Then all the other tasks should be configured to start upon the exported signal using DAQmxCfgDigEdgeStartTrig.

Yes, *AND* make sure the task that exports is the one you start *last*.  That way all the others are running and waiting for the trigger signal when it asserts.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 5
(2,179 Views)