09-07-2009 08:25 PM
Hi all,
I'm trying to find a way to get the frequency and ampltidue of a analog signal, but I'm not too experienced with LabView to know its many functions and cannot find one that could do that. This will need to run on the real time target cRIO.
Anyone know how to do this?
Thanks
-Freds
09-07-2009 10:26 PM
Hi,
analog frequency measurment two threshold limits i.e, upper and lower threshold limits. These represent the 1 and 0 levels of digital signal. For e.g. consider upper is 4.3 and 0.4 is lower threshold, When the signal crosses the 0.4 lower threshold start a timer till same threshold level occurs which represent one cycle of analog waveform. The time elaspsed between these two transitions gives you the dt of the cycle. Apply simple conversion to convert to frequency.
This is applicable only for periodic waveform.
post back for queries.
09-08-2009 01:00 AM
09-08-2009 12:48 PM
Hello fred1261,
There is actually an example in the Example Finder (Help » Find Examples) which shows how to take the amplitude vs frequency measurement of a signal on a real time target called “Realtime Amplitude Spectrum.vi”. You can find this example in the Example Finder by going to the Search tab and searching the keyword “real-time”. This example generates it’s own data, but can easily be modified to use data on channels of connected modules in the same chassis.
This should get you going in the right direction. Be sure to post back if this does not get at what you are trying to achieve!
09-08-2009 06:50 PM
This is applicable only for periodic waveform."
If I am understanding correctly, you're method is finding the period of the wave and then converting it to frequency? That seems to me like it would work, it seems like my Physics class from last semester is not as memorable...
From pine: "If you are acquiring sine signal, you can use "Extract Single Tone Information.vi" to get frequency, amplitude and phase of the input signal. This VI is on Signal Processing:Waveform Measurements palette."
That seems like a very effective and simple way to get the data, though I am not 100% sure the analog waveform will be a sine wave, but it probably will. Course, that is what I get for having to test a theory before buying a expensive device of which this code will be used on.
From Chris_G.: "There is actually an example in the Example Finder (Help » Find Examples) which shows how to take the amplitude vs frequency measurement of a signal on a real time target called “Realtime Amplitude Spectrum.vi”. You can find this example in the Example Finder by going to the Search tab and searching the keyword “real-time”. This example generates it’s own data, but can easily be modified to use data on channels of connected modules in the same chassis."
Oh really? LabView never ceases to amaze me with it's help. I did some searching in the help, but must've missed this example. So far this sounds like the best process, but I have yet to test it.
Hopefully, I will be able to get access to my team's cRIO and Lab View and try to put some of these methods into practice and see which works the best.
Thanks for the help thus far
-Freds
09-11-2009 04:59 PM - edited 09-11-2009 05:05 PM
I tried the "Extract Single Tone Information.vi", which kinda works, it throws some frequency and amplitude back at me - though its not anything recognizable and seems to grow as the data array I give it grows. Which is odd to me. Though if I use a proportion (ick - I know) it gives me the frequency I put in. I just don't know how to fix this waveform/data problem...
The example "Realtime Amplitude Spectrum.vi" is not entirely clear to me and I'm not exactly sure what its giving me nor how I would incorporate it into my project.
This is all new stuff for me, so I don't reallly know what I'm doing. I've never worked with waveforms in LabView (or in life for that fact...)
Edit: Do I not need to set the sample rate somewhere? Or something of that sort?
Thanks
-Freds
09-12-2009 06:20 PM
I tried the "Extract Single Tone Information.vi", which kinda works, it throws some frequency and amplitude back at me
--- I've never used it before, but I gave it a test withe a sine waveform, and it gives me exactly the answers I expect.
- though its not anything recognizable
--- Please explain.
and seems to grow as the data array I give it grows.
--- What "grows"? the frequency output? the amplitude output? what?
If you feed it a WAVEFORM, everything is there to give you the right answers.
If you feed in an array of DBLs, it will accept it, and do its best. The amplitude seems right (that's easy).
But you'll have to figure out the frequency scaling yourself.
Since you're not telling it what the sample rate of your data is, it assumes 1 Hz.
If your sample rate is 892 Hz, then multiply the DETECTED FREQUENCY you get by 892.
That shouldn't grow just because you sample a larger block.
Hope that helps
Blog for (mostly LabVIEW) programmers: Tips And Tricks
09-12-2009 07:10 PM
(Quoting in these forums is such a pain)
"I've never used it before, but I gave it a test withe a sine waveform, and it gives me exactly the answers I expect."
True, but all the examples seem to work and they all use computer generated waveforms. I don't know...
"Please explain."
In reference to the frequency and amplitude the VI returns, it seems kind of meaning-less. Both didn't appear to be correct and had a "m" attached to the number like a unit (though it seems it was just a option of display formatting - "SI Formating"?).
"If you feed it a WAVEFORM, everything is there to give you the right answers.
If you feed in an array of DBLs, it will accept it, and do its best. The amplitude seems right (that's easy).
But you'll have to figure out the frequency scaling yourself.
Since you're not telling it what the sample rate of your data is, it assumes 1 Hz.
If your sample rate is 892 Hz, then multiply the DETECTED FREQUENCY you get by 892.
That shouldn't grow just because you sample a larger block."
I'm feeding it a waveform, using the build analog waveform VI, as I did not know you could feed the VI a array of DBLs. You have to scale the frequency output? That I did not know and seems to make sense with the numbers we've been getting
Thanks for the new input, I'll have to try it tomorrow though.
Cheers
-Fred
09-12-2009 07:32 PM
You have to scale the frequency output? That I did not know and seems to make sense with the numbers we've been getting
That's true ONLY for the case where you feed it [DBL].
If you feed it a waveform, the info is in the waveform for it to calculate the correct answers.
If you're building the waveform yourself, make sure you set the "dT" value correctly. That establishes the sample rate and everything that depends on it.
The "m" you're seeing is a format in the indicator. It represents 1/1000, or "milli", just like "mSec" or "mVolt".
If you attach a "plain" indicator, you'll see "0.01" where you see "10m" in the fancy one.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
09-12-2009 07:53 PM
If you feed it a waveform, the info is in the waveform for it to calculate the correct answers."
Oh - that changes things then.
"If you're building the waveform yourself, make sure you set the "dT" value correctly. That establishes the sample rate and everything that depends on it.
The "m" you're seeing is a format in the indicator. It represents 1/1000, or "milli", just like "mSec" or "mVolt".
If you attach a "plain" indicator, you'll see "0.01" where you see "10m" in the fancy one."
I'm setting the dT value correctly, in seconds and yet still everything isn't right
Seeing the milli "m" is a bad sign that things aren't working then. 😛
Would it be better to attach a DBL array than building my own waveform or would both methods be the same?
Is there a specific way to build data into a DBL array for the "build a waveform" method (using the VI to build a waveform before passing it to the analyzing VI)? Right now we're taking in data and limiting the size of the array to a certain size. Having no examples or anything of the sort (downfall of having computer generated waveform examples, that is just what we are assuming...
Thanks
-Freds