10-10-2010 07:17 PM
Hi.
What is the easiest method of counting pulses on the digital inputs?
My application requires me to count the number of pulses in 1 second on 6 digital input channels. The maximum pulse frequency will be about 40Hz.
Thanks
Mike
10-11-2010 01:07 PM
Hi Mike,
The best method to count digital pulses is to use a counter. The USB-6008 has one counter that is accessible from PFI0. Check out page 15 of the USB-6009 specifications manual for a complete description of PFI0. As shown below, PFI0 is on pin 29:
You can wire your digital pulse train to PFI0 (pin 29) and run the example called Count Digital Events.vi. This example can be found in the NI Example Finder (Help»Find Examples) and going through the following path of folders: Hardware Input and Output»DAQmx»Counter Measurements»Count Digital Events.
Post back if you have any more questions related to this issue.
10-11-2010 06:31 PM
I'm aware of the single counter input, but I need to count pulses on 6 digital inputs.
Attached is my solution so far. I'm hopeful it will work.
10-12-2010 09:20 AM
Have you tried running that? If so, what happened? Add indicators to your error lines and check for errors.
I do not think you can run separate tasks on the same device. Read the entire port and then separate the data into separate channels if needed.
The biggest problem with this approach is the software timed acquisition (which is the only mode for the USB-6008). If you cannot acquire fast enough to ensure that every transition on all the lines is captured, you will get erroneous data. Your technique of comparing current value to previous value via the shift register will count both rising and falling edges, or two counts per pulse.
Lynn
10-12-2010 09:40 AM
Hey Mike,
You could use that program to count digital pulses. You should be cautious of a few things:
Also, you can run separate digital tasks on the same device. An issue occurs when you decide to add timing configurations to both tasks. Most of our devices use only one digital timing engine; therefore, if you were creating separate digital tasks that called the same digital timing engine, you would get an error. In your case, you shouldn't see this behavior, since your only option is static, software-timed DIO.
10-12-2010 05:53 PM
It seems to run fine, and the 'max pulse freq' indicator flickers between 333 and 500 samples per second (meaning I could be reading up to 166 pulses per second).
I'm aware that I'm reading both the rising and falling edge of the pulses, but that will give me a better average for my data I think.
For interest sake I tried reading 8 analog samples at 10Hz in parallel with the inner loop and that only slowed processing down to 250 samples per second!
So I'm quite impressed with the baby 6008 🙂
Mike
02-16-2017 04:31 AM
Hello,
I am coming back to Labview after a few years out (refreshing things and meeting a new "friend" the ni6008). I found this topic because I want to do something similar with this hardware in labview.
-The idea is to read 8 channels of a digital signal, so it is like the solution posted above, but here my problem, the input could be of 5KHz! Is there a way to do it? What I understand is maximum 500Hz, but the hardware I have to use is ni6008. Could be that possible?
02-16-2017 04:44 AM - edited 02-16-2017 04:47 AM
Hi sarcanji,
Could be that possible?
No, that's not possible with your cheap hardware!
What I understand is maximum 500Hz, but the hardware I have to use is ni6008.
The NI6008 can handle ~100Hz samplerate when reading the DIO pins from my experience. Additionally you are limited to "software timing" as you can only read 1 sample per request…
The idea is to read 8 channels of a digital signal, so it is like the solution posted above, but here my problem, the input could be of 5KHz! Is there a way to do it?
A possible workaround would be to read those 8 signals using the analog inputs as you can use "hardware timing" with them. But then you are limited to 10kS/s aggregate sample rate or 1.25kS/s per channel…
but the hardware I have to use is ni6008
General advice: buy hardware based on your requirements. Don't try to fit your requirements on available hardware…
(The also cheap USB6002 allows 50kS/s aggregate on their AI pins.)
02-16-2017 05:18 AM
Ok, thanks for your fast answer.
So, there is no way to follow to read the 8 digital inputs with the available hardware at the possible frequency...
So, you are saying processing the input as analogue input and counting the time until goes under a desired value, right? But all the channels shall be working at the same time, right? I am not sure if I understand your solution... But still will not enough for our frequency, right?
Yes, I know, buying the equipment according the specs, but let´s say that I am trying to run something already done
02-16-2017 05:37 AM
Hi sarcanji,
no, I don't see a way to read 8 signals at 5kS/s with your USB6008.
I am not sure if I understand your solution...
Examine the example VIs coming with LabVIEW and DAQmx. There are examples explaining how to read multiple (analog) inputs!
To convert those analog readings to "digital" values you only need to compare them to a threshold voltage…