Quantcast
Channel: Multifunction DAQ topics
Viewing all articles
Browse latest Browse all 6878

error in rewriting to the analog output buffer

$
0
0

Hi all,

  I am using 6711 card and trying to output some samples to analog channel. In the mid way, I will stop the task, redirect the buffer pointer, set the trigger mode and restart the task again. I try the following code

 

void output(void)
{
  double data[1000];
  for (int i=0; i<200; i++) data[i]=8.5;
  for (int i=200; i<700; i++) data[i]=4.2;
for (int i=700; i<800; i++) data[i]=3; for (int i=800; i<1000; i++) data[i]=0.0; DAQmxCfgSampClkTiming(AO_task, NULL, 100000, DAQmx_Val_Falling, DAQmx_Val_FiniteSamps,1000); DAQmxWriteAnalogF64(AO_task, 1000, 0, 10, DAQmx_Val_GroupByChannel, data, NULL, NULL); DAQmxStartTask(AO_task); Sleep(1); DAQmxStopTask(AO_task); // other calculation (not related to DAQ) DAQmxCfgDigEdgeStartTrig(AO_task, "/Dev1/PFI0", DAQmx_Val_Rising); DAQmxSetWriteAttribute(AO_task, DAQmx_Write_RelativeTo, DAQmx_Val_FirstSample); DAQmxSetWriteAttribute(AO_task, DAQmx_Write_Offset, 700); DAQmxStartTask(AO_task); // other calculation (not related to DAQ) DAQmxWaitUntilTaskDone(AO_task, 10); DAQmxStopTask(AO_task); }

 The task AO_task created somewhere else. Above function will be called several times. But I find that it is running without any problem for the first time. But if I call it again, the following error comes out 

 

"The generation is not yet started, and not enough space is available in the buffer.

 

Configure a larger buffer, or start the generation before writing more data than will fit in the buffer.

Property: DAQmx_Write_RelativeTo

Corresponding Value: DAQmx_Val_FirstSample

Property: DAQmx_Write_Offset

Corresponding Value:700

Property: DAQmx_Buf_Output_BufSize

Corresponding Value: 1000

 

Task Name: AO_task

Status Code:-200293"

 

I wonder what error is that, why can't I reset the pointer of the buffer. Thanks.


Viewing all articles
Browse latest Browse all 6878

Trending Articles