Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-6602 gated edge counting VC++ 6.0

Hello,

I'm using a NI-6602 with NI-DAQmx and VC++ 6.0, and I'm a newbie to all of it.
My task is to count the number of pulses per second coming from a photomultiplier module(TTL signal). The pulses are connected to source of Ctr0. I first tried to use the windows GetTickCount function to delay DAQmxReadCounterScalarU32 for 1000ms. This method had actually to much variation and I couldn't use it.
Next I set Ctr1 to generate a pulse of 1sec. and connected Ctr1Out (by hardware wire) with the Gate signal for Ctr0 but it looks like the counter counts regardless the Gate Signal.

Any help will be very welcome. I think a maybe simple function to define exactly the duration for counting pulses would do.

Eventually I want to use all counters on the NI-6602 and mcount the number of pulses from all in all 8 photomultipliers. The measurements don't have to be synchronised, one channel after another would be sufficient.

I will typically perform the measurement in two modes, one mode in which the counts are around 100k - 500k pulses per second and another mode with some 100 pulses per second.

Dirk
0 Kudos
Message 1 of 4
(3,594 Views)
Hi Dirk,

It sounds like you want to use Buffered Event Counting. Using Buffered Event Counting, you can program the rate at which your counter counts events. You should be able to find some examples in the help, or you can use the DAQmx Assistant to configure a "Count Edges" task with Finite or Continuous task timing.
0 Kudos
Message 2 of 4
(3,586 Views)
Hi Jonathan,

I'll need some time and trials to understand you answer about the buffered counting.
I meanwhile succeed to get a reasonable result with the DAQmxCreateCIFreqChan function.
Some code extract is below.


for (i = 0; i < 5; i++)
{
taskcreat = DAQmxCreateTask ("", taskHandle+i);
error = DAQmxCreateCIFreqChan (taskHandle[i], CtrStr[i], "", 5000000.0, 20000000.0, DAQmx_Val_Hz, DAQmx_Val_Rising, DAQmx_Val_HighFreq2Ctr , 1.0, 1000, NULL);
}

.
.
.
.

for (i = 0; i < 5; i++)
{
DAQmxStartTask(taskHandle[i]);
statread = DAQmxReadCounterScalarU32(taskHandle[i],1.0 ,data+i,NULL);
DAQmxGetErrorString (statread, errormessage, 560);
DAQmxStopTask(taskHandle[i]);
}


When I tried to measure 5 channels at a time, I noticed that some channels (2 & 4) produce an error code but I can read those in a second run seperatly. That's acceptable for my purpose at the moment but eventually I want to see whether I can read all 8 channels simultanously. I guess this is then when your proposal of the buffered counting comes in, right? Thanks.


Dirk
0 Kudos
Message 3 of 4
(3,567 Views)