From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Phase shift between a pulse and sin wave

Hello,

 

I was wondering if there is any VI that I can use to get the phase shift between a pulse and a sin wave (they have same frequency).

 

The Ideal case is that the pulse should go to 1 when sin wave is positive and goes to 0 when the sin wave is negative. I want to set this test to measure the phase shift between pulse going to one and sin wave going positive.

 

We just bought labview full version with Signal processing package, and I was wondering if there is anything that would be useful for me.

 

Thanks in advance,

Baran.

0 Kudos
Message 1 of 16
(4,075 Views)

This question has come up before. Did you try a search? For example: http://forums.ni.com/t5/LabVIEW/Caculate-phase-difference-between-two-sine-waves/td-p/787043

0 Kudos
Message 2 of 16
(4,068 Views)

Thanks.

0 Kudos
Message 3 of 16
(4,065 Views)

I am getting signals from DAQ 6009 and the results this example gives me is way off. I expect to have phase shift in order of couple of degrees, but it gives me 30 - 40 deg, and it keeps changing.

 

What I had made myself is to read the sin wave when the pulse goes up and divide it by the max of sin and get acos to find the phase, but that changes too from 3 to 5 degrees, and I am not sure if that's because of the accuracy/noise of my DAQ or something else.

 

 

0 Kudos
Message 4 of 16
(4,053 Views)

Can you save the data you got from the 6009 so that we can see it? For instance, you could run the VI, get the graph, then stop the VI. Then right-click on the graph and select Data Operations -> Make Current Value Default. Save the VI and upload it. Or, you could just save the data to file and upload that. If you do the latter be sure to include a screen shot (PNG, NO BITMAPS) so we can verify what the waveforms look like.

0 Kudos
Message 5 of 16
(4,049 Views)

I attached a VI file with the graph. 

For this one the two methods in the example gave me -21 and 19 degrees.

 

Thanks.

 

 

 

0 Kudos
Message 6 of 16
(4,042 Views)

Hi Baran,

 

Try this on for size and see if it works for you.

 

Phase Difference.png

 

Have a great day,

 

Chris V

 

 

Applications Engineer
National Instruments
0 Kudos
Message 7 of 16
(4,011 Views)

@Chris V wrote:

Hi Baran,

 

Try this on for size and see if it works for you.


Chris, that's what shown in the example I linked to.

 


@Baran wrote:

I attached a VI file with the graph. 

For this one the two methods in the example gave me -21 and 19 degrees


I'm not quite sure I understand what you are saying. If I replace the graph that's on the front panel of the example I linked to with your graph, one method gives me -15.3 and the other gives me -17.3.

0 Kudos
Message 8 of 16
(3,994 Views)

Even 15 and 17 is a little high! I don't understand why you got different results!! I get my signals from DAQ with N samples. Could that make any problem?

 

0 Kudos
Message 9 of 16
(3,985 Views)

How many samples per cycle are you acquiring? Are both the sine and square channels acquired in the same DAQ read?

 

Lynn

0 Kudos
Message 10 of 16
(3,978 Views)