# LabVIEW

cancel
Showing results for
Did you mean:

## Measure Frequency and Amplitude from Analog Signal

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

Message 1 of 16
(25,570 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

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.

With regards,
JK
(Certified LabVIEW Developer)
Give Kudos for Good Answers, and Mark it a solution if your problem is solved.
Message 2 of 16
(25,554 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

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.
Message 3 of 16
(25,546 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

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!

Chris_G
Sr Test Engineer
Medtronic, Inc.
Message 4 of 16
(25,517 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

From JK1: "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."

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

Message 5 of 16
(25,502 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

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

Message Edited by fred1261 on 09-11-2009 06:05 PM
Message 6 of 16
(25,443 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

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

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

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 7 of 16
(25,397 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

(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...

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

Message 8 of 16
(25,389 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

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.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 9 of 16
(25,386 Views)

## Re: Measure Frequency and Amplitude from Analog Signal

"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."

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

Message 10 of 16
(25,381 Views)