Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse generation for counting with USB-6211

I'm using a USB-6211 to count pulses that can vary in frequency from zero to about 5k.  I've tried using HighFreq1Ctr (using the 80 MHz time base) and feeding my pulses into the Gate of Counter 1.  This works fine as long as pulses are being generated but it gets timeouts when the frequency goes to zero.  If I set timeout value to -1 (infinite) it simply hangs, waiting for a pulse.  I'd like to have a way to simply report a frequency of zero and have it start measuring again, since the frequency will be changing continually.
 
I think this means I need to change to using the two counter method so I've changed to HighFreq2Ctr now feeding my pulses into the Source of Counter 1 and generating a pulse of known duration with Counter 0 for the Gate.  Hopefully this will measure the number of pulses within the "gate time". 
 
I am using these function calls to generate the pulses (which will be externally routed to the gate :
AGniDAQmx_CreateTask(instrHandle,"MotorSpeedFromSensors_,Task_Handle8)
AGniDAQmx_CreateCOPulseChanFreq(instrHandle, Task_Handle8,"Dev1/ctr0",DAQmx_Val_Hz,DAQmx_Val_Low,0,8.333,0.5)
AGniDAQmx_ClearTask(instrHandle,Task_Handle8)
 
However, no pulses are being generated.  I think it's because I don't have a ARM trigger to start the pulses.  How do I do this?  I'd like the counting/pulses to be continuous so the I just need a way to get them started.
 
Any help?
 
Thanks,
-CBJohnson
0 Kudos
Message 1 of 4
(4,185 Views)
I think I might have found the answer to my question in another thread.  I've added the "CfgImplicitTiming" command to the chain (shown below).
However, it still doesn't appear to be producing pulses.
 
Here's what I now have...
 
AGniDAQmx_CreateTask(instrHandle,"MotorSpeedFromSensors_,Task_Handle8)
AGniDAQmx_CreateCOPulseChanFreq(instrHandle, Task_Handle8,"Dev1/ctr0",DAQmx_Val_Hz,DAQmx_Val_Low,0,8.333,0.5)
AGniDAQmx_CfgImplicitTiming(instrHandle,Task_Handle8,DAQmx_Val_ContSamps,1000)
AGniDAQmx_ClearTask(instrHandle,Task_Handle8)
 
I expected to see the pulses when I connect the scope probe to pin 6 -  CTR0OUT
 
Am I on the track?
 
Thanks.
-CBJohnson
 
0 Kudos
Message 2 of 4
(4,162 Views)
The last line in your code is ClearTask, but I can't see StartTask anywhere...
Did you start this task, didn't you?... 🙂

- George Cs -
0 Kudos
Message 3 of 4
(4,155 Views)

Geroge,

Thanks!  That was the statement that I was missing. 

I thought the thread was already running so it didn't need the start. 

It's working now.

-CBJohnson

 

0 Kudos
Message 4 of 4
(4,150 Views)