LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse Frequency for a Water Flow Meter/Sensor

Hi,

 

I'm really new with Lab View and I'm trying to measure Water Flow Rate with the sensor YF-S201 ( http://www.hobbytronics.co.uk/yf-s201-water-flow-meter ) I'm using NI 6070E card. 

 

I need to get the flow rate in real time 

 

I'm attaching the simple VI I did. For some reason I'm not being able to make the measurement in the right way. 

 

Any advice will be greatly appreciated.

 

In advance, thank you for your help.

 

0 Kudos
Message 1 of 10
(6,977 Views)

Thank you for attaching your VI.  When I went to the site for your Hobbytronics device, it said "The page you are looking for cannot be found".  I'm guessing it produces TTL Pulses (0 to 5 v) at a rate proportional to flow, correct?  You are sampling it at 10 kHz, taking 1000 points and getting data back 10 times a second.  You seem to be using two methods to estimate pulse frequency.

 

I haven't tried measuring pulses, but what I would do (and may well just try it out!) is to use the Waveform functions to write a little test VI that makes such a pulse train with known parameters and then uses the two methods you used to see what results are returned.  Sometimes the best way to test code is to feed in "known" values and see what comes out the other end.

 

I'm generally "allergic" to Express VIs, especially the Dreaded DAQ Assistant and its Evil Twin, the Dynamic Data Wire.  Since you are "really new with LabVIEW" (note the only correct name and way of spelling it), I won't point you to the article "Learn 10 Functions in NI-DAQmx and Handle 80% of your Data Acquisition Applications" ...

 

Bob Schor

Message 2 of 10
(6,953 Views)

hi UFLow,

welcome to the forum!

 

the link you provided is broken some strange characters at then end

http://www.hobbytronics.co.uk/yf-s201-water-flow-meter

 

i never used the Express VIs, but from the looks, you should start only with the DAQ Assistant,

and check if you get data inside via the "Run" button on top.

what i noticed are your Samples and Rate values, which are extreme (i think).

at the moment you want 1 thousand samples every 10000ths of a second,

that means every second you accumulate 10 million samples.

start with very low values, like 100 samples and 1 Hz and verify that you get data.

 

there is also the NI Distributed Systems Manager (should be installed with your LabVIEW) where you can see what the current values are, that might also help with verification,

that your device and connection works.

 

my guess why your VI does not work is, that the DAQ Assistant shouldn't be placed inside a loop as you did, but other people with more knowledge about this should confirm/refute.

 

regards

 

EDIT: reading bob's post, i might have got my math wrong


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 3 of 10
(6,952 Views)

I just realized that I'm getting a PWM output...that's the frequency I have to get.

 

Is there any function for the analysis of PWM output?

0 Kudos
Message 4 of 10
(6,919 Views)

Hi UFlow,

 

There's an integrated magnetic hall effect sensor that outputs an electrical pulse with every revolution.

No, your sensor does NOT provide a PWM output!

You need to count the number of pulses per s (or any other time range you like) to get the amount of flow.

 

Which DAQ hardware do you use? Does it provide a simple counter, even as simple as provided y a USB6008? Then connect the pulse signal (which is TTL by specs) to the counter input and let your DAQmx device do the counting! (There's a huge library of example VIs coming with LabVIEW, and there are examples to count pulses.)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 10
(6,912 Views)

Hi GerdW,

 

Thank you for your response!

 

Thank you for your help I'm using a NI 6070E. 

 

I saw the examples but I couldn't use them. 

 

I know that it is an easy task but since I'm new I came to this forum. 

 

I'm a bit confused Smiley Frustrated

 

 

0 Kudos
Message 6 of 10
(6,909 Views)

Sorry, was sitting in a Doctor's office with my laptop, and discovered "No Internet"!  I whipped up this example to show you how to count pulses with an A/D converter, but GerdW is definitely right, if you really have TTL pulses, a Counter/Timer input is what you want to use.  But here's my code, anyway.  I used three different routines to estimate Frequency -- fortunately, all gave me the same answer.  The first is a Pulse Measurement VI on the Waveform Palette.  The other two are the Tone Measurement Express VI that you used (it looks different because I switched to Icon View), and the more-appropriate Timing Measurement Express VI.  I'll also attach a LabVIEW 2016 version of the code (but you should be able to code it from just looking at the Snippet ...].

Pulse Freq.png

Pulse Freq FP.png

Bob Schor

Message 7 of 10
(6,899 Views)

Thank you Bob!

 

I used the Timing Measurement and I think it's working! 

I'm just getting an error when I don't detect a signal but if I run the VI while I have a signal, it gives me the values! 

 

Smiley Happy

0 Kudos
Message 8 of 10
(6,874 Views)

Hi UFlow,

 

what about some minimalistic error handling?

Something like

IF error THEN
   frequency = 0;
ENDIF
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(6,872 Views)

Of course, what GerdW really wants you to do is the following:

  • Identify the Error number that signifies "no data yet, need to try again".
  • Add a Clear Errors function after the function that "impatiently" throws the error, wiring the particular Error-to-Ignore to its Specific Error input.
  • Use the Specific Error Cleared? output to decide whether or not to loop.

You'll find Clear Errors on the Dialog Palette, or use Quick Drop.

 

Bob Schor

0 Kudos
Message 10 of 10
(6,865 Views)