Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

change pulse length while task running

While a counter output task is running, can we change the pulse width or frequency?
 
Thanks!
0 Kudos
Message 1 of 3
(4,179 Views)

I managed to get it done with this, but I don't know if it's the best solution.

 while(ApplicationIsRunning)
 {

  ErrorCode = DAQmxIsTaskDone (PulseHandle, &TaskDone);
  if (TaskDone)
  {
   DAQmxStopTask(PulseHandle);

   DAQmxSetCOPulseLowTime(PulseHandle, "/Dev1/ctr2", Delay);
   DAQmxSetCOPulseHighTime(PulseHandle, "/Dev1/ctr2", PulseLength);
   DAQmxSetCOPulseTimeInitialDelay(PulseHandle, "/Dev1/ctr2", Delay);

   //DAQmxClearTask(PulseHandle);
   DAQmxStartTask (PulseHandle);
  }

}
  

0 Kudos
Message 2 of 3
(4,166 Views)

Hello physicien nocturne,

According to this KnowlegeBase article (How Can I Change the Duty Cycle on My Continuous Pulse Train?) you should be able to change the duty cycle on the fly if you also set the frequency.  This KnowlegeBase article shows how to do it in LabVIEW, but for text based you should use a DAQmxWriteCtrFreq (or DAQmxWriteCtrFreqScalar) function call.  This should allow you to change the duty cycle without stopping the task.

I hope this helps, and have a great day!

Cheers,

Brooks
0 Kudos
Message 3 of 3
(4,151 Views)