ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

error 'DAQmxErrorSamplesWillNeverBeGenerated'

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 ...
0 Kudos
Message 1 of 5
(3,243 Views)
Please note the following correction:
DAQmxWriteBinaryI32( hAO, 100, ...

should be changed to:
DAQmxWriteBinaryI32( hAO, ictSamples, ...
0 Kudos
Message 2 of 5
(3,237 Views)
hello I B,

Two suggestions for you:
1- Do not configure the output buffer. "NI-DAQmx automatically configures the buffer when you configure sample timing" I took this quote directly out of the NI-DAQmx C Reference Help.

2- Start the task and only stop it once you are done.

Hope this helps.
0 Kudos
Message 3 of 5
(3,212 Views)
Hello Serge,

1. The documentation states, "If you do not configure the buffer size using DAQmxCfgOutputBuffer, NI-DAQmx automatically configures the buffer when you configure sample timing". So the buffer can be manually allocated using 'DAQmxCfgOutputBuffer'. The error still occurs regardless of whether the buffer is manually/automatically allocated.

2. The task is supposedly automatically started/stopped by passing the argument 'AutoStart=TRUE' to the function 'DAQmxWriteBinaryI32'. I will try your suggestion of manually starting/stopping the task.

Ian
0 Kudos
Message 4 of 5
(3,207 Views)
OK Ian,

Let me know how it goes.

@I B wrote:
Hello Serge,

1. The documentation states, "If you do not configure the buffer size using DAQmxCfgOutputBuffer, NI-DAQmx automatically configures the buffer when you configure sample timing". So the buffer can be manually allocated using 'DAQmxCfgOutputBuffer'. The error still occurs regardless of whether the buffer is manually/automatically allocated.

2. The task is supposedly automatically started/stopped by passing the argument 'AutoStart=TRUE' to the function 'DAQmxWriteBinaryI32'. I will try your suggestion of manually starting/stopping the task.

Ian


0 Kudos
Message 5 of 5
(3,194 Views)