LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

phase of a signal

Solved!
Go to solution

Hi there,

 

I have a signal and want to measure the ampl and phase. I m trying three different methods i.e. Discrete Fourier Transform ( I just calculate it myself, according to the formula), Fast Fourier and extract single tone information (using the sub-vi of NI ) and all give same amplitude but different phase. Can anyone have a look at my sample program and help me find out where is the error.

 

Thanks

0 Kudos
Message 1 of 15
(5,406 Views)

Hi helaka,

 

Thanks for the post!

 

It seems odd that you would get the correct Amp values but not the correct Phase differences.

 

I am aware that different techniques outcomes are to different accuracies, could this be the case here - how different are the values? 

 

These guys on this post, have a good working vi - does it work the same?

 

Kind Regards,

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 2 of 15
(5,374 Views)

Hi Hillman,

 

Thanks for the reply. I had a look at the post you suggested and I do not think that is the case, there they are talking about the difference in phase between two signals, I just have only one in my example. I tried again and I figured out that in order for me to have the same phase between the DFT and extract single tone information (sub_Vi) I have to calculate the phase as artan(real/imaginary) which seems odd to me, but is not that I am an expert in DFT. I tried also the mutiple tone sub_vi and it gives the same result like the single tone, while the sub_vi amplitude and phase spectrum gives a phase which is way off from the two others. In the program I have included a set of data so you can see how far the phase produced by the latter is.

 

Sincerely,

 

Helaka

 

 

0 Kudos
Message 3 of 15
(5,360 Views)
I am not sure what you are looking for.  Phase is a constantly changing parameter and can only be a constant when measuring it relative to another signal.  In an FFT function, the transform inherently defines a signal that starts with a phase of 0 radians (e^-jwt) to reference from.
Randall Pursley
0 Kudos
Message 4 of 15
(5,346 Views)

Hi Randall,

 

 Thanks for the reply. My case is this: I apply a small alternating voltage and I measure the temp oscillations of a sample at different temperatures of the bath, the temp oscillations measurement start at the same moment  when the voltage crosses zero, so the phase of the voltage is zero at this moment therefore I do not need to measure it . What I am saying is this, I wanted to make sure that my DFT calculation were right so I used different sub_vi of NI which are supposed to give the same result, but I noticed that if I use the amplitude and phase spectrum it gives a totally different result and same was true for my DFT calculation unless I change the formula of the phase calculation ( by the way all methods give almost the same amplitude). Now, is there any mistake in this sub_vi or it should not be used in this case I do not know.

 

 

0 Kudos
Message 5 of 15
(5,334 Views)

It appears that in the single tone code they add 90 degrees to the phase at the end.  I do not know why that is, but if you don't then the FFT and the single-tone phase are close to the same.

 

I will have to look into the DFT when I have more time to see what you are doing there.

 

 

Randall Pursley
0 Kudos
Message 6 of 15
(5,325 Views)
Solution
Accepted by topic author helaka

Take a look at the attached (v. 8.0).  All approaches come up with the same value after making the following changes.

 

1.  FFT - turned off 'unwrap phase' so reading is between -pi and pi.

2.  DFT - negate imaginary part (equations I found show the imaginary part negated)

3.  Single tone - Subtract 90 degrees from phase output

4.  Multi tone - Subtract 90 degrees from phase output

 

Of course, if you don't negate the imaginary part of the DFT, then the DFT, Single tone, and Multi tone all pretty much match with the FFT being 90 degrees out of phase.  I can't tell you why this is so.  Maybe the NI guys can shed some light on the differences.  Hope this helps.

Randall Pursley
0 Kudos
Message 7 of 15
(5,306 Views)

Hi Randall ,

 

Thank you for your time and help. 

Well you are right the guys of NI should shed some light where the error is.

 

Sincerely ,

 

Helaka

 

 

0 Kudos
Message 8 of 15
(5,289 Views)

Hi All,

 

I was in this thread earlier on - but it has developed rapidly.

 

I noticed you guys had a question..

 

So please could you ask me what your exact question is because I would like to help,

 

Kind Regards, 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 9 of 15
(5,270 Views)
The question is why you get a different phase for a signal when you compare the phase measurements from the FFT function and the Single-Tone function.  They are 90 degrees different.
Randall Pursley
0 Kudos
Message 10 of 15
(5,251 Views)