Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to count TTL pulses during 100ms ?

I need to count TTL pulses coming out of an instrument (particule counter). The pulses appear randomly. I must count how many pulses appeared in the last 100ms, and so on, every 100ms. I don't want cumulative counts, but the number of events every 100ms.

I need a hardware clock, so that the counting pace cannot be disturbed by Windows making some weird, unrequested, CPU-hungry task.

I fact, I need to do that for 2 identical instruments of the same kind, and I have 2 cards with 2 counters each, total 4 counters. My idea would be to use 1 counter as the clock for 2 other counters, but how to trigger the counter value read ?

Thanks.

0 Kudos
Message 1 of 9
(5,244 Views)
Hi,
 
I join an example that counts digital events (counter RAZ each reading) timed with an external clock that can come from another counter indeed!
I hope you wanted to use DAQmx driver and LabVIEW...
 
Regards,
 
David D.
Applications Engineer
NI France
0 Kudos
Message 2 of 9
(5,237 Views)
David,
 
I have SCB 68, PCI-6259 board(M series) and Labview 7.1 and would like to count TTL pulses with DAQmx.
I connected TTL pulse (source signal) into pin nimber 37 in SCB 68 (CTR 0 SRC) and TTL ground signal into pin number 11 (PFI 0) as mentioned in example. (I used BNC-to-two aligater jacks, which fed in SCB 68).
I followed your example attached in order to count TTL pulses which randomly appear. I really want to count how many pulses appeared during every 100ms. I don't want cumulative counts, but the number of TTL pulses every 100ms.  
I only obtained 0 or 1. For example, I want to get the data like the following below:
0ms - 0 counts
100ms - 121 counts
200 ms - 132 counts, and so on. 
 
I only changed sampling rate 1Hz and samples to read 10. (I understand that this gives data every 100ms). Is it correct? Any hint or advice would be greatly appreciated. Thank you
0 Kudos
Message 3 of 9
(5,148 Views)
Hi,
 
In the example I gave you, you need to supply the TTL you want to count the pulse (connected on pin 37) and a TTL "clock"  which is connected to PFI0. The TTL on PFI0 permits a hardware timing (100ms for example) to count the edges that occur on the TTL source.
 
If you do not need hardware timing, have a look at the example attached. You only have to connect the TTL source and the VI counts every 100ms (software timed) the edges that occur durind those 100 ms.
 
Hope it will help you,
Regards,
 
David D.
Application Engineer - NI France
 
01-02-2006 01:26 PM
0 Kudos
Message 4 of 9
(5,138 Views)
David,
 
I appreciate to your help. I have some questions to clearly understand example VI program. 
 
1. Do I use TTL pulse generator to set hardware timing for TTL "clock"?
2. As you explained, I only connect the TTL source to count TTL pulse every 100ms, but I've got wrong data.
As I mentioned, my TTL pulses are fed to SCB 68 using BNC-to-two aligators. Signal line is only connected to Pin number 37 and ground line is left.
Is the connection correct?
3. What is difference between Counter 1D U32 1 sample and Counter 1D U32 NSample in  DAQmx Read.vi ?
In order to count TTL pulse every 100ms, which sample do I use? (1 sample or Nsample)
4. Do I need Duplicate Count Prevention? I think I use this property because PCI6259 is M-series. Am I right?
 
Thank you.
 
0 Kudos
Message 5 of 9
(5,128 Views)
1. You are the only one that can answer this question. If you need hardware timing, use the first example, if not, use the second one.
2. In the second example, you only have to connect the TTL signal you want to count edges. You have to connect to CTR SRC 0 and ground.
3. You count ONE number of edges during 100 ms on ONE channel so it is a 1 sample.
4. No, example I gave you must wotk directly.
 
Regards,
 
David
0 Kudos
Message 6 of 9
(5,104 Views)
David,
 
I followed your advice. But I have still got wrong data.
I'd like to make sure that which SCB-68 pin number does connect to ground signal.
 
I did connect that TTL pulse signal - pin number 37 and groung of TTL - sample clock source (PFI 0 (pin number 11)).
If not, does the ground signal have to connect digital ground pinn number ?
 
Second, to get the count number every 100ms, I think that if I set sampling rate 1Hz (as given in your example), I have to sample to read 10. Am I wrong?
In your example attached, I only changed counter (from Dev2/ctr0 to Dev1/ctr0) and sample clock source (Dev2/PFI0 to Dev1/PFI0).
Other parameter values are followed in your VI. And I added to "write LABVIEW measurement file vi" in order to write data file.
 
Thanks
 
0 Kudos
Message 7 of 9
(5,099 Views)
The ground signal has to be connected to the digital ground pin. (Use the second example which is the simpliest of both.)
Regards
 
0 Kudos
Message 8 of 9
(5,096 Views)
David,
 
I modified your program posted above. I've tested my Labview program to count TTL pulses every 1 sec.
TTL pulses: 1KHz( ~1000 TTL pulses/sec)
Labview program Sample Clock Source: 1 sec setting (high 500ms and low 500ms)
 
But I had wrong data (I am not pretty sure) through saved data file, i.e.,
0 - 1sec: 1002
1 - 2 sec: 998
2 - 3 sec: 987
3 - 4 sec: 1004
etc...
 
But as I mentioned above, I've got inconsistent data.
Even my function generator doesn't make exact 1kHz TTL pulse,  I expected that the variance of data is very small, i.e., 998 ~1002 counts / sec.
 
If my Labview program has a problem, could you let me know?
I appreciate to any hint or advice
 
Thanks
 

Message Edited by leek2 on 01-09-2006 01:11 PM

0 Kudos
Message 9 of 9
(5,069 Views)