06-16-2010 12:16 PM
Hey folks,
I´m stuck with a strange problem:
I would like to do pulse counting with a PCI 6221. I have two counters and I´m using at the moment one of the counters to create a continuous pulse train as the sample clock for the second counter.
Like:
-Create Pulse Train Task
//DAQmxErrChk (DAQmxCreateTask("ContPulseTrain",&pulseTaskHandle));
//DAQmxErrChk (DAQmxCreateCOPulseChanTime (pulseTaskHandle,"Dev2/ctr1","",DAQmx_Val_Seconds ,DAQmx_Val_Low, 0.0, pulseTime, pulseTime));
//DAQmxErrChk (DAQmxCfgImplicitTiming(pulseTaskHandle,DAQmx_Val_ContSamps,1000));
-Create Counter Edge Task
//DAQmxErrChk (DAQmxCreateTask("CounterTask",&ctrTaskHandle));
//DAQmxErrChk (DAQmxCreateCICountEdgesChan(ctrTaskHandle,"Dev2/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp));
//DAQmxErrChk (DAQmxCfgSampClkTiming(ctrTaskHandle,"Ctr1InternalOutput",1,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
- Starting tasks
- Reading within a loop the desired amount of data
//DAQmxErrChk (DAQmxReadCounterScalarU32 (T.ctrTaskHandle, 10.0, &databuff1, NULL));
-Ending tasks
//DAQmxStopTask(T.ctrTaskHandle);
//DAQmxStopTask(T.pulseTaskHandle);
//DAQmxClearTask(T.ctrTaskHandle);
//DAQmxClearTask(T.pulseTaskHandle);
This works, even the NISpy document shows no error, until the DAQmxStopTask(T.ctrTaskHandle) command causes the whole programm to freeze. Actually, StopsTask gives no response. The pulse train task tested seperatly works (and terminates) perfectly and the counter task also. But using both together starts to make problems.
I updated the driver to the latest version and as far as I can see I have the Service Pack 2 installed on my windows machine.
I would appreciate any hints, cause I´m a little clueless.
Thanks!
sawi
06-18-2010 08:23 AM
sawi,
i am not sure if this is the cause of the issue, but i see that you are reading scalar values in your loop. Is it possible, that you are reading much slower than the the pulse train?
Another question: What is the programming environment you are working with (CVI, VC, ...)?
What happens if you just skip the StopTask and only call ClearTask?
Norbert
06-22-2010 04:43 AM
Hey Norbert,
thanks for your reply! Skip the StopTask did not change anything and the programming environment is VC.
But I finally found a solution. I moved my whole programm to another machine, which is much newer than the other one and now it works. Maybe the actual NI-drivers don´t work properly on an older computer with an Win XP, which wasn´t updated for a longer time. (Even with Service Pack 2 installed)