06-14-2009 07:02 PM
Hello everyone.
I am reading from a flow rate sensor that outputs a square wave signal whose frequency has a linear relationship with the flow rate and ranges from 37 to 550 Hz. My hardware does not support reading the frequency, so I have to calculate it. What I ended up doing was reading the signal every 1 millisecond (1000 Hz), taking two samples and averaging them, and storing both the signal value and time at which it was read. Every 400 milliseconds, I loop through this data and find out how many cycles occurred and the time between the first and last cycle, divide number of cycles by that time.
Here's a graph of the signal.
Solved! Go to Solution.
06-15-2009 04:11 AM
06-15-2009 04:23 AM
What you see is the quantization noise. So in your 400 ms there might be 67 or 68 and sometimes 66 peaks). That is o.k.
You can reduce the noise by longer integration time, but it makes your sensor less responsive to changes.
Felix
06-15-2009 06:10 AM - edited 06-15-2009 06:15 AM
06-15-2009 07:37 AM - last edited on 04-04-2024 08:31 AM by Content Cleaner
Thanks for all the replies!
I'm not sure what the power line frequency is, I'll have to check. I'm using the SCXI-1000 with a NI SCXI-1100 module. I don't think the spec sheet I was given had the output voltage range, but I will have that and the cable checked out.
As for sampling faster then 1kHz, I'm not sure how to do that. I'm using a timed loop structure, the fastest I can loop is 1 millisecond. I did a little searching around, it appears you can use the hardware to do faster timing? I'll dig around some more, but if anyone knows how this is done that would be very helpful.
Again, thanks for all the answers, they are very helpful!
06-15-2009 08:04 AM
I never use software timed loops then performing DAQ operations as a thumb rule. It is to many negative issues connected to it. And as you mentioned you can not run a timed loop faster than 1Khz. You should go to the help menu in the toolbar, and then select find examples. Then you search for "continuous acq". It is best to leave all the timing details to the daq unit, and just pull data from the daq buffer then they are needed. I your case I will recommend a sample freq equal to 6KHz. That is more than 10 times your highest frequency. You can still update your data at 400msec intervals. Your signal also looks good. I can not much noise in your signal. So My guess is that your software is not optimal. You should not get 120Hz then there are no flow. If you post it we can take a look.
06-15-2009 11:04 AM
Thanks!
I took a look at the examples, I think the "Cont Acq&Graph Voltage-Int Clk" example is what I'm looking for. I didn't see my hardware in the requirements box, will it still work? (I don't have access to the hardware right now.)
Also, one last queston and I should be set. I still need to calculate the frequency of the signal, but I'm wondering if I'm doing it in the best way. I'm looping through the data and counting how many high-low-high's in the data using an enum to keep track of what state I'm in. I'll upload an example vi of what I'm doing, I just want to know if there is a better way to do it with LabVIEW Base.
Thanks so much for the replies, this is great information!
06-15-2009 12:11 PM - edited 06-15-2009 12:14 PM
I whipped up this quick and dirty. I do not think you get it more accurate. Take a look and see if you can use it.
Note! This user has only base version 😉
Edit I think the example VI you referred to is the correct one. But I have no DAQ VIs on my current PC
06-15-2009 01:04 PM
06-16-2009 02:22 AM
Lukepipe,
now that we know your DAQ Hardware, tell us more about your sensor (manufactor,type ) and cabling (type of wire, lengh) and we might be able to help you getting a better signal.
If your posted signal wave comes from your sensor without any flow there shouldn't be any pulses to detect and all I see is a 4.4V DC with 1.2Vpp line noise (120Hz is typical for 2 way rectifier on a 60Hz System).
The typical outputs of flow sensors are reed contacts (bad because of bouncing contacts), open collector (hall sensor) or pushpull (activ, sensor needs power supply) ...