LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Caculate phase difference between two sine waves

Solved!
Go to solution

Hey guys

Im having some trouble with this. I have read most of the topics related to this but none of the solutions posted have helped me.

I have this small circuit and im taking some voltage values using my pc sound card. Data acquisition is working ok. As you might know, the sine wave read in the resistor terminal has a phase different in comparison to the inicial wave read at the capacitor terminal. I have tested the VI file and i can confirm this in the graphics i see there. 

I have been having trouble identifing the phase difference (in degrees) between both waves.

I would really appreciate if you could help me out with this. Here is my VI file in case someone can give me some suggestions on how to calculate the phase difference in degrees. Also, in this VI, there are some tests i made with no good results at all. 

Any help will be appreciated

Download All
0 Kudos
Message 1 of 17
(14,087 Views)

Hi moreins,

 

I have seen your VI and I have calculated phase difference between two signals before. From my point of view, your code is doing ok. So, can you provide me with your signals? Just add Write to Measurement File, set to LVM file and X value Column as One Column per Channel and send me the LVM file. It would give me a better idea on troubleshooting your problems.

 

Looking forward for your reply,

Krisna Wisnu

 

Message Edited by Krisna Wisnu on 10-04-2008 10:22 PM
Certified LabVIEW Developer (CLD)
Certified TestStand Developer (CTD)
Using LabVIEW 8.5.1 (2008) to LabVIEW 2021
Message 2 of 17
(14,072 Views)

hey

thanks for the reply

im not home right now so theres no way to get the info you are needing. let me do that for you as soon as i get home and i will send it asap

thanks!

0 Kudos
Message 3 of 17
(14,062 Views)

heres the lvm file. i hope this can provide you more info.

i had trouble creating the lvm file so let me know if the file has what you need

Message Edited by moreins on 10-05-2008 10:51 AM
0 Kudos
Message 4 of 17
(14,025 Views)
Solution
Accepted by topic author moreins

Hi moreins,

 

I have changed the code, check this out! I provided two solutions which either way works to calculate phase difference.

Let me know if this solution works for you or not. Have a nice day!

Sincerely,

 

 

Krisna Wisnu

Certified LabVIEW Developer (CLD)
Certified TestStand Developer (CTD)
Using LabVIEW 8.5.1 (2008) to LabVIEW 2021
Message 5 of 17
(13,993 Views)

hello Krisna

thanks a lot for all the help given. the code you provided me works very vell. both methods are very useful and im gonna run some test to see which one adapts better to mi needs.

i have only one question. i ran the code you gave me with the lvm file i made yesterday and the phase difference is around 270°. ¿dont you think thats way too much? beacuse, when i look at both signals at the graphic they look they hardly have less than 90° of phase difference.

what do you think about this? should i susbtract 360° to the result that both methods is giving me??? because if i do that, im getting acceptable phase difference values

 thanks again for everything! Smiley Happy

Message Edited by moreins on 10-06-2008 09:05 AM
0 Kudos
Message 6 of 17
(13,964 Views)

Depends which one has been used as the reference sine wave.  1-2 = 90 Degrees, whilst 2-1 = 270 Degrees.

Craig

LabVIEW 2012
0 Kudos
Message 7 of 17
(13,955 Views)

the white signal is the one that comes from the the signal generator.

im confused now Smiley Surprised

0 Kudos
Message 8 of 17
(13,951 Views)

If the white one is the one from the signal generator and the red one is the delayed signal then the phase shift is the amount of phase to the right of the white signal.  So if you are expecting 90 degrees of phase shift you will have to modify the code so that instead of subtracting like so (Phase of white- Phase of red)  you subtract like so (Phase of red- Phase of white).  I cannot see your code as i am working in 8.2 otherwise i might of been a bit more help.

 

Another way is to subtract your existing answer from 360 Degrees.  i.e if you are getting say 271 Degrees, then subtracting this from 360 gives you 89 Degrees 🙂

 

Always more than one way to skin a cat 😉

 

Craig

LabVIEW 2012
0 Kudos
Message 9 of 17
(13,945 Views)

craigc wrote:

Another way is to subtract your existing answer from 360 Degrees.  i.e if you are getting say 271 Degrees, then subtracting this from 360 gives you 89 Degrees 🙂


thanks a lot for this. thats what i thought since its kinda weird having  271° of phase difference!

thanks a lot for this hint! Smiley Happy

Message Edited by moreins on 10-06-2008 10:05 AM
0 Kudos
Message 10 of 17
(13,928 Views)