10-19-2016 03:00 PM - edited 10-19-2016 03:01 PM
I'm using the NI-DAQmx C API to read data from a cDAQ-9188
I'm able to read analog voltages and digital inputs fine (NI9201 and NI375).
Having problems with Counters (measuring frequency) (NI9411).
I just get error "Some or all of your samples have not yet been acquired" after timeout.
My pseudo-source:
DAQmxCreateTask("", &taskHandle);
DAQmxCreateCIFreqChan(taskHandle, "cDAQ9188-189E9F4Mod1/ctr0", "", 1, 1000, DAQmx_Val_Hz, DAQmx_Val_Rising, DAQmx_Val_LowFreq1Ctr, 0.1, 1, NULL);
DAQmxCfgSampClkTiming(taskHandle, "pfi0", 5.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 5);
DAQmxStartTask(taskHandle);
DAQmxReadCounterU32(taskHandle, 5, 10.0, (uInt32*)data, 5, &read, NULL);
Are my device names and everything else correct?
Thanks.
Solved! Go to Solution.
10-20-2016 09:03 AM
Have you compared it against the C api examples? I believe you have the option to install the examples when you install the daqmx drivers.
If you have done that and it seems the same then I'd say you should try troubleshooting if you are producing any data at all.
-Bear
10-20-2016 09:07 AM
I'll see if I can find the examples.
I know there is data, it works fine is SignalExpress.
10-20-2016 02:12 PM
Using the examples I changed my code to this:
DAQmxCreateTask("", &taskHandle); DAQmxCreateCIFreqChan(taskHandle, "cDAQ9188-189E9F4Mod1/ctr0", "", 1, 1000, DAQmx_Val_Hz, DAQmx_Val_Rising, DAQmx_Val_LowFreq1Ctr, 0.1, 1, NULL); DAQmxSetCIFreqTerm(taskHandle, "cDAQ9188-189E9F4Mod1/ctr0", "/cDAQ9188-189E9F4Mod1/pfi0");
DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_ContSamps, samples);
DAQmxStartTask(taskHandle); DAQmxReadCounterU32(taskHandle, 5, 10.0, (uInt32*)data, 5, &read, NULL);
But the data returned is VERY high. I should be getting 100 - 200Hz but the data returned is 300,000Hz to 700,000Hz.
10-20-2016 02:34 PM
Got it working!!!
Final code:
DAQmxCreateTask("", &taskHandle); DAQmxCreateCIFreqChan(taskHandle, "cDAQ9188-189E9F4Mod1/ctr0", "", 1, 1000, DAQmx_Val_Hz, DAQmx_Val_Rising, DAQmx_Val_LowFreq1Ctr, 0.1, 1, NULL); DAQmxSetCIFreqTerm(taskHandle, "cDAQ9188-189E9F4Mod1/ctr0", "/cDAQ9188-189E9F4Mod1/pfi0"); DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_ContSamps, samples); DAQmxStartTask(taskHandle); DAQmxReadCounterF64(taskHandle, 5, 10.0, (float64*)data, 5, &read, NULL);
Have to use the right ReadCounter function and use the ImplicitTiming.
Thanks!!
10-26-2016 06:14 AM
We'll I've built my own data acquisition software using NI C/C++ API.
Check it out at http://jfdatalogger.sourceforge.net
Thanks
10-27-2016 08:13 AM
Props for posting your code!
Thanks for contributing. Seems legit to me!
-Bear