close all;clear all;clc % MATLAB script available by email [email protected]
1.- Simulating 2 random phases
ph1_deg=.1*(2*(randi([1 2],1,1)-1.5))*randi([150 1800],1,1)
ph2_deg=.1*(2*(randi([1 2],1,1)-1.5))*randi([150 1800],1,1)
2.- Generating signals
same carrier 2 random different phases within [15 180]deg
f1=23.5e6 % [Hz]
3.- So far so good, one checks a trigonometry manual and there you have it : Multiply both carriers and the phase difference should readily come up.
But the resulting theoretical expression is supposed to be time independent, it's supposed to be DC.
In RF boards DC is almost always blocked preventing access into different RF stages.
Shure Xilinx boards have some DC protection to prevent DC hitting signal processing modules.
wasn't this supposed to be a clear measurement of the phase difference?
perhaps the power of the difference
4.- There's a clear loss of amplitude accuracy, the amplitude that has to supply the DC reading for the phase difference.
May be another difference of powers?
5.- Let's focus on the zero crossings
6.- Perhpaps Low Pass Filtering
x1.*x2 increases DC accuracy?
sr = dsp.SignalSource;
sr.Signal = x12;
sink = dsp.SignalSink;
nth=20 % filter order
wsn=.25 % normalized Nyquist freq = fs/2
fir = dsp.FIRFilter(fir1(nth,wsn)); % .25 fraction of Nyquist freq
sa = dsp.SpectrumAnalyzer('SampleRate',fs,...
'OverlapPercent', 80, 'PowerUnits','dBW',...
'YLimits', [-150 -10]);
input = sr();
filteredOutput = fir(input);
filteredResult = sink.Buffer;
Low Pass Filtered signal containing the phase difference does not show the expected accuracy to measure phase differences.
And this is without noise.
Observe that the peak value is
To measure with precision a phase difference it is convenient to work with for instance a [0 5]V range, not with mV if possible.
7.- Squaring input signals
All that's left is to measure pulse widths, perhaps average a few of them and translate pulsewidth (time) to phase (difference)
Do not demodulate to DC.
All you need are the difference between squared input signals
if d1_deg>180 d1_deg=360-d1_deg; end
d1_deg is measured phase difference and
dph_deg is expected value.
8.- Example MFJ222 phase difference meter [1 50] MHz
Manufactured by MFJ Enterprises, 300 Industrial Park Road,
Starkville, MS 39759. Phone: (662) 323-5869
MFJ schematic (public, available online) showing signals conditioning
The sign ambiguity is not relevant because one may assume that
dph=ph2-ph1 in a certain order, but if the phase difference exceeds 180deg there's again a sign shift in the phase difference.
Therefore the important measurement is the absolute difference between phases.
In the measurement procedure one has to choose what signal is the reference and what signal phase is measured against the eference, thus deciding the order to consider for the difference,
9.- There's room for accuracy improvement
Measuring accuracy repeating for 1e5 rounds
ph1_deg=.1*(2*(randi([1 2],1,1)-1.5))*randi([150 1800],1,1);
ph2_deg=.1*(2*(randi([1 2],1,1)-1.5))*randi([150 1800],1,1);
if d1_deg>180 d1_deg=360-d1_deg; end
% dph_deg; % comparing
err_abs=abs(d1_deg-dph_deg); % absolute error
err_rel=err_abs/dph_deg*100; % relative error
title([' Amount samples : ' num2str(num_samples)])
The few scattered large errors are sign inversions that are not considered in the line with clause
if d1_deg>360 ..
10.- Regarding amplitude/phase noise, as long as 'small' the floating configuration show in the MFJ222 schematic is a the correct approach for the noise on both branches cancel each other, that never happens, such is the nature of noise, but it get's reduced, it's common practice in RF circuits.
Thanks for reading this answer.
If this answer is found useful would you please conside clicking on the accepted answer.