Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

I have to control two step motors by a PCI6221 NIdaqmx with ansi c functions

I have to control two step motors and read an analogue signal.
I dispose on a PCI 6221 and a NIDAQmx 8.3 soft.
 
Two control these motors I need  two pulse train generation with different rates.
There is a problem on this program because i can't control two digital lines independently with different sample rates.
I've tried to route different clock sources as ai/sampleclock or ao/sampleclock and also different internal outputs of the two resources on counters...
 
I don't know if exists two resources of time independently
 
The code is:
 

DAQmxErrChk (DAQmxCreateTask(

"",&taskHandle));

DAQmxErrChk (DAQmxCreateTask(

"",&taskHandle2));

DAQmxErrChk (DAQmxCreateTask(

"",&taskHandleCtr));

DAQmxErrChk (DAQmxCreateTask(

"",&taskHandleCtr1));

 

DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0/line0","",DAQmx_Val_ChanForAllLines));

DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/Ctr0InternalOutput",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,Num_Samples));

DAQmxErrChk (DAQmxCreateDOChan(taskHandle2,

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

DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle2,

"/Dev1/Ctr1InternalOutput",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,Num_Samples));

DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr, "Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,rate,0.5));

DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr,DAQmx_Val_ContSamps,sampsPerChanToAcquire));

DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleCtr1,

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

DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandleCtr1,DAQmx_Val_ContSamps,sampsPerChanToAcquire));

DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));

/*********************************************/

// DAQmx Write Code

/*********************************************/

DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,Num_Samples,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));

DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle2,Num_Samples,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));

/*********************************************/

// DAQmx Start Code

/*********************************************/

DAQmxErrChk (DAQmxStartTask(taskHandle2));

DAQmxErrChk (DAQmxStartTask(taskHandle));

DAQmxErrChk (DAQmxStartTask(taskHandleCtr));

DAQmxErrChk (DAQmxStartTask(taskHandleCtr1));

0 Kudos
Message 1 of 2
(2,606 Views)
Hi,

as you mentioned it is not possible to generate the same signal with a diffrent clock. On a standart device you have for clocks: one for AI, one for AO, on for DIO and one for Counter.
If you dont wont to buy a second device, you could try to use AO where you generate a square signal with a diffrent rate from the counter. This would be a solution!

I hope this helps you, RMathews
Ramona Lombardo
Applications Engineer, NI Germany
Certified LabVIEW Developer
0 Kudos
Message 2 of 2
(2,578 Views)