Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the correctly scaled amplitude of a power spectrum?

I am taking data off of a afm probe with a resonant frequency.  I want to determine the amplitude of the signal at the resonant frequency.  I've tried using AutoPowerSpectrum (FFT(x)FFT*(x)/n^2) and just plain FFT, but neither are scaled correctly when I input a sine wave at a given amplitude and frequency.  What do I need to do to scale my spectrum, so that I can tell the actual amplitude of the signal at the resonant frequency?
0 Kudos
Message 1 of 8
(8,012 Views)

Hi gja,

I was hoping you could post a screenshot of what you mean by incorrectly scaled amplitude.  Also, paste a  snippet of your code in which you are creating the spectrum.  This will help me determine what we can do to better scale your data.

 

 

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 2 of 8
(7,998 Views)

   


    ulCount= 200000 
    For i = 0 To ulCount - 1
        xtimetemp(i) = i / ulCount
    Next i

    For i = 0 To ulCount - 1
        xtime(i) = xtimetemp(i)
        Datanm(i) = 10 * Sin(xtimetemp(i) * 100000)
    Next i

    dttime = 1 / ulCount

    CWDSP1.AutoPowerSpectrum Datanm, dttime, pwrspecouta, df
 
    CWGraph2.PlotY pwrspecouta, 0, df
So, the input is one second of a sine wave with a peak-to-peak amplitude of 20 m and frequency 15916 Hz, but the power spectrum reads an amplitude of about 1.4. 
 
0 Kudos
Message 3 of 8
(7,992 Views)
Hi,
 
To make sure I understand what you are wanting.  You are expecting to see a graph with an amplitude of 20m at the specified frequency.  Looking at what you graphed and the output of the AutoPowerSpectrum you are plotting the Amplitude in RMS (root mean squared) when you actually want the peak value of amplitude.  You can tell not only by the unexpected value but also if you check your units on the y-axis they are m^2.  You can use the CWDSP.SpectrumUnitConversion method to convert the amplitude you get from the AutoPowerSpectrum function to peak value instead of RMS.  Also, make sure to set the ScalingFactor input for this function to Linear.
 
Let me know if this helps.
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 4 of 8
(7,977 Views)

Yes, I think this SpectrumUnitConversion should do the trick.  I do have a question on the inputs for that function however.  What exactly are the ENBW and CoherentGain inputs?

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

The Help topic for the SpectrumUnitConversion Method describes ENBW as, “equivalent noise bandwidth of the selected window. You can use this value to compute the power in a given frequency span.” CoherentGain is defined as, ”peak gain of the window relative to the peak gain of the Rectangular window. Use this value to normalize peak signal gains to that of the Rectangular window.”

 

The Help topic also says, “The ENBW and CoherentGain parameters are output by the ScaledWindow function. You need this input only when you use the spectral density output formats (the last four DisplayUnit selections).” In other words, you only need to use these inputs if you have used the ScaledWindow method and are setting the DisplayUnit to 4, 5, 6, or 7. From what you and Caroline have discussed, I assume you will be setting the DisplayUnit parameter to 1.

 

Regards,

 

Eric

0 Kudos
Message 6 of 8
(7,944 Views)
Thanks for your input.  I think that these functions will get me the solution I am looking for, but I am still having trouble with the syntax.  Can you please post an example of code using the ScaledWindow, AutoPowerSpectrum and SpectrumUnitConversion functions that will run in VB6?
0 Kudos
Message 7 of 8
(7,938 Views)

Hi Steve,

i do not have an example to show you but if you could tell me specifically what you have questions on in regards to the syntax than I can better help you out.  Let me know what specific parts of the functions you are having trouble with and I can help you out.

 

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 8 of 8
(7,923 Views)