LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation of Phase from The FFT block in Labview?

Hi There,

 

I am using an example file (niUSRP Ex Tx Continuous IQ) in Labview 2011 to transmit the signal which has the FFT block to see the Magnitude spectrum of the Transmitting signal. In the example, the magnitude is 0dB at 1Khz ( which is the baseband signal). Now, I added the phase spectrum to see the phase of the Transmitting signal . I exported the graph to the excel and found out that it has very minimal value (almost corresponds to 0) at 1Khz. 
I was wondering , how is the calculation made to measure the mag and phase in the FFT block?

 

In this regard, I changed the Amplitude from 1 V to 10 V of the Transmitting I-Q signal and got following results

When Amplitude=1; Mag=0 dB

                              Phase= -5.41E-16

When Amplitude=10;Mag=20 dB
                               Phase= -1.52E-15 

 

Well, my question is how is FFT measuring such values for phase ?? ( what is the underlying mathematical equation ??) as I think , for Magnitude , it is basically doing the 20*log(1 or 10) to get 0dB or 20 dB.

 

I have also attached the IQ TX vi .

Waiting  for the Reply.
Thanks

0 Kudos
Message 1 of 8
(4,946 Views)

Hi Asimnud,

 

I'm not sure why you get a different phase when you increase the amplitude. I would like to try it myself, but I cannot run your code since there's a missing subVI (subGenPhaseContSine.vi). Can you post it here or point me to where you got it from?

 

Thanks

Tarek B
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(4,908 Views)

The vi is named as "niUSRP EX TX Continuous IQ" in the Modulation Toolkit Examples in Labview 2011 32 bit .

 

Thanks

0 Kudos
Message 3 of 8
(4,903 Views)

Are you really getting a larger value?  The two numbers are slightly diffrerent but it seems to me like a computation approximation error.  "E-15" or "E-16" is pretty much "0" in either case. 

 

 

0 Kudos
Message 4 of 8
(4,897 Views)

That is what I assumed too. However, I was more concerned about the equation, the FFT block is using to calculate that value for phase . Let me also tell you that , I use the same FFT block at the receiver end and get more decent phase value ( between -180 to 180 in degrees)

But, Again, I am curious about the mathematical equation used by Labview FFT . I tried to see the sub vi for the FFT block , but could not understand much from it . 


Putting it simple, what parameters does the the phase node of FFT block depends upon if not the amplitude???

=======================================
Here is some online research I did and tried to figure out the reason behind it . Depending on two different amplitude value , here are my assumption for two cases:

 

  1. When Amplitude is 1 V. The  peak-to peak value, in this case we have both I=Q= 1V, then its rectangular representation is I+Qi =1+1i V.While calculating it on dB 
    Either, Mag=20*log(I) = 20*log(1)=0 dB
    Or, Mag=20*log(squareroot(I^2+Q^2)) =3.01 dB
    But How does the FFT block calculates the phase value ? 
    Either, Phase=20*log(Q)=20*log(1)= 0 deg.
    Or,Phase= arctan(I/Q) = arctan(1)=45 deg


  2. If I change the Amplitude to 10 V, then its rectangular representation is I+Qi =10+10i V& its Mag and Phase in dB should change to
     Either, Mag=20*log(I)=20*log(10)=20 dB
    Or, Mag=20*log(squareroot(I^2+Q^2)) =23.01 dB
    In this case the phase must be 
    Either, Phase=20*log(Q)=20*log(10)=20 deg
    Or, Angle= arctan(I/Q) = arctan(1)=45 deg

===================================================================

The Magnitude for depicted in red bold font yields me the correct result. But I could not verify the same approximation for the phase value .

I would really appreciate if you could run the VI and clear my confusion over it.

Thanks Again

 

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

A double precision number has about 16 digits of resolution. So your 5.1E-16 is very much in that range. Since the computation of a phase and/or FFT is quite a bit complexer than a simple addition it is very believable that you got slightly different results during computation even if the actual value would be expected to be the same. Basically you are comparing 0 with 0 here (a phase of -5E-16 is really very much 0).

Rolf Kalbermatter
My Blog
Message 6 of 8
(4,881 Views)

Thanks Rolf.

That was one of my concern. I agree with you and Tarek being those value for phase correponds to 0. I think thats solved. And it makes sense because by default the input phase value is zero too.
Nevertheless, My other query is how does FFT block in labview function calculates that particular phase value. In short, I am keen to understand the theory or mathematics behind that.

Also, if you assign any finite random phase value to the I-Q signal, it still does not show that value in the spectrum . I am not aware if you could run the vi in your computer or not but its kind of fuzzy.

Really appreciate your suggestion 

0 Kudos
Message 7 of 8
(4,871 Views)

I agree. Your phases are very close to zero and thus well inside the -180..+180 range you expect. All floating point computations have such limitations, that's why they should never be used with e.g. "equal" comparisons.

 

An fft always results in a complex array, and since complex data can be expressed as magnitude/phase instead of re/im , there is no separate calculation involved. The phase is inherent.

 

If this is just for display, use an appropriate format, e.g. "%.6f" and these values will display as zero as you expect.

0 Kudos
Message 8 of 8
(4,865 Views)