Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

enrouting secuencially with ctr0internaloutput

Hi at all,
 
I would to write digital lines sequentially; first in line 0 and when it is finished in another line to not use a demux hard.
 
I've done a program to control step motors and i have to control three motors. For that i have to switch the digital lines when a writing task is done.
 
Then, I've used the C function RegisterDoneEvent and it works well; but to switch digital lines i have to enrouting each time a counter (ctr0) and i have problems with that. i don't know if that is possible.
 
Here a cut of my program when it is called the function RegeisterDoneEvent
 

int32 CVICALLBACK DoneCallback(TaskHandle DOytaskHandle, int32 status,

void *callbackData)

{

int32 error=0;

char errBuff[2048]={'\0'};

TaskHandle DOztaskHandle=0;

TaskHandle DOzataskHandle=0;

uInt64 uInt64Samples_z=800;

int32 Int32Samples_z=800;

uInt8 bit[1];

float rate=2000;

bit[0]=1;

// Check to see if an error stopped the task.

DAQmxErrChk (status);

printf(

"tasca2\n");

DAQmxErrChk (DAQmxStopTask(DOytaskHandle));

DAQmxErrChk (DAQmxStopTask(taskHandleCtr));

DAQmxErrChk (DAQmxClearTask(DOytaskHandle));

DAQmxErrChk (DAQmxClearTask(taskHandleCtr));

DAQmxErrChk (DAQmxCreateTask(

"",&DOztaskHandle));

DAQmxErrChk (DAQmxCreateTask(

"",&DOzataskHandle));

DAQmxErrChk (DAQmxCreateTask(

"",&taskHandleCtr));

DAQmxErrChk (DAQmxCreateDOChan(DOztaskHandle,

"Dev1/port0/line4","",DAQmx_Val_ChanForAllLines));

DAQmxErrChk (DAQmxCfgSampClkTiming(DOztaskHandle,

"/Dev1/Ctr0InternalOutput",1000,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,uInt64Samples_z)); Here the problem!!!!!

DAQmxErrChk (DAQmxCreateDOChan(DOzataskHandle,

"Dev1/port0/line5","",DAQmx_Val_ChanForAllLines));

DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr,

"Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,rate,0.5));

DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr,DAQmx_Val_FiniteSamps,uInt64Samples_z));

DAQmxErrChk (DAQmxWriteDigitalLines(DOzataskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,bit,NULL,NULL));

DAQmxErrChk (DAQmxWriteDigitalLines(DOztaskHandle,Int32Samples_z,0,10.0,DAQmx_Val_GroupByChannel,DOdata,NULL,NULL));

DAQmxErrChk (DAQmxStartTask(DOztaskHandle));

DAQmxErrChk (DAQmxStartTask(DOzataskHandle));

DAQmxErrChk (DAQmxStartTask(taskHandleCtr));

Error:

if( DAQmxFailed(error) ) {

DAQmxGetExtendedErrorInfo(errBuff,2048);

DAQmxClearTask(DOytaskHandle);

printf(

"DAQmx Error: %s\n",errBuff);

}

return 0;

}

 

 

If somebody has had a similar problem please contact me;

 

Thanks at all,

 

0 Kudos
Message 1 of 2
(3,092 Views)

Hello Novice22:

The easiest way to know where is the problem is to track the error code. What is the error code and error text you have had with this code? or if you don't have any error, can you describe the unexpected behavior?

Thanks,

0 Kudos
Message 2 of 2
(3,054 Views)