lab!fyi

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