# Calculate frequency offset from phase offset

**URL:** <https://www.ruby-forum.com/t/calculate-frequency-offset-from-phase-offset/239492>\
**Category:** GNU Radio\
**Created:** [March 1, 2014, 4:49am UTC](https://www.ruby-forum.com/t/calculate-frequency-offset-from-phase-offset/239492 "2014-03-01T04:49:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [March 1, 2014, 4:49am UTC](https://www.ruby-forum.com/t/calculate-frequency-offset-from-phase-offset/239492/1 "2014-03-01T04:49:14Z")

</div>

Hi guys,

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

double gsm\_receiver\_cf::compute\_freq\_offset(const gr\_complex \* input,  
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
