11-10-2010 11:44 AM
I want to count pulses coming from an avalanche photon detector (APD) and reference them to the intensity of a light source. I have written a small vi (using Labview 8.0, attached) to read a counter (to which I have connected the output of the APD) at intervals synchronized with the acquisition of analog data (on which I measure the output of another detector).
The counter is the card PCI-6602, while I collect the analog data with a PCI-6052 (installed on the same computer).
The vi executes successfully about 95% of the times, but in the other 5% the counter does not get sampled the number of times that I require and the DAQmx Read vi that reads the buffer times out (when the vi times out usually all the requested samples are available except the last two or three, for example if I request 5000 samples I may get 4997 and if I request 100 samples I may get 97). I attach the vi here in the hope that someone can tell me what is wrong.
The vi is quite straightforward but let me add a few lines of description so that it is clear what I have in mind when writing it - it is quite possible that I am not doing what I think I am doing and that could be the source of the problems.
First of all I create two DAQ tasks, one "Analog input" and the other "Counter input". I believe I do that correctly, the problem is not likely there.
Then I request the synchronization using the DAQmx Timing vi, Sample Clock. For doing this I wire an instance of the vi at the output of each of the tasks I created. I set the source of the Sample Clock for the analog input task to "Onboard clock" (I understand that by doing so the analog input channel sampling takes its clock from an internal clock of its own board), and I set the source of the Sample Clock for the counter task to /Dev1/ai/SampleClock (Dev1 is the name of the PCI-6052 board); if I understand correctly, this is the same source as the "Onboard clock" for the analog input, so this should already guarantee that the two samplings are performed at the same time if I set the rate for the two instances to be the same; and if I would set the rate of the clock for the counter at one half the rate of the clock for the analog input, then I would get one counter sample every two analog samples (please let me know if I am understanding wrong).
Both instances of the Sample Clock vi are set to "Finite Samples", and the number of samples is entered as a variable (the same for both). I start the counter task, and I apply to each of the tasks the DAQmx Read set to the proper case.
Sometimes the DAQmx Read fails with error code -200284, and the size of the vector it reads is smaller than what it should be by a couple of units.
The curious thing is that if I select Analog Wfm NChan NSamp instead of Analog Wfm NChan NSamp then the timeout problem becomes worse, happening about 10 to 15% of the time.
What could be the problem? I am doing something wrong? Thanks in advance for all of the answers.
Giovanni