I have read many messages indicating that DIO are software-time in the E-series (I own a 6034) however
I have got an idea that I don't see (yet) why it should not work.
As suggested by many, I am using a counter task to generate a single pulse which I want to use as a trigger in
my application.To trigger other devices, I would however prefer using a DI0 line instead of terminal CTR0_OUT (pin 2)
because it seems safer given the lower limits in sinking and sourcing current of the CTR0_OUT terminal.
To obtain an hardware-timed pulse on DIO0 with my 6034E, I had the idea of using two digital ouptut tasks. The
first task would start when a RISING edge is detected on CTR0_OUT (configured with DAQmxCfgDigEdgeStartTrig),
then it would put DIO0 in the HIGH state (using DAQmxWriteDigitalLines to write a single sample), and then it would
- I assume - automatically stops. The second task would put DIO0 in the LOW state when a FALLING edge
is detected on CTR0_OUT in a similar manner. My attempts to implement this approach have been unsucessful
but I do not understand exactly why it does not work (see code below).
Another question is what I need to add to my code so that I would get a new impulse each time
I start the counter task.
Thank you,
Gabriel
// Configure counter task
DAQmxErrChk( DAQmxCreateTask("",&mCtrTask));
DAQmxErrChk (DAQmxCreateCOPulseChanTime(
mCtrTask,
"Dev1/ctr0",
"",
DAQmx_Val_Seconds,
DAQmx_Val_Low, //int32 idleState: DAQmx_Val_High or DAQmx_Val_Low
0.000, // float64: initialdelay
0.001, // float64: lowtime (must be different from 0)
hightime)); // float64: hightime
// Configure digital output tasks
long sampsPerChanWritten;
unsigned char High[1]={1};
DAQmxErrChk(DAQmxCreateTask("",&mDigOut1Task));
DAQmxErrChk(DAQmxCreateDOChan(mDigOut1Task,"Dev1/Port0/line0","",DAQmx_Val_ChanForAllLines ));
DAQmxErrChk(DAQmxWriteDigitalLines(mDigOut1Task,1,true,1,DAQmx_Val_GroupByScanNumber,
High,&sampsPerChanWritten,NULL));
DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(mDigOut1Task,"Dev1/ctr0",DAQmx_Val_Rising));
unsigned char Low[1]={0};
DAQmxErrChk( DAQmxCreateTask("",&mDigOut2Task));
DAQmxErrChk( DAQmxCreateDOChan(mDigOut2Task,"Dev1/Port0/line0","",DAQmx_Val_ChanForAllLines ));
DAQmxErrChk( DAQmxWriteDigitalLines(mDigOut1Task,1,true,1,DAQmx_Val_GroupByScanNumber,
Low,&sampsPerChanWritten,NULL));
DAQmxErrChk( DAQmxCfgDigEdgeStartTrig(mDigOut2Task,"Dev1/ctr0", DAQmx_Val_Falling));
// trigger single pulse
DAQmxErrChk( DAQmxStartTask(mCtrTask));