Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

pulse counting low frequency to 0 Hz

Solved!
Go to solution

Hi all,

 

I have searched the forum but have not found what I needed, unfortunately I do not have time to read everything posted.

Basically I have a main VI that updates about every 200ms or so. This VI measures temperatures, controls an analog out and measures analog in voltages.

I need to measure the frequency of two pulsed flowmeter signals, 0-10V square pulses, the frequency regularly goes all the way to zero (at this point I am guessing my max frequency would be about 100Hz).

Using NI 9217, 9201 and 9263 modules on an 8 slot USB cDAQ.I think this means I do not have access to any counters.The 9201 also measures two additional voltages that do not need to be sampled fast at all.

 

A few questions:

- I assume I need to use two loops here, the main VI and one, that should run faster, to measure frequency (or pulses)?

- I found a VI that counts pulses (attached), modified it a bit to give me an average pulse count/min but I do not know how to make it work in my VI,

this counter wants a 1D array of Waveform as its input, what I actually have is a Waveform out  When taking the Y waveform component

and feeding that into the Counter VI the values are wacko and depend on how fast the main VI updates.

- If the main VI updates every 200ms should the DAQ read VI be in the faster loop?

- I have tried to use the various waveform, pulse, period measurement VI's but these all give an error at a frequency of 0 or 1 Hz

- I have used the timing and transition measurement VI for this and wired the error out to a case structure and made the 'error out = true' case empty, this seems to be working but I'd think there must be a better

way than that. In addition, I need to average that signal over a timespan of a few minutes.

 

I hope the above made some sense. I'd be happy to try and clarify.

 

A hint in the right direction would be appreciated.

 

Thanks much

Arne

0 Kudos
Message 1 of 11
(9,374 Views)

RE: I need to measure the frequency of two pulsed flowmeter signals, 0-10V square pulses, the frequency regularly goes all the way to zero (at this point I am guessing my max frequency would be about 100Hz). I would use analog input channels for the signals since the range is 0-10V, then feed the waveform(s) to e.g to the Extract Single Tone Information.vi that will provide you with an output of the detected frequency. Also, be sure to sample at a rate greater than twice the highest frequency component of the signal(s) to accurately reconstruct the frequency of the waveform.

 

-Ciao

0 Kudos
Message 2 of 11
(9,350 Views)

 


@P.Sanders wrote:

RE: I need to measure the frequency of two pulsed flowmeter signals, 0-10V square pulses, the frequency regularly goes all the way to zero (at this point I am guessing my max frequency would be about 100Hz). I would use analog input channels for the signals since the range is 0-10V, then feed the waveform(s) to e.g to the Extract Single Tone Information.vi that will provide you with an output of the detected frequency. Also, be sure to sample at a rate greater than twice the highest frequency component of the signal(s) to accurately reconstruct the frequency of the waveform.

 

-Ciao


 

Hi,

 

Thanks for the reply. It turns out my frequency's are between about 0 to about 30Hz. The extract single tone VI, single tone measurements etc etc give incorrect values at frequencies below about

15 Hz. At a signal frequency of 9 Hz or so, these VI's output a detected frequency of around 20 Hz. Is this a limitation of the VI or am I doing something wrong here.

0 Kudos
Message 3 of 11
(9,345 Views)

I'm not entirely sure because I can obtain correct results all the way to 0 Hz. Create a new test VI set up an AI task, acquire the waveform at frequency x and check whether its detected correctly.

 

-Ciao.

0 Kudos
Message 4 of 11
(9,312 Views)

Will try that, thanks. I'll report back next week.

0 Kudos
Message 5 of 11
(9,284 Views)

Hi Abiermans,

 

Thanks for posting! For your the modules you have, you're going to have to acquire the signal as analog input and calculate the frequency in software. From the sounds of things, the frequency of the signal being generated is dynamic. What we need to know is the range of available pulse frequencies to be able to determine a 0 Hz signal, which is just a DC value. Let's say your device generates 0,1,10,100 Hz signals. To distinguish the 1 Hz from the 0 Hz, you would have to record 1 second worth of data. If that data was constant in that time you'd know that your device is generating a 0 Hz, DC signal. If 0.5 Hz was also a valid output, you'd have to record 2 seconds worth of data to see if the signal is 0.5 Hz or 0 Hz. The extract signal tone VI will work for any frequency in theory, but its accuracy depends on the number of periods of the input signal it has to actually make its calculation. You typically want at least 1 period. This should get you started but let me know if you need me to clarify anything.

 

Good luck!

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
0 Kudos
Message 6 of 11
(9,249 Views)

 


 

Hi,

 

I see were you are going with is. I verified that if I acquire the signal with my analog input and just wire it to the extract single tone VI the

result is a nonsense output at low frequency's, lower  than about 15 Hz. The signal I want to measure goes from roughly 30 Hz or so all the

way to zero. So basically , I have to gather x secs worth of data, analyze it and display the result. I assume I can gather x secs worth of

values in an array. How do I wire this to the extract tone VI to get a frequency?

 

Also technically you'd have to gather infinite secs of data to determine 0 Hz. Althoug if the value doesnt change for 5 secs I can consider it zero.

All that said. If I can measure down to 5 Hz and have the output display zero (and not jump all over the place) for anything less than 5 Hz

I'd be happy.

 

Thanks

Arne

0 Kudos
Message 7 of 11
(9,225 Views)

Hi Arne,

 

I think we're on the same page. I searched around and couldn't find an example that does a good job of this so I coded one up. I attached it here for LV 2009. I'll also be adding this as a community example. Hope this helps:

Measure Frequency of Analog Input

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
Message 8 of 11
(9,188 Views)
Solution
Accepted by topic author ABiermans

I just got back from holiday festivities. Thanks very much for your efforts. I will try and incorporate this into my VI.

0 Kudos
Message 9 of 11
(9,160 Views)

 

Allthough this is an older thread, i feel i have a contribution to this.

I was also looking for a way to measure low frequencies (in my case 0 - 500 Hz) and i have found a way that works for me.

I have decided to set frequencies lower than 0.5 Hz to 0, but that can be changed.

 

I am not using lab-view, so i post code with comments here. Maybe somebody else can use it.

 

The code is in C.

 

    Upon initialisation of the program :

 

    // timer task :
    DAQmxErrChk (DAQmxCreateTask("",&Freq1));
    DAQmxErrChk (DAQmxCreateCIFreqChan(Freq1,"Dev2/ctr0","", 0.1, 1000.000000, DAQmx_Val_Hz, DAQmx_Val_Rising, DAQmx_Val_LowFreq1Ctr, 0.001, 4, ""));
    DAQmxErrChk (DAQmxCfgImplicitTiming(Freq1, DAQmx_Val_ContSamps, 4000));
    DAQmxErrChk (DAQmxStartTask(Freq1));

 

For reading the data i use a 100 ms timer:

 

    // read current sample count
    DAQmxErrChk (DAQmxGetReadTotalSampPerChanAcquired(Freq1, &samplecount_new));
    // check if samplecount has changed since last time
    if ((samplecount_new != samplecount) && (samplecount_new > 0))
    {
        // only if at least one new sample was aquired the read will fetch a single sample:
        // make sure samples array is big enough for amount of samples received in 100 milliseconds (depends on max. frequency to be measured)
        if (samplecount_new < samplecount)
        {
            amount = (0xFFFFFFFFFFFFFFFF - samplecount) + samplecount_new;
        }
        else
        {
            amount = samplecount_new - samplecount;
        }
        DAQmxErrChk (DAQmxReadCounterF64 (Freq1, amount, 10.0, &samples[0], 4000, &read, NULL));

        zeroHzcnt = 0;
        // do something with the received saple(s) here...filtering etc.
        debug_printf("Timer val %7d freq %7.2f  %d  %d", data, samples[0], samplecount, samplecount_new);
        samplecount = samplecount_new;
    }
    else
    {   // no sample received in 100 milliseconds (= frequency lower than 10 Hz)
        zeroHzcnt = zeroHzcnt + 1;
        if (zeroHzcnt >= 20)
        {    // 20 times no new sample (= frequency lower than 0.5 Hz)
             debug_printf("Timer 2 sec no data => freq = 0");
             zeroHzcnt = 0;
        }
    }
    

 

This solution will not slow down the main application, because new data is only read when new samples are available.

No timeout will ever occur and the read function will never take up a lot of processor time.

Ofcourse when the frequency becomes low, the update of the measured value will slow down.

 

 

 

0 Kudos
Message 10 of 11
(8,827 Views)