The error 'DAQmxErrorSamplesWillNeverBeGenerated' is generated when attempting to use the DAC on the 6225 to output a signal. A description of how to replicate the problem is provided below. I would appreciate any comments/suggestions that will help correct the problem.
Thanks
Ian
My application is written using Micrsoft Net VC++ compiler under WinXP PRO. The application is designed to output a square wave, 2 or more times, via the DAC. The duration of each square wave is 10ms and the time between them is 1 to 10 seconds.
The code provided below illustrates how the problem can be replicated. The signal is successfully output a first time. However, the error occurs when the function 'DAQmxWriteBinaryI32' is executed the second time. The error code produced is 'DAQmxErrorSamplesWillNeverBeGenerated' and the corresponding text message is:
"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".
The following code illustrates how to replicate the problem. Note, this is not the actual code I use but it does illustrate the actual function calls, function arguments and calling function sequence used.
int32 aiData[10] = { 0, 32000, 32000, 32000, 32000, 32000, 32000, 32000, 32000, 0 };
int ictSamples = 10;
TaskHandle hAO; // handle for analog output
VERIFY( DAQmxCreateTask( "AO", &hAO ) == 0 );
VERIFY( DAQmxCreateAOVoltageChan( hAO, "6225a/ao0", "", -10, 10, NULL ) == 0 );
float64 fSamplingRate = 1000.0; // 1000Hz signal
for( int ix = 0; ix < 10; ++ix ) {
VERIFY( DAQmxCfgOutputBuffer( hAO, ictSamples ) == 0 );
VERIFY( DAQmxCfgSampClkTiming( hAO, "", fSamplingRate, DAQmx_Val_Rising,
DAQmx_Val_FiniteSamps, ictSamples ) == 0 );
// error occurs the second time (i.e. ix == 1) that the following function is executed
int32 ictSamplesWritten;
int32 iStatus = DAQmxWriteBinaryI32( hAO, 1000, TRUE, 10.0, DAQmx_Val_GroupByScanNumber,
aiData, &ictSamplesWritten );
VERIFY( 0 == iStatus );
VERIFY( ictSamplesWritten == ictSamples );
// wait before presenting next square wave
::Sleep( 1000 + (rand() % 9000) );
}
... cleanup and shut down code ...