03-15-2019 08:27 AM
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.
03-19-2019 09:43 AM
Hello MisplacedPouch,
Which hardware are you using?
03-19-2019 11:17 PM
I am using eight PXIe-6124 modules connected to a PXI Chassis PXIe-1075.
03-19-2019 11:24 PM
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.
03-20-2019 11:16 AM
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