LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counting ttl pulses with Count_Events-Easy (DAQ-STC)

My goal is to count ttl pulses over a specified bin size from an APD photon counter.

I dowlnoaded Count_Events-Easy (DAQ-STC).vi from the NI website, and tried using it to count ttl pulses through the PFI 0 channel of my pci-6014 basic multifunction DAQ.  If I run the vi continuously it does not display an counts unless the Measurement & Automation test panel is open for the pci-6014 and I select the corresponding counter and event source under Counter I/O.  The vi counts match the  test panel counts, for what that's worth.  If I reset the counter I/O test panel the vi stops counting and will not start again until the counter I/O is restarted.  Also, if I stop the vi  the test panel also resets. 

Why won't the vi run on its own?  Is there something obvious I'm missing here?
0 Kudos
Message 1 of 11
(4,229 Views)
Any suggestions?
0 Kudos
Message 2 of 11
(4,226 Views)
 

Hi,

The Count Events Easy (DAQ STC) example was not configured to have PFI 0 as the counter source. I was able to use this example with an E Series card using Pin 42 (Counter 1 Source) and Pin 37 (Counter 0 Source).  There are some newer counter examples in the LabVIEW example finder.  I am attaching a counter example from the LabVIEW Example finder.  This example gives you a few more options including setting source PFI line.  Try this example and please let me know if you have any problems.

I also want to make you aware that your application would be much simpler if you use the DAQmx driver.  Here are a couple of links with more information about DAQmx:
Answers to Frequently Asked Qustions about NI-DAQmx and Traditional NI-DAQ (Legacy)

 

Regards,
Hal L.

 
0 Kudos
Message 3 of 11
(4,213 Views)
I wasn't using the DAQmx driver because I was under the impression that the pci-6014 was not supported by DAQmx.  However, I think this may have been due to my using NI-DAQ 7.0.1.  I have now installed NI-DAQ 7.4.  However, when I try to run Count Edges (DAQ-STC).vi LabVIEW prompts me to locate the VI named "Counter Source (STC).vi"  Do you know where I can find that?  (A google search with that search term turns up nothing.)
0 Kudos
Message 4 of 11
(4,193 Views)
Hi,
 
The PCI 6014 is supported by DAQmx.  
 
The Count Edges (DAQ-STC).vi example is located in the LabVIEW example finder.  You will be able to open it directly by going to Help>>Find Examples>>Hardware Input and Output>>Traditional DAQ>> Counters>> DAQ-STC>> Count Edges (DAQ-STC).vi. 
 
If you use the example on the discussion forum, you can manually browse to the vi when you download the example program.  When LabVIEW prompts you to locate the vi, select "Browse" and go to this location: C:\Program Files\National Instruments\LabVIEW 7.1\Examples\DAQ\Counter\DAQ-STC.llb . If you open the DAQ-STC.llb, you will be able to select the Counter Source (STC).vi. 
 
Regards,
Hal L.
0 Kudos
Message 5 of 11
(4,185 Views)
Thanks for your suggestion about using DAQmx.  I've got my DAQ now counting photons from the APD in a loop with a variable delay (correpsonding to the sample bin time).  Count # scales pretty accurately with the bin time, but at some values there appear to be some artifacts such as periodic spikes in the count #.  Can anyone recommend a more accurate way to specify the bin time?
0 Kudos
Message 6 of 11
(4,172 Views)
Attached is a screenshot of the program I'm trying to emulate.
0 Kudos
Message 7 of 11
(4,170 Views)
I've added a step to measure the timing of the loop, and have found that sometimes it 'skips a beat'.  As in, occasionally the delay between steps is 0 ms, although usually it's not.  Is this a memory management problem?  Is there a better way to specify the timing of the signal collection?
0 Kudos
Message 8 of 11
(4,160 Views)

Hello Ian,

I took a look at the last VI you posted and you are going run into problems with windows (assuming you are using windows) causing the loop to iterate with a different time always.  One thing that may help somewhat is to change the wait VI to the wait until next ms multiple VI.  I think that this <a href="http://digital.ni.com/public.nsf/websearch/12B2EA9AD5B265AD86256257004DD8E2?OpenDocument">Knowledgebase</a> does a nice job explaining why you want to use this VI instead.  How small of a time bin are you trying to specify?  You really can't get faster than 2 or 3 ms loop iteration from windows. 

Let me know if this change helps at all,

Laura

0 Kudos
Message 9 of 11
(4,139 Views)
Hi Laura,
    Thanks for your response.  Yeah, I was thinking about the timing situation earlier today when somene mentioned to me that they thought the problem with my vi was due to Windows priority settings.  Correct me if I'm wrong here: If I use the "Wait until next ms multiple" function, it will give me a consistent time spacing between bins, but could possibly miss some ttl pulses due to dead time while waiting for the next ms multiple.  If I use the Wait(ms) function, it will give me an inconsistent time spacing between bins, but I won't miss as many ttl pulses.   
    My experiment will be light-starved, and so the biggest priority is to miss as few photons (ttl pulses) as possible.  In this context I would probably be best off using the Wait(ms) function and just tolerating the inaccurate bin times, right?  Would using a timed loop be more accurate?  In all likelihood the fastest bin time I will ever need in an actual experiment is 5-10ms.
    Also, can I assume that the two channels will be looking at the same [inaccurate] time window?  That is more important than the exact time being accurate because eventually I will do a cross-correlation of the two channels. 

    Is there a way I can output a pulse train at a known frequency from the DAQ and use it to trigger both counter channels?  I have a pci-6014 which only has two counters.  Is there a way I can use the onboard clock to generate the pulse train and save the counters for counting ttl pulses? 

    Could the DAQmx_Timing vi help here?
0 Kudos
Message 10 of 11
(4,015 Views)