RF Measurement Devices

cancel
Showing results for 
Search instead for 
Did you mean: 

IQ magnitude vs Spectrum magnitude

Trying to sort something out.....Consider the following experiment where I transmit a single CW tone, which is caputred with an A/D that does a complex demodulation.  The IQ samples that result have been decimated to some BW.

 

Now...I can do two things.  I can take those IQ samples and compute the magnitude for each IQ pair (i.e. - sqrt(I^2 + Q^2)).  OR, I can send those IQ samples into some of the Spectral Measurements Toolkit vi's, and observe the magnitude *spectrum* over the acquisition BW.  In this case, the spectrum consists only of a single impulse at the CW tone.  My feeling was that the magnitude I measure from each IQ pair should be approximately the same as the peak of the computed spectrum, since even though my measurement has some bandwidth, all of my energy is located in a single place.

 

Unfortunately, this is not the case.  For example, if I put a known power level of x-dBm into say, my NI-5660, then I expected that the magnitude I calculated (i.e. sqrt(I^2+Q^2)), should be traceable back to that known input power.  However, whether I interpret that result in Volts, Vrms, Vpk, Vpk-pk....I can never quite get an "output" power that matches my "input".    

 

Furthermore, if I take those same IQ samples and put them through the Basic Power Spectrum.vi and then the Scale Power Spectrum.vi.....the peak magnitude of my CW tone is yet another different answer from the previous method, or the actual input.  To make things worse, the Scale Power Spectrum.vi is terribly difficult to follow, making it hard to figure out exactly how the code is scaling everything and what each of the options really does.

 

I suppose I have three short questions....

 

1. If I calculate the sqrt(sum of squares)....what units is that in?  Are I and Q scaled somehow such that I shouldn't expect to exactly trace back the input power?

 

2. Why, for a single CW tone and relatively narrow BW, would the sqrt(sum of squares) method be different than finding the peak of a power spectrum?

 

3. Is there a decent explanation anywhere regarding how the SMT vi's do scaling?

 

---
Brandon

 

 

 

 

0 Kudos
Message 1 of 8
(27,625 Views)

Hi Brandon,

It looks like you're pretty much on the right track with the computations, but as you seemed to allude to the units can get a little confusing. The I and Q values that come out of the niRFSA Fetch IQ (Complex Cluster) VI will be in Volts. If you look in the help for that VI it lays out the equation for conversion to power:

Y returns the complex-value time domain data array.

The real and imaginary parts of this complex data array correspond to the in-phase (I) and quadrature-phase (Q) data, respectively. To calculate the instantaneous power of a sampled I/Q point, use the equation (I2 + Q2)/2R, where R is the input impedance in ohms (Ω). For NI RF vector signal analyzers, R = 50 Ω.


From there you should be able to compare to the peak of the spectrum, but the value won't necessarily match up for a given IQ pair since the FFT for the spectrum is calculated over a full record, generally with some averaging involved. In the case of the SMT IQ Spectrum for niRFSA shipping example it is set up for RMS averaging. You could also change the Fetch IQ VI to return an unscaled 1D array of I16 which will give you the raw data that is acquired by the card.

Your second question may be answered by the inclusion of scaling for the input impedance in the excerpt from the help above. You would also need to bridge the gap between the power in Watts from calculation and the, presumably, dB(m) of the spectrum.

For your third question the answer is sort of yes and no. The "spectral info" output from VIs such as the SMT Zoom Power Spectrum VI will give you some scaling information, and if you are using the SMT Spectrum Unit Conversion VI as well (as in the IQ Spectrum example I've been referencing) then there is a user controlled conversion to a wide range of of units. Did you have specific SMT VIs in mind other than those?

Regards,

Peter Williams

Message 2 of 8
(27,602 Views)

Just to further clarify, the magnitude of the IQ data (magnitude = sqrt(I^2 + Q^2)) from RFSA equals the peak voltage (Vp) of the RF signal.  Assuming a sine tone, Vrms = Vp/sqrt(2).  So the Vrms of the RF signal (for a particular IQ sample) is sqrt(I^2 + Q^2)/sqrt(2).  I think this may be where you are getting stuck.  From this, Power = Vrms^2/R = (I^2 + Q^2)/2R, as Peter quoted in the documentation.

 

There are other conventions for what the scale of the IQ data means, but I believe sqrt(I^2 + Q^2) = RF Vp is more commonly used.

 

Boiling all this down, here's how I usually convert from IQ data to power in dBm vs time (see attached 'IQ to dBm vs time.png').

 

Note that '10**(0.5)' means 10^(0.5) (or sqrt(10)) to the LabVIEW expression node.

 

I see less than a 0.1 dB difference between the power read on a power meter, the peak search measured in the RFSA soft front panel, and the power computed from the IQ data as above.

 

Of course, multitone or proximity to the noise floor will make the results different. Note that the power found from the peak search function in the soft front panel varies a few tenths of a dB depending on the FFT window used ('Flat Top' seems to match the best).

0 Kudos
Message 3 of 8
(27,584 Views)

Great discussion.  Thanks.


I had to go back and work through the math of an IQ demodulator again in order to remind myself that the magnitude calculated from sqrt(I^2+Q^2) is equal to the peak voltage, Vp.  Indeed, calculating an "instantaneous magnitude" from each IQ pair gives approximately the same power as I know I'm inputting. Science marches on.

 

Also, this post reminded me that the Power Spectrum VI returns the power in Vrms^2 or dB....not dBm.  This is why I thought I was seeing some discrepencies.  Really...I just wasn't careful with what was being returned.

 

Now that I've got everything straight....a calculation of the instantaneous magnitude (sqrt(I^2+Q^2) and converted to dBm), matches well with the spectral peak using SMT Spectrum Unit Conversion.vi (when set for dBm)....as well as the Signal Processing->Spectral Analysis->Power Spectrum.vi, when I convert the output (Vrms^2 or dB) to dBm. 

 

I believe I was just a victim too many VI's that appeared to do the same thing, but were really all providing a different output.

 

Today's lesson: units matter!

 

---
B

0 Kudos
Message 4 of 8
(27,573 Views)

I found this VI very helpful. It came as a subVI to these examples that show the measurements made be the RF SFP.

https://decibel.ni.com/content/docs/DOC-22813

 

It converts back and forth from dBm, V, V^2, dBV, Watts, etc. 

 

This assumes that you have alread converted from I & Q to Vrms, which has been discussed above

     (Vrms = Sqrt ((I^2+Q^2)/2))

Once you have this, you can send it into the subVI to convert to desired units.  

 

The subVI has hard coded an impedance of 50 Ohm.  You can change it if your system has diff impedance.  

 

0 Kudos
Message 5 of 8
(26,752 Views)

If I want to take the fft of I and Q data to obtain a power spectrum, similar to what I would see on a spectrum analzyer,

would I take the fft of the raw signal - i.e. I + i*Q and then square the absolute value of the fft to get the spectrum?

 

Please advise.

 

Thank you 

0 Kudos
Message 6 of 8
(24,564 Views)

Here's what I've used.  There are other built-in ways to get the spectrogram, but I'm assuming you want to use the raw FFT for some reason.  Given the scaling conventions for IQ data used by RFSA and the FFT conventions in LabVIEW:

   Power in dBm = 20*log(magnitude(FFT(IQ Data)) / array size) + 10

 

See attached VI.  Note that I put an option for applying a hanning window in there (quick and dirty).  If you use one of toolkit functions, you'll get more advanced windowing options.  I also use a subVI to re-arrange the FFT so that negative frequencies are on the left (I put this together before LabVIEW added the 'shift' parameter on the FFT primitive), along with computing the correct f0 and df.  You can use the shift parameter instead.

 

For some reason the forum won't let me attach the VI (keeps saying "the contents of the attachment doesn't match its file type.").  So I'm attaching a screenshot of the diagrams instead.

 

Hope this helps.

 

0 Kudos
Message 7 of 8
(24,533 Views)

Hi, could you tell me why you + 10 for the Power "= 20*log(magnitude(FFT(IQ Data)) / array size) + 10"? Actually your method is really helpful and I can get the same result as using these two ways, but still confused about this equation.

it's really long long time ago.

Thanks

0 Kudos
Message 8 of 8
(9,892 Views)