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 difference for each pulse of square waves

I have the following VI that is used as a subvi to calculate the phase difference between each pulse of two square waves. It works great the majority of the time, but on occasion it will end up throwing out a phase that is in the millions. I'm not seeing anything really jump out at me, and wondering if anyone may see what is causing that issue.

0 Kudos
Message 1 of 6
(2,162 Views)

Hi guy,

 

on occasion it will end up throwing out a phase that is in the millions. I'm not seeing anything really jump out at me

When you got very large values for Phase then most probably the Divide, followed by ×360, is the reason for this…

check.png 

(See those other subtle changes to your VI. There could be even more changes…)

 

Can you debug your VI and put a conditional probe inside to stop the VI for exactly this problem? Then set all values to default, save the VI and attach it again!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,160 Views)

For the conditional probe and setting values to default. What is the best way to do that in a subvi? I was hoping to just run the main vi and then open the subvi and set the values, but all the values were still zero.

0 Kudos
Message 3 of 6
(2,147 Views)

I manged to get the values to save. Here is a normal example of when it happens. Max phase is 86, and min phase is -1.7E9.

0 Kudos
Message 4 of 6
(2,123 Views)

Hi guy,

 

it's the way you calculate the phase:

check.png

Graph1 shows the intermediate results of the counting loops, graph2 the resulting phase: you divide a large number by a small number resulting in a large number…

 

As there is some noise on your data: would it help to set this "High limit" to values around 6, somewhere in the middle between HIGH and LOW level?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(2,113 Views)

In the main vi I have a case structure that will read the voltage from the config file, and set the limits to the middle of the voltage being used. What I ended up doing to capture that data was just add the capture to the vi and ran it alone, so I was playing around the value to see if it mattered. Do you have any recommendations on the correct way to calculate the phase values?

 

What I wanted it to do was subtract the time difference between the two channels, and then divide that by the period to get the phase percent. As I'm looking at this, it seems like I need to find a better way to find the time difference between the signals.

0 Kudos
Message 6 of 6
(2,104 Views)