02-27-2017 03:48 PM
I'm using DAQmxWriteAnalogF64() to write arrays of values to an analog output channel. It works fine the first time DAQmxWriteAnalogF64() called. The second call fails as follows:
Function DAQmxWriteAnalogF64: (return value == -200288)
Attempted to write a sample beyond the final sample generated. The
generation has stopped, therefore the sample specified by the
combination of position and offset will never be available.
Specify a position and offset which selects a sample up to, but not
beyond, the final sample generated. The final sample generated can be
determined by querying the total samples generated after a generation
has stopped.
Attempted to Write Sample: 101
Property: DAQmx_Write_RelativeTo
Corresponding Value: DAQmx_Val_CurrWritePos
Property: DAQmx_Write_Offset
Corresponding Value: 0
If I delete the task and create it again every time I call DAQmxWriteAnalogF64() everything works fine. But surely that's not the "right" way. Or is it?
The error message seems to indicate that subsequent calls to DAQmxWriteAnalogF64() add the new array of samples to the end of some output buffer. How do I tell it to start over at the beginning of the buffer each time DAQmxWriteAnalogF64() is called?
All I want DAQmxWriteAnalogF64() to do is transmit an array of samples I provide each time I call it. It works on the first call only.
How do I "specify a position and offset" as directed in the above text?
How do I "querying the total samples generated" as directed?
Is it possible to reset the task without deleting and recreating it each time I call DAQmxWriteAnalogF64()?
I found a function that appears to change an attribute of the task from "relative" to "offset" positioning of the buffer pointer. But the function doesn't provide enough parameters to do what it says it does. The function is DAQmxResetWriteAttribute(). It has an attribute called "Relative To". The help text says to specify a value for the attribute of either DAQmx_Val_FirstSample or DAQmx_Val_CurrWritePos, but there's no parameter available to do that.
Please help, I'm lost!
Solved! Go to Solution.
02-28-2017
03:11 AM
- last edited on
11-18-2024
11:28 AM
by
Content Cleaner
Hello,
I'm not familiar with output generation but I made some search on the help and I seem to understand that that error arises when you have regeneration mode active on the output channel, which should be the default condition; regeneration means the DAQ board will reuse samples in the buffer to regenerate the output signal when it has finished outputting it. To exclude regeneration you must issue this command:
DAQmxSetWriteAttribute (taskHandle, DAQmx_Write_RegenMode, DAQmx_Val_DoNotAllowRegen);
The side effect of this setting is that you must continuosly provide AO samples to the daq board (i.e. putting the write operation in a loop), since it will no more reuse previous samples to generate output data; nevertheless, you can change the signal to output simply changing the values in the buffer passed to the board.
I have found a CVI example that shows these settings:
DAQmx - Continuously Generate Voltage - Non-Regeneration - LabWindows/CVI
An alternative to this solution is to stop the task and write the new buffer to the board when you need to change the output signal, which may match with your requirements or not.
Some references to the error you are getting can be found in the following links: some of the documents are aimed to LabVIEW users but the concepts described apply to CVI as well.
Analog Output Regeneration in NI-DAQmx
Analog Output Regeneration Modes
Data Transfer Request Condition for Continuous Analog Output using NI-DAQmx
02-28-2017 02:37 PM
Thanks Roberto. Sure would help if NI would try a little harder to explain what goes on under the hood.