Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Write Current Write Position Property is wrong in continuous AO

I've got a continuous AO task, and the user interrupts this at some unknowable point (e.g. when he's bored).

At this point, I want to know the current value of the AO channel. I'm writing a waveform to the task in continuous mode and figured that the easiest way would be to read the number of samples generated and then index the waveform to get the value.
 
However, on stopping the task, the DAQmx Write: Current Write Position property returns the final value in the waveform, not the current value.
 
I read a similar problem here, where billings11 experienced the same issue. He also noted the same behaviour I see, which is that this property updates correctly if the task is still running; the problem here being that the Current Write Position will lag behind the true value as the AO task continues to write.

One solution was to configure a counter to count the number of clock edges. Is this the only way to do this? Why doesn't the property appear to work correctly?
0 Kudos
Message 1 of 4
(3,828 Views)
Sorry, here
0 Kudos
Message 2 of 4
(3,822 Views)

The property tracks data as it is transferred from your host memory buffer to the device, not when the data is written to the DAC and output to your bored subject. Depending on which device you are using as much as 2K samples may be buffered on the device. Even more on some devices.

Your idea of using a counter to count the ao/SampleClock pulses is a good one. You can also shrink the onboard memory to its minimum and the property will track the output more closely. You don't say what kind of device you are using. If it is an E or M Series device you can set the Data Transfer Request Condition to Onboard Memory Empty. This will result in the property being only 2 or 3 samples off.

Message 3 of 4
(3,813 Views)
And you are looking at the wrong property. Try the Total Samples per Channel Generated property. You will have to mod it with your buffer size.
0 Kudos
Message 4 of 4
(3,810 Views)