Hello, I've been using an AD8302 module to try and read the reflection coefficient and phase from different devices under test. From the datasheet I am aware that I get the magnitude ratio as a value in between 0 and 1.8V. I want to convert this magnitude ratio into real and imaginary values which can then be transferred to a touchstone format (.s1p) file to be opened using a smith chart later on. May I know what formula to use to convert the magnitude ratio to complex form using the phase?

It looks like your phaseDiff equation is incorrect. Using equation 9 in the datasheet on page 16:

Vphase = -Rf*I_phi*(mag(phaseDiff) -90) + Vcp,

where Vcp = 0.9V, Rf*I_phi = 10mV/degree.

Solving for phaseDiff:

phaseDiff = +/- (Vphase - 0.9)/(-0.01) + 90

phaseDiff = +/- (90 - 100*Vphase) + 90

Perhaps if you implement the above equation, your results will look more realistic.