## Phase shift measurement

### Phase shift measurement

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

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

### Re: Phase shift measurement

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.

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

Technical Support Manager

### Re: Phase shift measurement

One word: Brilliant!

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

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

### Re: Phase shift measurement

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

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

### Re: Phase shift measurement

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° at ~1MS/s: 6.372° (250x below "practical" Nyquist) Thats also absolute difference of 0.00417%

"New accurate and fast phase shift calculation formula"

topic31641.html

Example, phase measured on 100MHz sines:

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

### Re: Phase shift measurement

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.

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

Technical Support Manager

### Re: Phase shift measurement

...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: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.

Actual physical offset is 1.23°

### Re: Phase shift measurement

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

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

### Re: Phase shift measurement

Maybe this helps a little:

https://www.eevblog.com/forum/testgear/ ... msg1106436

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.

https://www.eevblog.com/forum/testgear/ ... msg1106436

Overall to understand the formula you start working "inside out". Something along these lines: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).

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.