01-17-2011 10:20 AM
Hi,
I'm trying use Labview 2009 with NI PCI-6221 card to do pause trigger(gated) counting. The problem is, I cannot use sample clock and trigger property node at the same time and it later on causes issue when I calculate counts per unit time.
The gating signal is a 10000 Hz TTL signal that is high for 10 us and low for 90 us. The vi is set to recieve signal from the photon counter when the gating signal is high(pause when low), and calculate the average cts/per unit time in cts/ms. The following is the screenshot of the vi.
There is an inconsistancy when I compare the counts per unit time of this vi with the other vi that counts continuously under the same condition. When calculating the counts per unit time in ghe gated counting vi, I put in a gating time factor to correct the 1/10 counting time difference. The screenshot for the continuous counting vi is as follows
The "Samples to Read" is set to 10000 for both vis. The Rate is set to 100000 Hz and the Sample Clock Source is set to 100KHz from the device for the continuous vi. In this setting, the continuous vi updates average cts/ms every 100 ms, whereas the gated vi updates about every 30 ms and yields 1/3 of the average cts/ms. I would like to know if there's a way to fix this problem.
Thanks for reading this post.
Chung-Yu
01-17-2011 01:19 PM
Well, I guess the thing that surprises me first is that the gated counting task, in which you never configure any kind of sampling clock via "DAQmx Timing.vi", is apparently allowing you to read an array of samples from a buffer. I wonder if perhaps it might be getting cute and returning an array of size=1 every time?
My guess at the rest of the mystery:
A. 30 msec is your actual loop execution time, probably largely paced by the updates to the visual graphs
B. Your calculated rate comes out wrong because you've hardcoded an assumption of a 100 msec loop rate.
C. I'm not sure of your intentions where you append the current array of data to the single most recent value from the previous iteration. You then attempt to do a subtraction on arrays with different sizes. That may well be wasting CPU, depending on how LV handles it, and it's something you shouldn't be doing anyway.
-Kevin P
01-17-2011 02:32 PM
When I use the "DAQmx Timing.vi" with the DAQmx Trigger property node, I get error 200145 saying that I cannot use them at the same time. A few searching on this topic I found one suggestion saying that two edge seperation shold be used in this occation. I also ran into some problem using that, so I wonder if there's an solution to make them work at the same time.
The array stuff in the while loop is for calculating the time average. The continuous counting vi is written by someone else, I used it as a starting point for the gated counting version. I'll work on making this part so that it makes more sense and efficient.
After reading your suggestion, I tried to put a 100 ms wait time in the while loop for the gated counting vi and it turned out to give the same cts/unit time and update rate as the continuous counting vi. In the continuous counting vi, the loop length is indeed hardcoded by "Samples to Read"/Rate which is 100 ms. Before adding the 100 wait time in the while loop and without the sample clock for the gated counting vi, the loop length is about 30 ms so the outcome disagree with the continuous counting vi. I guess my problem at this point is, to be more specific, how to use the DAQmx Trigger property node with the DAQmx Timing.vi without getting error 200145.
Thanks,
Chung-Yu
01-17-2011 05:00 PM
On your M Series board, both the sample clock and the pause trigger signals use the "gate" input of the counter, so you can't use both at the same time.
What it sounds like you want is to count the pulses every time the gate is high. You can do this with a pulse width measurement. You'll just need to add the following channel property node to the linked example:
The end result will be that your card will latch in a single sample on the falling edge of every gate signal. The value of that sample will be the number of photons that occurred while the gate was high.
Best Regards,