LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the corresponding X-Axis value of the Detected Maximum Amplitude?

Solved!
Go to solution

Hi, I am able to get the maximum amplitude from a data but I also want to get its corresponding X-Axis value. How do I do that?

 

Here's a look at the reading in my Front Panel:

 

data.png

 

Looking at the TDMS file of my data. It can be seen that 2.9238 (amplitude) is actually the highest. However, the displayed Fundamental Frequency is not the corresponding value of the highest amplitude.

 

data2.png

0 Kudos
Message 1 of 8
(5,421 Views)

I would do something like this.  I have two elements in the cluster: the Amplitude and the Frequency, in that order.  You can then use the Max & Min on the cluster.  Make sure the Max & Min has the comparison mode set to "Aggregates".  It will compare the first element first, which is why you want the amplitude to be the first element in the cluster.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(5,395 Views)

Hi Jerson,

 

In your code you are writing values of amplitude and fundamental frequency for each iteration of the For Loop. So each amplitude corresponds to its fundamental frequency.

 

To find the highest amplitude, for each iteration amplitude value is being compared with the highest value got during previous iterations, so after the loop is finished, you get the highest amplitude.

 

While the fundamental frequency shown on the indicator is just the last recorded value, as it can be seen also from your screenshots.

 

To find the fundamental frequency corresponding to the highest amplitude you can write it also to a shift register, as the amplitude, but you should update the shift register value, only in case the maximum value of the amplitude was changed.

 

Thanks,

Arev

 

CTO | RAFA Solutions

 

Certified-LabVIEW-Embedded-Systems-Developer_rgb.jpgCertified-LabVIEW-Architect_rgb.jpg

Message 3 of 8
(5,387 Views)

@JersonJose wrote:

Hi, I am able to get the maximum amplitude from a data but I also want to get its corresponding X-Axis value. How do I do that?

 


You are mixing waveform and dynamic data, which is a bit confusing.

 

After the transform, you'll have a new waveform where x is frequency instead of time, bu all you need is tap into the "max time" output of waveform min&max to get the generic x-value corresponding to the maximum amplitude. Convert it to DBL for a more intuitive value. Now keep track of it in a shift register, similar to the max value and replace it whenever a higher max is found.

0 Kudos
Message 4 of 8
(5,355 Views)

@arevh wrote:

To find the fundamental frequency corresponding to the highest amplitude you can write it also to a shift register, as the amplitude, but you should update the shift register value, only in case the maximum value of the amplitude was changed.


How do I update the shift register connected to the fundamental frequency when the highest amplitude is gathered? Am I going to use a specific block for this one?

 

0 Kudos
Message 5 of 8
(5,305 Views)
Solution
Accepted by JersonJose

Hi Jerson,

 

You can implement something like this.

 

Freq.PNG

 

Check if the highest value was updated, and if yes, write appropriate frequency to the shift register.

 

You can try also implementing solution suggested by 

 

Thanks,

Arev

 

CTO | RAFA Solutions

 

Certified-LabVIEW-Embedded-Systems-Developer_rgb.jpgCertified-LabVIEW-Architect_rgb.jpg

Message 6 of 8
(5,284 Views)

Hi arevhamb,

 

I tried what you suggested and it is working perfectly! Thank you very much for your help and inputs.

0 Kudos
Message 7 of 8
(5,251 Views)

@JersonJose wrote:

 

I tried what you suggested and it is working perfectly! Thank you very much for your help and inputs.


One flaw is the fact that several frequencies could have the same amplitude, so this code give the highest frequency that matches that amplitude. If you want e.g. the lowest frequency with that amplitude, you would need to rearrange the code a little bit.

 

(Yes, comparisons with DBL are quite unlikely to produce an equal, especially after fancy transforms, but the theoretical possibility exists. The current code is not bulletproof.)

 

It is also a really bad habit to initialize the shift register with zeroes here, because it makes the code too specialized and it cannot ber re-used for seemingly similar, but slightly different problems. For example if you try to re-use the code for a case where all amplitudes are negative, the uninteresting zero would always be the largest. You should initialize the upper shift register with -inf and the lower with NaN, for example. The current code is not universal.

Message 8 of 8
(5,232 Views)