LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a counter to detect frequency

I have an application that basically needs to run as fast as possible given an input signal from a sensor on a vehicle. This frequency I get can range from 300 Hz to 2.2 kHz. I am also sensing three other analog inputs. This is how the vi should work:

1. Input signal is passed to DAQ board counter (GPCTR0_GATE). The counter is configured to count on each rising edge.
2. When a rising edge is detected, sample the three analog input channels and dump these values to a buffer (array).
3. Capture the period of the input signal at the same time I'm getting the three analog channels, dump this to the buffer as well.
4. Continue this process until a stop button is pressed.
5. When the test has completed, copy the buffer to a database.

Basically, what we're trying to do is capture readings based on an external clock that can vary with speed. While testing the application I wrote, I've noticed some serious problems, and this is where I need some expert advice on how to handle them. If the input frequency were constant at 1 kHz, and the test was run for exactly 10 seconds, I would expect to see 10,000 data readings copied to the database (in a perfect world, at least). What I get depends on whether or not I'm requesting the period of the input signal - if I only request the three analog input channels, then I get around 10,000 data points. If I request the period as well as the three analog channels, then I may get 20% (2000 data points) - and the period is wrong at the lower frequencies (300 Hz to 900 Hz).

I'm at a loss here. I've written this using traditional NI-DAQ as well as with DAQmx. Neither one gives me the input period right, and the number of data points captured decrease significantly when I try to get the period. I've looked a the examples, used alot of the examples, but still no luck. Any help would be greatly appreciated.

My configuration:

LabVIEW 7.1
PCI-6014 on the PC and a DAQCard-6062E on the laptop
Windows XP
0 Kudos
Message 1 of 3
(2,844 Views)
I think you are going to need a DAQ card that utilizes at least 2 DMA channels. Otherwise, I don't think you can do more than one thing at a time (either freq counter or analog input).

Maybe a NI guy will respond soon to comfirm.
Randall Pursley
0 Kudos
Message 2 of 3
(2,803 Views)
Hello,

I do think that a higher performance card would help you significantly in your application. Something like a Value M Series (NI 622x) might solve the problem since it offers 6 DMA channels. If you are able to strip down your program such that it is the easiest piece of functioning code that demonstrates the behavior you would like to see, I could give it a test run on an M Series device and let you know how things turn out. I would need the DAQmx code in order to do this since M Series do not support Traditional NI-DAQ.

Another thing that I found interesting about your post is that the examples were not ever working for you. I would suggest trying the Meas Dig Period-Low Freq 1 Ctr.vi in the DAQmx examples to see if you are able to successfully measure the frequency of your signal. If that's not working, then it might be an issue with the signal that you are connecting up. You should confirm that the signal is TTL compliant and possibly even probe the signal to confirm you are receiving what you are expecting.

Post back with your thoughts and code if you'd like.

Jared A
Message 3 of 3
(2,794 Views)