Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

E-series. Time between 2 leading edges w/ GPCTR

We are attempting to acquire the time between 2 first leading edges with 2 light screen signals coming into PFI_9.  The light screen signals send pulses to PFI_9 independently and one at a time.  However, we realize that we sometimes get multiple pulses subsequent to first pulses on each screen and this yields erroneous GPCTR times between first leading edges.  

 

We want just the first edges of each screen.  If need be, we can separate the lines from the screens so that screen 1 goes to PFI_9 and screen 2 goes to PFI_4, or some other such recommendation.  If we do that, what might the code look like?

 

0 Kudos
Message 1 of 3
(3,358 Views)
I would bring the signals in on two different PFI lines and approach the problem like this:

1. Create a Pulse Generation task on one counter (CTR0) to trigger off of the first light screen pulse.
2. Setup a second task on CTR1 to count edges on CTR0. Set this task to stop (or pause) when it sees the second light screen pulse.
3. Now you have the amount of time between the pulses (Take the amount of events counted and divide by the frequency of the pulse train generated on CTR0).

I don't know if this will help you or not, but here is an example of doing this in LabVIEW. The example is in DAQmx which I would recommend using if your hardware supports it. I am attaching a screenshot. If you don't have LabVIEW at least you'll be able to see the program flow from the screenshot.


I hope this is helpful!

Garrett H
National Instruments
0 Kudos
Message 2 of 3
(3,340 Views)
Garrett H
National Instruments
0 Kudos
Message 3 of 3
(3,338 Views)