I had written a vi for controlling our aircraft brake dynamometer originally with LabVIEW 5.0, using traditional NI DAQ. The AMD K6 333 based PXI controller finally went bad, and now I am updating my application to use LabVIEW 7.0 (The latest version that our company has a license for) and DAQmx. I successfully converted all of the control functions, with one exception. I use a quadrature encoder on the central spinning mass, and continuously measure the frequency of the pulses on one of the encoder channels to compute the surface velocity of the spinning mass. This method worked fine with traditional NI DAQ, but it is not working correctly with DAQmx. I followed an example I found for continous frequency measurement with DAQmx on this site, where I set up a DAQmx task outside of a loop and then keep calling DAQmx Read (Counter 1D DBL NSamp) inside of a loop. I tell it to read all available data, average the readings, and then run it through a formula node to compute surface velocity. This seems to work fine for steady state readings, but goes wild while the spinning mass is CHANGING velocity. When I accelerate or decelerate the spinning mass, the readings jump wildly (indicating a wide range of frequencies being read) from very large numbers to very small numbers, then home in on the correct number as a steady state velocity is reached. I have tried using two methods for reading frequency, and both methods exhibit this behavior. I have tried the low frequency with one counter method, and also the wide range frequency with two counters method. The spinning mass will see maybe 450rpm maximum rotational velocity, and the encoder outputs 1024 pulses per revolution.
I can attach a vi with my velocity reading loop, if it will help. Is there something that I am fundamentally missing in using DAQmx for continuously reading frequency with counters? I am now using a PXI-6221 M series board, I believe. Before, I was using a PXI-6040E series board for this task. The spinning mass can remain stationary for minutes at a time, with no rotation, and can accelerate from zero RPM to the maximum, then decelerate again to zero, over the course of several minutes. I want the vi to not error out while waiting for pulses, and also to exit cleanly and quickly if I press my stop button.
As I understand this you are trying to read the frequency of an quad encoder and the reading is fine as long as the quad encoder is at a steady speed but when it is changing speed you are getting random frequency values. I looked at your code and nothing seemed to jump out at me as being wrong with it but I do have a couple suggestions to see if we can narrow down where the issue may lie.
If you could just try running on of the examples found in the example finder (Help»Find Examples...) specifically example Hardware Input and Output»DAQmx»Counter Measurements»Digital Frequency»Meas Dig Frequency-Buffered-Cont-High Freq 2 Ctr.vi. And just wire the output to a waveform chart or a dial and see if you are seeing the same results there. If that is giving expected results i would just implement your formula node and averaging into that example and save it as your code. I have attached an image of such an implementation.
I know this is an old thread, but we are having a similar problem with frequency spikes on a cdaq 9178 chassis and NI9401 DIO module running DAQmx 9.02 in both SignalExpress and LabVIEW 2009.
Any resolution to this?