Phase shift measurement

Forum for discussing PicoScope version 6 (non-automotive version)
Post Reply
User avatar
jane
Newbie
Posts: 0
Joined: Sat Mar 03, 2012 12:20 pm
Location: Norway

Phase shift measurement

Post by jane » Thu Mar 08, 2012 4:55 pm

To find the phase shift between two signals (Ch A and B) I:
a) Add a cycle time measurement to Ch A (or B).
b) Use cursors to measure the time delay between signal A and B.
c) Calculate the phase shift from the information above.

Is it possible to implement a measurement into PicoScope 6 that calculates the phase shift (in deg) between Ch A and B.

BR
JanE

Martyn
Site Admin
Site Admin
Posts: 3229
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Phase shift measurement

Post by Martyn » Fri Mar 09, 2012 7:20 am

You can do this reasonably well using Maths Channels and the following equation

acos(integral(A*B)/(sqrt(integral(A*A))*sqrt(integral(B*B))))/Pi*180

although you have to take the value after the phase settles down as the start conditions are unknown and the first part of the trace will be inaccurate.
Martyn
Technical Support Manager

User avatar
jane
Newbie
Posts: 0
Joined: Sat Mar 03, 2012 12:20 pm
Location: Norway

Re: Phase shift measurement

Post by jane » Fri Mar 09, 2012 8:46 am

One word: Brilliant! :D
I ran a quick test connecting probe A/B before/after a filter and the phase shift read-outs matched the filter's transfer function very well.

Thank you!

BR,
JanE

Barnett
Newbie
Posts: 0
Joined: Mon Nov 07, 2016 5:20 pm

Re: Phase shift measurement

Post by Barnett » Wed Sep 19, 2018 8:56 pm

Hello,
I am trying to get used to the math functions in 2208B scope. Can you explain the steps in the phase calculation or point me to a paper? It works well. I would like to understand the steps.
acos(integral(A*B)/(sqrt(integral(A*A))*sqrt(integral(B*B))))/Pi*180

lab!fyi
Active User
Active User
Posts: 38
Joined: Mon Dec 12, 2016 6:58 pm
Contact:

Re: Phase shift measurement

Post by lab!fyi » Thu Sep 20, 2018 8:20 am

FYI there is newer method around:

"New accurate and fast phase shift calculation formula"
topic31641.html

Example, phase measured on 100MHz sines:

at 50GS/s: 6.387°
PS6000__phase_test__50GSas__short.jpg
at ~1MS/s: 6.372° (250x below "practical" Nyquist)
PS6000__phase_test__1MSas.jpg
Thats also absolute difference of 0.00417%

Martyn
Site Admin
Site Admin
Posts: 3229
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Phase shift measurement

Post by Martyn » Fri Sep 21, 2018 7:14 am

It is a correlation formula

integral(A*B)/(sqrt(integral(A*A))*sqrt(integral(B*B)))

to check A and B where 1 is positive correlation, 0 no correlation, and -1 negative correlation

before scaling to degrees.

If you also remember that integral is calculating the area under a curve, and by doing A*A you are rectifying the signal you should be able to understand the rest.
Martyn
Technical Support Manager

lab!fyi
Active User
Active User
Posts: 38
Joined: Mon Dec 12, 2016 6:58 pm
Contact:

Re: Phase shift measurement

Post by lab!fyi » Fri Sep 21, 2018 8:46 am

Martyn wrote:If you also remember that integral is calculating the area under a curve, and by doing A*A you are rectifying the signal you should be able to understand the rest.
...and there also lies trap for young players. With this method not only duty cycles but also areas under curve must be exactly identical otherwise calculus is off. phase(A;B) measurement is integral method taken between cursors where it is more less settled:
phase_trace_differences.jpg
Actual physical offset is 1.23°

Barnett
Newbie
Posts: 0
Joined: Mon Nov 07, 2016 5:20 pm

Re: Phase shift measurement

Post by Barnett » Mon Sep 24, 2018 5:04 pm

Thanks for all who have helped on phase shift measurement.
When I use (acos(integral(A*B)/(sqrt(integral(A*A))*sqrt(integral(B*B))))/Pi*180) I get up to a 30% error.

When I use ((((atan(1/tan(pi*(A/10000)))/pi)+(A/10000))*-((atan(1/tan(pi*(B/10000)))/pi)+(B/10000)))+0.25)/0.002777777 it matches the cursors.

I would still like to understand how the first formula works.
acos(integral(A*B)/(sqrt(integral(A*A))*sqrt(integral(B*B))))/Pi*180
Would you say the formula below is what it is doing?
acos(correlation formula)/Pi*180

Thanks / Charles

lab!fyi
Active User
Active User
Posts: 38
Joined: Mon Dec 12, 2016 6:58 pm
Contact:

Re: Phase shift measurement

Post by lab!fyi » Tue Sep 25, 2018 8:36 am

Maybe this helps a little:

https://www.eevblog.com/forum/testgear/ ... msg1106436
It's correlation formula. Will only show phase if the shape is exactly the same (except phase shift). For in-phase signals, it'll measure the similarity between waveforms (if you remove "acos" and scaling). It'll be "1" if the signals are completely the same (ignoring scale) and "0" if they're completely dissimilar. "-1" will mean the same sinal, but inverted. You can use the formula to measure how similar is your waveform to the sine wave (or any other signal you may want to use as an etalon).
Overall to understand the formula you start working "inside out". Something along these lines:

acos(integral(A*B)/(sqrt(integral(A*A))*sqrt(integral(B*B))))/Pi*180

=>

A*A
integral(A*A)
sqrt(integral(A*A)
sqrt(integral(A*A))*sqrt(integral(B*B))

A*B
integral(A*B)

etc. After you get a visual picture what each part does on specific signal you can put it together and understand. Brain likes visual ques. So even running seemingly basics on known signal like A*A can help sometimes.

Post Reply