Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

acquiring random TTL pulses on 2 synchronous counters

Hi!

I have to count random TTL pulses during a finite gate time, from two separate sources. I want the counting events to be done exactly at the same time during exactly the same gate time (100ms, 1s, 10s, ...). In other words, I want to trigger to counters so that they can start counting and stop counting at the same time exactly.

I am using Labview 7.1 with the 6601 board (4 counters available). My TTL pulses are connected to pin 2-36 (counter 1) and 7-41 (counter 2). How can I do this?
I would really really apreciate any help or example!!!

Thanks a lot.

Fred

0 Kudos
Message 1 of 8
(5,682 Views)

1 way: 

A. Configure counter 2 to generate a single pulse, using low idle and high pulse (default settings).  Set high pulse time to be the required "gate time" you mentioned.

B. Configure counters 0, 1 for edge counting with a "pause trigger."  (I'm not at my LV PC to check -- the "pause trigger" may require use of the DAQmx Trigger property node rather than the regular DAQmx Trigger vi.)  Set the pause trigger source / terminal to be the output of counter 2.  Set polarity of pause trigger to mean "count while pause trigger is high, do not count while low".

C. Start counters 0, 1.  They are ready to count, but because counter 2's output is low no counting is happening yet.

D. Start counter 2.  Its pulse will act to gate the counting operation on counters 0, 1.  Since they both use the exact same signal for gating, they count during he exact same interval.

Variations are possible that involve a Start Trigger, but I don't think that's necessary.  The gating pulse IS necessary and seems sufficient for synchronization in itself.  You also have a spare counter that could support a buffered mode if desired.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 8
(5,680 Views)
Thank you Kevin!
Here is an example of what I've done. I can start and pause counters 0 and 1 with the "manual trigger" button. It's close to what I want, but not exactly. I want to set the "gate time" (let say 100ms). When I run wy vi, I want counters 0 and 1 to start automaticaly, count pulses during 100ms, reset counts to 0,  count again during 100ms, and so on...
I have used a DaqMx property Node, as you suggested for counters 0 and 1 (althought it's not so clear to me as I am new in the Labview World!...). I believe I have to modify the lower line of the diagram (what I call "manual trigger" and what you call counter 2) to achieve my goal. But how to? I have not succed in it so far....
Woul you be kind to help me again?
Thank you
Fred

Message 3 of 8
(5,676 Views)

Fred,

So now it sounds like you want to a series of measurements, each one being counts during a particular 100 msec interval.  And you want all these 100 msec intervals to be continuous, right -- no time gaps between them?

Because you want to reset the count to 0 at the start of each interval, that naturally leads to a different type of measurement than I first described.  You should plan to do period measurement which causes the count to reset to 0 after each sample right down at the hw level. 

Your 2 measurement counters should perform buffered period measurement, and they'll need to by sync'ed using a Start Trigger.  The 3rd pulse counter will now need to generate a continuous pulse train with a total period of 100 msec (rather than a pulse width of 100 msec) and be used as a Sampling Clock by the other 2 (rather than being used as a Pause Trigger).  Finally, you may need to set the "Duplicate Count Prevention" property for the 2 measurement counters.  This will allow you to buffer up values of 0 during 100 msec intervals in which there are no incoming pulses from one of your external sources.  I don't know whether you should set it to True or False though -- its default behavior hasn't been constant for all board types over various DAQmx versions so the safest thing is just experiment and find out which setting does what you need.

Somehow you'll need to generate a pulse for your Start Trigger too.  This can be done with a pulse from your 4th counter or by using a digital output (using a digital output may require physical wiring).

Finally, you'll need one of the counters configured to use Interrupts for data transfer rather than the faster, more efficient DMA.  The 6601 provides only 1 channel of DMA for data transfer, so only 1 buffered counting task gets to transfer data to RAM this way.  The other one will need to be explicitly configured to use interrupts.

This is such a substantial and significant set of changes that you'll probably have to start over from scratch.  Try searching the ni site for examples and search the forums for prior discussions about photon detector apps.  There've been several threads about PDT's that typical have similar data collection requirements to yours.  I can't build up a whole example for you, but post again once you think you've found / reworked something close.

(Note: the 6602 provides 3 channels of DMA to support 3 simultaneous buffered counting tasks.  Though it costs twice as much as the 6601, I think it offers well over twice the capability.  Still, you should be ok with the 6601 because you're only buffering at 10 Hz which should be absolutely no problem for interrupts.  A few kHz would be different...)

-Kevin P.

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 8
(5,662 Views)
Hi Kevin
I've worked on this very interesting idea of doing buffered period measurement. Let me explain how I
-the lower line of the diagram generates a continuous pulse train on ctr2 with a total period of 100ms (50ms high, 50ms down).
-the two upper lines configure the tasks for ctr0 and ctr1 :
  • Ctr2InternalOutput is used as the period measurement terminal for both counters
  • PFI39 (Ctr0Source terminal) and PFI34 (Ctr1Source terminal) are the timebase source terminal
  • "duplicate count prevention" is set to true, tough there should always have pulses in a 100ms interval
  • counter 0 uses interrupts
  • counter 1 uses DMA
So now, it seems to work, but....

  • there is no count on Ctr1
  • I can only perform a finite measurement task. A continuous measurement gives me errors :
  • error 200300 with an implicit timing
  • error 200145 sample clok timing
Hope you're not on holidays and can help me!!!...Thank you

0 Kudos
Message 5 of 8
(5,469 Views)
sorry for my stupid signature "help me, I will help you"...
of course I willl help you if I can, but it seems that you're a real veteran of Labview...
0 Kudos
Message 6 of 8
(5,468 Views)
Hi,
You maybe need to modify your timing: select "sample clock" instead of the "implicit" configuration. Select here the  appropriate timebase  (CTR2 output).
Hope this helps 😉
 
 
Manuel R
AE dans une autre vie
0 Kudos
Message 7 of 8
(5,356 Views)
OK, now it works. There was no count on ctr1 because the CI.TimeBaseScr was not correctly selected : the default SOURCE terminal for ctr1 is PFI35, not PFI34! Moreover, there are no more problem with timing configuration.

Both of the VIs I have attached allow to countinously acquire and plot pulses on two synchronized counters. One uses the pulse-width method, while the other uses the period method:
  • in the  period method, the counter begins to count when armed, which could occur between GATE edges. Therefore, the value latched by the first active GATE edge is unreliable and should be discarded.
  • in the pulse-width method, The first measurement will be correct even if the pulse train is in progress when the counter is armed. If the counter is armed while the GATE is in the active state, the measurement will begin with the next transition into the active state.
Hope this will help others.
0 Kudos
Message 8 of 8
(5,306 Views)