Hi all,
I'm trying to perform two separate acquisition simultaneously: an analog acquisition on some channels and a frequency measurement on a counter. The developing environment is CVI 7.1, using a PCI-6281 DAQ board, NI_DAQ 8.5.0f5
My problem is that the frequency comes from an encoder on a motor which is performing a speed ramp, so the period of the signal is not constant and I must syncronize speed values with analog measurements.
I have no access now to the device so I tried to develop a solution on a simulated device, my code is the following, on the simulated device it terminates with no error (but no measurements on Cdata

but this is probably due to the board being a simulated one):
// Create the analog task
DAQmxChk (DAQmxCreateTask ("Analog", &taskAI));
DAQmxChk (DAQmxCreateAIVoltageChan (taskAI, "/Dev1/ai0", "Voltage", DAQmx_Val_Cfg_Default, -5.0, 5.0, DAQmx_Val_Volts, ""));
DAQmxChk (DAQmxCfgSampClkTiming (taskAI, "OnboardClock", 1000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, size));
// Create the counter task
DAQmxChk (DAQmxCreateTask ("Counter", &taskCI));
DAQmxChk (DAQmxCreateCIFreqChan (taskCI, "/Dev1/ctr0", "Counter", 2.0, 100.0, DAQmx_Val_Hz, DAQmx_Val_Rising, DAQmx_Val_LowFreq1Ctr, 0.001, 4, ""));
DAQmxChk (DAQmxCfgImplicitTiming (taskCI, DAQmx_Val_FiniteSamps, size));
// Set counter task to share start with analog task
DAQmxChk (DAQmxSetTrigAttribute (taskCI, DAQmx_ArmStartTrig_Type, DAQmx_Val_DigEdge));
DAQmxChk (DAQmxSetTrigAttribute (taskCI, DAQmx_DigEdge_ArmStartTrig_Src, "/Dev1/AI/StartTrigger"));
// Start the tasks
DAQmxStartTask (taskCI);
DAQmxStartTask (taskAI);
// Wait until task done
while (!doneAI) {
DAQmxChk (DAQmxIsTaskDone (taskAI, &doneAI));
}
// Read measurements
DAQmxChk (DAQmxReadAnalogF64 (taskAI, DAQmx_Val_Auto, 0.0, DAQmx_Val_GroupByChannel, Adata, size, &sRead, 0));
DAQmxChk (DAQmxReadCounterF64 (taskCI, DAQmx_Val_Auto, 0.0, Cdata, size, &sRead, 0));
Question is: does this make sense at all? Can I expect it works on a real board the same as on the simulated one? And am I guaranteed that Cdata[n] was acquired exactly in the same moment as Adata[n]?
Since I am acquiring at very high rates, I can imagine that there isn't a new frequency measurement for every analog sample, so I suppose I will get an array of frequencies like that
[ 100.0, 100.0, 100.0, 110.0, 110.0, 110.0, 115.0, 115.0 ..... ] and so on, that is frequency measurement is repeated if there is no new value ready: is this true or am I doing wrong assumptions?