Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Get the number of samples on PCI-6221 CTR output

Hello!

I'm looking for an example in ANSI-C to the following problem. Let me try to explain the background:
I have connect a stepping motor at ctr1 and use to run it the function:

DAQmxCreateCOPulseChanFreq (*taskHandle, "Dev2/ctr1", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0,(float64) freq, 0.5));
DAQmxCfgImplicitTiming (*taskHandle, DAQmx_Val_ContSamps  ,1000);

So this works fine but now I want to get the sample number when the task is going to stop (how many samples were created since start). This value is important for further functions. I spent a lot of time on this and I don't really know how to fit the problem. Do I need to use the Event method which the card is providing? If yes, can anyone post a simple example. I've already looked at the NI-Examples but no one has match my problem.

I'm thankfull for any kind of answer.

Best regards
Oliver

0 Kudos
Message 1 of 3
(2,993 Views)
Dear Oliver

The only way to know exactly how many pulses have been generated is to use a second counter and count them; the DAQmx driver itself doesn't keep track of this. Fortunately, your 6221 board has two counters, so if your not doing finite pulse generation or anything else which requires both CTRs for a single task, you will be able to just use these.

Best regards

Philipp R.
0 Kudos
Message 2 of 3
(2,963 Views)
Hello Philipp!

Thanks a lot for your answer!
You're right, this card has two counters but unfortunately I need them both for output functions. I found an other way to count the pulses. I use the DAQmxRegisterSignalEvent function.
I am going to count every function call and divide the number through two. So I get exactly the number of pulses. I've tested this way with the Measurement and it seems to work.

Best regards
Oliver
0 Kudos
Message 3 of 3
(2,943 Views)