Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make the analog output determined after stopping the task

This is part of the program
"
 
// build up a rect waveform
memset(m_Data,0,m_nSampleNumber*sizeof(double));
  for(int i=0;i<m_PulseDutyFactor;i++)
  {
   m_Data[i]=m_nMagnitude;
   
  }
 ///  build up the task
  DAQmxErrChk(DAQmxCreateTask("",&m_TaskHandle));
  DAQmxErrChk(DAQmxCreateAOVoltageChan(m_TaskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
  DAQmxErrChk(DAQmxCfgSampClkTiming(m_TaskHandle,"",m_nFreq*1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,m_nSampleNumber));
  long written;
  DAQmxErrChk(DAQmxWriteAnalogF64(m_TaskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,m_Data,&written,NULL));
  // start the task
  DAQmxErrChk(DAQmxStartTask(m_TaskHandle)); 
  
  
....
 
/// change the output waveform (change the pulse duty factor )
 
if( m_TaskHandle!=0 ) {     
  double mag=m_nMagnitude;
  m_PulseDutyFactor=pdf;
  long written;
  memset(m_Data,0,m_nSampleNumber*sizeof(double));
  for(int i=0;i<m_PulseDutyFactor;i++)
  {
   m_Data[i]=m_nMagnitude;   
  }
  
  res=DAQmxStopTask(m_TaskHandle);
// restart the task
  res=DAQmxWriteAnalogF64(m_TaskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,m_Data,&written,NULL);  
  res=DAQmxStartTask(m_TaskHandle); 
 }
"
When I call "DAQmxStopTask", the task stop, but the analog output is random, sometimes it is zero and sometimes it is full-voltage (m_nMagnitude).
The question is:
Could I make the output on some determined value eg. full-voltage (m_nMagnitude)?
Or there some better sollution for me to change the continuous output waveform without a break (DAQmxStopTask) ?
0 Kudos
Message 1 of 2
(2,578 Views)
Is it possible or impossible?
 
Please help.
0 Kudos
Message 2 of 2
(2,568 Views)