06-06-2017 12:27 PM
I'm trying to measure counting rates (counts / second) for two devices using NI PXI 6224 and Labview 2012.
As far as I understand I need one counter for counting and one timer to define the counting interval.
The two cannot belong to the same general-purpose counter/timer or I get "resource reserved" error.
Is there a way to read out two counting rates simultaneously with the two counters on NI PXI 6224?
The example shows my current approach for one counting rate.
PS: The example is constantly creating and deleting tasks.
Can this be changed such that a single create task is followed by multiple reads and a single delete task?
Solved! Go to Solution.
06-06-2017 08:25 PM
Since you just want frequency (counts/second), have the counters measure Period (seconds/count) and invert the measurement.
06-08-2017 03:21 AM
Thank you for that hint.
It works very well for periodic signals, but I forgot to mention that in my case the signals come from an ion detector and are not periodic.
Thus I do have to count each pulse in the time intervall to get the rate.
Are there other options?
06-08-2017 05:31 AM
In that case, I would use a digital circuit. Use a pulse circuit (like a 555 Timer) and AND that with the pulse output. The result goes into your counter. Then just use another digital line to enable the pulse timer, wait long enough for the pulse to end, and read the counts.
06-09-2017 09:33 AM
Hi,
If I got you correctly, you are trying to perform Edge Counting with your PXI 6224. If this is the case, I would advise you to have a look at LabVIEW examples; just search for "count".
For simultaneous measurement there are also lots of examples, if not directly for Edge Counting, for other tasks such as Continuous Voltage Acquisition. You can get the implementation idea for synchronization from such examples and program and adjust this code. It shouldn't be that complicated 😉
Let us know if you have further questions,
Bart
06-12-2017 04:04 AM
Hi,
I'm familiar with the Edge counting examples but none of them adresses counting rates.
From "Counter - Count Edges.vi" I learned how to use a second counter/timer to determine when the first counter should start, pause or reset.
If I reset the counter periodically the count rate just before reset should be the total number of counts during the period.
However I was not able to synchronize reading out the counts to this event. I would be very interested in an example how to do this.
With the digital pause I can make sure the counter stops after a defined time and then read out the value.
In order to reset the counter I then have to restart the task as shown in the example attached in my original question.
I'm using multiple channels for voltage aquisition but when I try the same for counting I get the following error:
"There can not be multiple counters in the same task for input operations. Use a seperate task for each counter."
The 555 solution sounds reasonable but for now I will just read the rates alternating.
Best,
Tim
06-20-2017 09:53 AM
Only have time for very brief summary right now...
1. One possible approach I've used is to "borrow" the AO subsystem for its sample clock if my app doesn't need to generate clocked AO. You can just continuously regenerate 0 Volts on ao0. Configure your two edge-counting tasks to use the AO Sample Clock as their own sample clock.
2. Another possibility is to set up both counters for period measurement (as already suggested). You can then post-process to calculate an average count rate over any interval you choose. Note: this method offers a lot of flexibility for post-processing, but is also a little more prone to generating DAQmx errors during fast bursts of pulses.
-Kevin P
06-21-2017 11:15 AM
1. I only have AI on the PXI 6224 but I guess it would work the same way.
Do you know of an example of how do this, since I'm new to DAQmx it takes a lot of time to figure it out.
2. Can you specify how to do the post processing?
Best, Tim
06-21-2017 03:08 PM
Below is a decent starting point for method 1:
(This is a snippet. You can save the image as a file, then drag it into an empty vi block diagram to get instant code.)
- Kevin P
06-30-2017 02:49 PM
Hi Kevin,
thank you so much, it worked instantly. Also the comments were very helpful.
However I do think the counts from the last iteration should be subtracted, not added.
I was worried about what happens if the counts reach the limit of U32, but appearently everything is wrapped correctly.
I also replaced your visually advantageous "Max" with the efficient "reverse 1D array" + "index array" to get the last element.
I then modified it so that I can read out my 32 AI channels while using both counters.
Best,
Tim