Only data, no BS.

[ Frontpage >

Oscilloscope math channels


Accurate phase shift calculation formula for advanced math capable oscilloscopes

Measurement of phase between two signals is often required when using oscilloscope. Some scopes have built-in function for that, some do not. One could accomplish task with cursors, but this is time consuming and not ultimately accurate. Alternative is to use math formula. For example in PicoScope community following formula is circulated:


Formula is based on integration and is principally functional, but due to various technical nuances often does not work or displays completely wrong value, as demonstrated on screenshot above (orange trace, DC average over oldPhase(A;B) measurement). Main culprit is time it takes for integrated trace to "settle".

Substantially improved result can be obtained with formula operating on entirely different principle of trignometrical discretization. Condition is that signals have equal duty cycles at zero crossing. Duty itself may differ from 50%. Consequently works with pulses of equal length. Pulses must overlap. Within these limitations waveform of any shape and amplitude is first converted to square wave of "standardized" amplitude (inside formula). Then phase diff is obtained via simple arithmetics for two square waves (indigo trace, DC average over newPhase(A;B) measurement).


Results obtained with different methods on input of ChA: 10kHz, 0dBm triangle. ChB: 10kHz, -10dBm square:

Input 40°
newPhase(A;B) 39.86°
Cursors 37.54°
oldPhase(A;B) 55.84°

As seen new formula demonstrates accuracy unobtainable even by cursor measurement. Note that when phase diff is over 180° it starts to diminsh again with both formulas and reaches 0° by 360°.

Tests were conducted on PicoScope 6 - PC Oscilloscope software version:, PicoScope 2408B hardware. Signal generator was Siglent SDG2122X.

New development:

((((atan(1/tan(pi*(A/10000)))/pi)+(A/10000))*-((atan(1/tan(pi*(B/10000)))/pi)+(B/10000)))+0.25)/0.002777777 * (((atan(1/tan(pi*T))/pi)+T)*2)

To obtain numerical phase as single signed measurement (no graph) in -90°...90° range create discrete helper function that will have value -1 for T<0 and +1 for T>0. Then multiply phase-PWM trace with it. Not suitable for graphing. Auto-measurement must be made between cursors that are placed at -90° and +90°. Trigger quality (noise) will mess reading up (original function is pretty much immune to noise). See below, small signal (compared to current ADC range) is measured with low and high sampling rate, latter induces lot of sampling noise.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Contact lab!fyi