Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

6601 CTR/TMR - problem reading multiple counters

I'm developing some code for frequency measurement in Visual C++ using the
NI 6601 counter/timer board. I am able to successfully read the counter
for a single counter; however, my application requires reading multiple counters.

I have code to the effect as follows:

do
{
nStatus = GPCTR_Watch( nDevice, ulCounter1, ND_ARMED, &ulArmed1 );
nRetVal = NIDAQYield( nYieldOn );
} while ( ( ulArmed1 == ND_YES ) && ( nStatus == 0 ) );

do
{
nStatus = GPCTR_Watch( nDevice, ulCounter2, ND_ARMED, &ulArmed2 );
nRetVal = NIDAQYield( nYieldOn );
} while ( ( ulArmed2 == ND_YES ) && ( nStatus == 0 ) );

do
{
nStatus = GPCTR_Watch( nDevice, ulCounter3, ND_ARMED, &ulArmed3 );
nRet
Val = NIDAQYield( nYieldOn );
} while ( ( ulArmed3 == ND_YES ) && ( nStatus == 0 ) );

I have tried a single do..while, but to no avail. In the above code, the
first counter returns, but the next one just hangs there indefinately - not
arming.

Can anyone point me in the right direction on how to read multiple counters
on the 6601?

Thanks,

Aaron Lukacsko
alukacsk@avtron.com
0 Kudos
Message 1 of 2
(1,010 Views)
Your program is hanging because you are setup for a continuos read, which means your counter will never unarm. If the first counter never unarms, then your program will hang until the first counter is stopped. You need to either use one Do statement for all for of the GPCTR_Watches or use the Buffer Functions. If you want a continuos buffered operation then you need to use GPCTR_Config_Buffer and GPCTR_Read_Buffer functions. However, if you are just doing a finite number of counts then you use the GPCTR_Watch function, without any buffer functions.

Kevin Bisking
National Instruments
www.ni.com/ask
Message 2 of 2
(1,010 Views)