LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring frequency with NI 9423

Greetings everyone, I would like some advice with the mentioned measurement, as I'm certain there must be a better way to do it. Basically, the frequency I'm after is rather low (30Hz tops), and it is not always present, rather it is 0 most of the time, so using the direct frequency calculation function more often than not, yields a timeout error.

 

I jury rigged a quick measuring using the edge counter functionality and while it got me out of a sticky situation (long story), I'm certain there must be a better and more accurate way to measure frequency, while also accounting for the fact that it's low and can often be 0. Also I tried the solution NI offers of clearing the error manually and sending a 0 after timeout error, but if I set timeout at reasonable values, I get nothing but zeroes, and with a longer value it updates VERY slowly. Ideally I'm looking at 5-10 updates per second with a reasonable acuraccy, any ideas?

 

Timing.png

0 Kudos
Message 1 of 5
(3,446 Views)
I would suggest you to use producer consumer architecture: http://www.ni.com/white-paper/3023/en/
Thanks
uday
0 Kudos
Message 2 of 5
(3,421 Views)

Yeah... the thing is, I am not having issues with the architecture itself. I am having issues with the method of measuring frequency, which is somewhat inaccurate and slow as I can only get 1 update a second. What I need is not architectural advice, but a better method of calculating the frequency, based on the pulse counter or another method.

0 Kudos
Message 3 of 5
(3,418 Views)

I have a suggestion for you. Use Low Frequency Measurement with 1 counter. This method works better with frequencies less than 10k Hz. 

 

0 Kudos
Message 4 of 5
(3,378 Views)

That's actually what I was doing when I used the frequency counting. I have a (dunno if good or bad) habit of creating the hassle with the DAQ assistant, then generate DAQmx code and modify accordingly, so in the end screen I saw the options of 1 counter low freq, 2 counter high freq and the such. My problem was the no-frequency timeout error when system is stopped, but I'm happy to say I found a workaround, and learned a few things in the process:

 

-For some reason, you must start task, read and clear task, every time, dunno why (continuous measurement gives a lot of errors)

-Also, changing polymorphic read from 1 channel N samples to 1 sample (frequency and period) doesn't yield any data, so I had to use index array to get the single number into the array for conversion purposes. Maybe someone more experienced can explain why that happens.

-The acquisition of frequency MUST be contained in its own while loop, as it will hold back whatever else is inside the while loop it inhabits if frequency is zero, until it finally times out, and I need the rest of the panel to be responsive all the time.

 

So the better workaround I found was, in its own while loop I start task, read and clear task for frequency measuring, for every value, then use a case with error cluster wired to selector. In no error I just send the value to a local variable (race conditions are a non-issue since I only write to the lv from there) and in error case (timeout) I clear error and send a 0 to the lv. That way, when I have a reading I have updates, and when I have a 0 it is reflected and the loop doesn't interfere with the rest of the program.

0 Kudos
Message 5 of 5
(3,348 Views)