I'm trying to write a very simple application that sends out an analog
waveform, of which the user (myself) can increse/decrease the
amplitude by pressing a button. This is my init code (amplitude
starting at 4.0):
ampl = 4.0;
for(int i=0;i<1000;i++)
data[i] = ampl*sin((double)i*2.0*PI/1000.0);
DAQmxCreateTask("",&taskHandle);
DAQmxCreateAOVoltageChan(taskHandle,"Dev1/
ao1","",-5.0,5.0,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(taskHandle,"",
1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);
DAQmxWriteAnalogF64(taskHandle,
1000,0,0.0,DAQmx_Val_GroupByChannel,data,&res,NULL);
DAQmxStartTask(taskHandle);
then i have 2 routine which adjust ampl, refill the data array and
call Write again :
if (ampl < 10)
ampl++;
for(int i=0;i<1000;i++)
data[i] = ampl*sin((double)i*2.0*PI/1000.0);
int32 res;
DAQmxWriteAnalogF64(taskHandle,
1000,0,0.0,DAQmx_Val_GroupByChannel,data,&res,NULL);
this works nicely, but whenever I press the up or down buttons, it
takes around 8 seconds before my oscilloscope sees the changes !!
Somehow, the new data is only inserted after a long time
what am I doing wrong ???