# Calculate frequency offset from phase offset

Hi guys,

I’m reading the code of Airprobe and I found this function.

unsigned first_sample, unsigned last_sample)
{
double phase_sum = 0;
unsigned ii;

for (ii = first_sample; ii < last_sample; ii++) {
double phase_diff = compute_phase_diff(input[ii], input[ii-1]) -
(M_PI /
2) / d_OSR;
phase_sum += phase_diff;
}

double phase_offset = phase_sum / (last_sample - first_sample);
double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
return freq_offset;
}

It calculates the frequency offset with “freq_offset = phase_offset *
1625000.0 / (12.0 * M_PI);” I guess the (1625000.0/12*pi) equals
(1625000/6)/(2pi) and 1625/6 kbit/s is the modulation rate of GSM.

So, what is the principle of this calculation? How to calculate the
freq_offset with phase_offset. I tried some derivation but failed. Can
anyone help me to find out the derivation ?

Best wishes,
Zhenhua

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.