LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert time to frequency

Greetings,

 

I'm sure there's probably and easy way to do this, but it's escaping me this morning. 

 

I've been having some problems with a flow meter, and as part of my troubleshooting I did some data captures yesterday.  

 

My measurement system uses a counter input to measure output from the flow meter.  The frequency is multiplied by 60, and then by a conversion factor to me instantaneous flow rate.   At specified intervals, I save this rate to a file.  I can then open that file in a graph and see my flow readings over time.

 

Yesterday I did a simultaneous raw analog capture on that counter input using a separate DAQ system.  This was saved as a TDMS file.

 

What I'd like to do is take that TDMS file of pulse measurements and convert it to represent what I see when I'm looking my captured flow readings.  

 

Is there a way for me to "play" my recorded pulse train into a counter?  

 

Or is there some other way for me to convert this pulse train data?   

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 1 of 10
(4,945 Views)

Good Afternoon Patrick,

 


Is there a way for me to "play" my recorded pulse train into a counter?  

 

Or is there some other way for me to convert this pulse train data?   


 

You can "play" the recorded data by using a TDMS Read and a properly configured Analog Out task.  With this output wired to your normal input, you are able to duplicate the same input that you saw yesterday (assuming sampling rates and resolutions of the analog portions are correct).  This is just the opposite of how you captured your pulse train with an analog input and used a TDMS Write yesterday.

 

As far as converting the pulse train data, you can use a TDMS Read, parse out your data and reassemble it in whatever format you normally save your data.

Message 2 of 10
(4,920 Views)

Thanks for your reply Charlie. 

 

I realized after I posted it, that my question wasn't very well worded.  Unfortunately I was too busy putting out fires to go back and edit it.  

 

Now that I've thought about the problem a little more, I think I have an idea of how I can parse the data.  Really, all I need to determine is the Period between each pulse and then convert that to a Frequency.  Then just plot the frequencies.  

 

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 3 of 10
(4,896 Views)

Still having some trouble with this one.

Essentially what I want to do with this waveform data is extract the periods between the "pulses" and convert those into frequencies. 

Currently I'm working with the Pulse Measurements.vi  But it only returns one measurement per iteration.  Trying to put the VI into a For Loop has proven problematic for me. 

I've tried extracting the Y component of the waveform and using the size of that array to drive the For Loop.  I was then using the index of the For Loop to select which pulse to return the period for.  But this isn't correct.  It will only run so far, and then return an error stating that the waveform did not cross the mid reference level enough times to perform the measurement.

I think part of the problem is that with that method I'm looking for way more "pulses" then there actually is in the signal. 

I've tried using a number of different tools to define exactly what constitutes a "pulse" and to count how many of them there actually are.  But so far I haven't found anything that seems to work.  It's starting to feel very much like a "You can't get there from here" situation.  But I know there's probably a relatively easy way to get what need from this waveform. 

I'm including a couple of screenshots of the signal. 

When I work with the small segment of the waveform, I can enter pulse numbers from 1 to 5 and the Pulse Measurements.vi returns expected values for each of pulses.  If I try to find pulse #6 (which isn't there), I get the error above.  So I'm speculating that if there's a way for me to determine how many "Pulses" are in the waveform, I could wire that value -1 to the N Terminal of my For Loop.  I just can't seem to find the right tool to tell me how many pulses are in my signal. 

 

Pulse All.jpg Pulse Zoom.jpg

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 4 of 10
(4,873 Views)

Patrick,

 

It looks as though your pulses are fairly clean with good signal to noise ratio.

 

Why not just autoindex through the array looking for the transitions through a threshold.  That is v(i-1) > Vth and v(i) < Vth for the falling edge.  Store the values of i for which this is true in an array.  Then the differences between elements of that array multiplied by the sample interval are the pulse periods.  You might be able to calculate the differences directly in the transitions loop.

 

Lynn 

Message 5 of 10
(4,868 Views)

I hate admitting I'm this stupid.  But I just can't figure this out at all. 

 

 

Maybe it's time to look for a job flipping burgers. 

 

 

 

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 6 of 10
(4,854 Views)

Alright.  Looks like I got it. 

 

That was a lot trickier than I thought it would be.  Thanks for assistance. 

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 7 of 10
(4,847 Views)

Patrick,

 

I have been busy today so did not have time to do much more than to suggest an approach.  If you continue to have problems, post what you have tried along with some typical data saved as default.

 

Lynn 

0 Kudos
Message 8 of 10
(4,839 Views)

Your reply definately sent me in the right direction. Thanks again. 

 

I got a little frustrated with myself because I was struggling with a few pretty basic concepts after that.  But with a little help, I eventually got it.

 

And of course now it all seems much simpler than it did when I started.  

 

 

find pulse frequency.jpg

 

 

I was able to put the result array against my flow factors and conversion formula.  The results matched those that had been recorded by the counter function on the test stand. 

 

This is a good thing.  Now I can "weekend" properly.     :smileyvery-happy:

Message Edited by pallen on 06-27-2009 11:17 AM
---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 9 of 10
(4,821 Views)

Patrick,

 

Hope you had a good weekend.

 

The In Range and Coerce function and most math functions are polymorphic and accept array inputs.  Without trying both I cannot say which might be faster or more memory efficient, but here is an alternative way to do the tests.  I did not fill in the case structures in the first for loop. The output array might have a problem with the first or last element and the shift register should probably be initialized.

 

Lynn

Time to freq.png 

0 Kudos
Message 10 of 10
(4,795 Views)