7

I have the output of my FFT, an array of complex numbers, and each one has been computed to the magnitude squared. To my understanding, the magnitude squared is equivalent to the power, so in order to map to dBm, I would take 10 * log(x) of each of these numbers. This does not seem to give accurate dBm levels according to another spectral analyzer.

Converting to magnitude voltage, by taking the square root of the magnitude squared and dividing by the size of the FFT, and then taking the 20 * log(x) of this number seems to give closer dBm level when compared to other equipment. Why is this?

Brian Carlton
  • 13,252
  • 5
  • 43
  • 64
upswimsdn
  • 171
  • 1
  • 1
  • 3
  • 1
    What units is your magnitude in? dBm is dB relative to 1 mW, so you probably need to consider a reference impedance also. Volts alone is not enough. – Juancho Jun 27 '12 at 23:08
  • You possibly will get exact match to expected values if take into account Sinc roll-off effect and windowing effects. Also to ignore effects and simply validate algorythm, use 2 known different Sin signals in one mix and compare with expected difference in power. –  Jun 27 '12 at 23:44
  • None of the answers below address an important part of your question: "dividing by the size of the FFT" in one case, and not in the other. Assuming your FFT algorithm only scales on the inverse, you need to divide by the FFT size which is due to Parseval's theorem. – MrMas Oct 27 '17 at 18:20

2 Answers2

7

10 Log10 of the magnitude squared yields dB, but not dBm. dB is a relative measure. Since dB are logarithmic, you can add some constant to a pile of dB numbers and the pile still has the same meaning because separate dB numbers are only relative to each other.

However, dBm defines 0 as representing 1 mW. Now there is a absolute reference, so individual dBm numbers are no longer just ratios but actually represent fixed power levels. For example, 42 dBm = 15.8 W.

The problem you have is that you don't apparently know what the input values to your FFT represent. Is it a voltage signal, a current signal, something else? Power is proportional to both the voltage squared and the current squared, but you can't know absolute power without the proportionality constant. In the case of voltage squared, the proportionality constant is 1/resistance. In the case of current squared, it is resistance.

So the real problem is that you don't know what is coming out of your FFT because you don't know what you stuck in. This is often a problem when people get sloppy with units, or ignore them altogether as in this case.

Let's say for sake of example that what you put into the FFT was a EMF signal in units of volts. That means the magnitude squared you are referring to is in units of volts squared. That still doesn't tell you power though. If you knew, for example, that this voltage was driving a load of 600 Ω, then you can compute power. A FFT output value of 1 V² would then imply a power of 1.67 mW, which means 2.22 dBm. In this example, you could multiply the V² values by 1.67 first and then take 10 Log10 to get dBm, or equivalently take 10 Log10 of the V² values then add 2.22 to get dBm. Of course the actual factor you use to adjust 10 Log10(V²) to dBm depends on the resistance the original voltage is driving, which you haven't told us.

Pay attention to units.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
  • I think 42dBm is an exact number as it is 10+10+10+3+3+3+3dBm it becomes 10*10*10*2*2*2*2 mW, so 16W by my count, but I could be incorrect. This is not something serious, but I am wondering if I am doing the math incorrectly and have for years. – Kortuk Jun 28 '12 at 03:17
  • @Kortuk - wrong, wrong, wrong! ;-) No it's not that bad. Log(2) = 0.3010(3), not 0.3. So you have a slight rounding error of 0.3%. I've never needed more than 2 significant digits for a dB value anyway. – stevenvh Jun 28 '12 at 05:22
  • @Kortuk: Your rule of thumb where 3 dB is a factor of two is quite close. You got 16 W with a quick and dirty calculation you can do in your head, and I got 15.8 W by doing the more exact math with a calculator. That's actually pretty good. The precise answer is 10^4.2 mW, which is about 15,849 mW, or 15.8 W rounded to three places. Basically, we are both right. – Olin Lathrop Jun 28 '12 at 11:10
  • @Kortuk: Put another way, a factor of 2 in dB is 10 Log10(2), which is 3.01030...., for which 3 is a useful approximation especially when manipulating dB in your head. However, you have to keep in mind that it is a shortcut and approximation, and not loose sight of the real definition of dB, which is 10 log10(power). – Olin Lathrop Jun 28 '12 at 11:14
  • Yeah, I thought it might be a rounding error but I was wondering to what extent. Thanks for taking the time. @stevenvh answered it already but at the time it was more fun to ask and I used it to show others a way to do dB quickly. I have never needed more than 2 sig figs either because in all of my situations measuring extremely accurately is possible but our systems often could have errors in the +-3dB range. Fun fun. – Kortuk Jun 28 '12 at 12:39
  • @Olin - Thank you, this was very helpful. I'm using a USRP and GNU radio to look at channels in the TV band spectrum, so the input to the FFT is coming from an analog to digital converter, which should be in terms of volts. – upswimsdn Jun 28 '12 at 17:47
  • @upswim: It sounds like the A/D is measuring voltage, or more accurately EMF (ElectroMotive Force), but there is no guarantee the numbers are in units of volts. Unless someone has done deliberate conversion, the probably are not. – Olin Lathrop Jun 28 '12 at 18:56
5

To my understanding, the magnitude squared is equivalent to the power,

The magnitude squared is proportional to the power. Think of it this way, if you measured the voltage across a resistor and squared it, you have the numeric value of the power normalized to 1 ohm, i.e., the power that would be associated with that voltage across a 1 ohm resistor. Similarly for the current through a 1 ohm resistor.

So, to find the actual power, you need to know the value of the resistance the voltage was across or the current was through.

Since 1 volt across 1 ohm yields 1 watt, and 10 log (1) = 0, you're finding the power in dB referenced to 1 watt into 1 ohm when you take 10 log of the magnitude.

Alfred Centauri
  • 26,502
  • 1
  • 25
  • 63