10-22-2020 04:01 AM
Steps:
The Write Buffer is filled to 1000 Samples before Start.
After starting DAQmxGetWriteTotalSampPerChanGenerated is called immidiately.
Issue:
DAQmxGetWriteTotalSampPerChanGenerated for NI USB - 6001 return 1000 samples.
But, for other devices such as NI PCIe - 6363 (X series) and NI USB - 6211 it returns the actual value generated somewhere less than 10.
Attached:
6001_checkWriteTotalSampPerChanGenerated.nitrace - Output of NI USB 6001
6211_checkWriteTotalSampPerChanGenerated.nitrace - Output of NI USB - 6211
test.c - Code to reproduce
10-22-2020 02:35 PM
I did some thread searching just now but came up (mostly) empty-handed. I remember at least reading if not participating in prior discussions about some odd observations when using this property. The closest thread I found is a very old one I was in, but that's not the one I was trying to find.
Anyway, here's my take based on a combination of memory and inference. There are circumstances where the TotalSampPerChanGenerated property refers *merely* to the # samples the driver has delivered from the task buffer to the device. The old linked thread is one of them. I *think* that (some) USB-connected devices might be another.
If so, then what you see with your low-cost USB-6001 device is that the driver has decided it should transfer all the data to the device as quickly as possible (and the device has a big enough onboard FIFO buffer to receive all of it). So you start the task, the driver immediately transfers data, and then you query the property and it tells you that *all* the samples have been *generated*. In fact, they haven't. It's just that the kind of low-latency two-way communication needed for a more accurate assessment of *actual* generation progress isn't available in the DAQmx driver for your USB-6001 device. So it reports the next best thing -- how many samples have been *delivered* to the board.
There's a thread within the last several months where this was explained more clearly by someone from NI, maybe your search skills are enough better than mine that you can find it.
Bottom line though is that this is more like a design decision than a bug waiting to be fixed. You shouldn't expect the difference in behavior to change in the future.
-Kevin P
10-26-2020 11:32 PM
Hi Kevin,
Thanks for the info.
Currently for all devices we are relying on DAQmxGetWriteTotalSampPerChanGenerated, to stop the analog write.
10-27-2020 11:33 AM
Currently for all devices we are relying on DAQmxGetWriteTotalSampPerChanGenerated, to stop the analog write.
Unfortunately, you probably simply can't continue with that strategy despite how obvious and sensible it may seem. But couldn't you just configure your tasks for Finite Sampling?
-Kevin P