# How to calculate phase rotation of I/Q reference samples for Bluetooth Angle of Arrival

I am trying to compensate phase rotation due to carrier frequency offset (CFO) for Bluetooth Low energy (BLE) Angle of Arrival (AoA). In BLE AoA the adv. packets carry a Constante tone extension @250Khz over a BLE Channel (@2.4Ghz).

As the clock of reciever and transmitter are not perfect there is a CFO of around 15 KHz.

So far Ive seen that CFO can be calculated by algorithms such as the ones proposed by Moose in 1994. In the case of BLE AoA, you get 8 reference samples from one antenna (1 MHz) and then you get a switching sample (500 Khz) for the rest of the antenna array elements. These 8 reference samples@1 Mhz are used to calculate CFO which allow to calculate correctly the wavelength of the signal.

I have read however, that you also need a phase rotation compensation. I would like to ask what are the common algorithms to calculate this phase rotation?

By searching around I found something about Costas Loop...would this be related to this ?

• You may need to read some material related to the topic of phase-locking loop (PLL). Costas Loop you mentioned is a special type of PLL. A PLL basically consists of a phase comparator (also called phase discriminator), a low-pass filter (called loop filter) and a voltage-controlled oscillator (VCO). en.wikipedia.org/wiki/Phase-locked_loop Jun 16 at 0:31

A Costas Loop is one common implementation for carrier recovery in single-carrier wireless communications. However phase rotation compensation for a complex baseband signal (where the RF signal is down-converted such that the center frequency where the carrier originally was is now at or near DC) is much simpler and done according to:

$$y[n] = x[n]e^{j\phi}$$

$$= x[n](\cos(\phi)+j\sin(\phi))$$

Where $$x[n]$$ and $$y[n]$$ are baseband IQ signals with real and imaginary components given as:

$$x[n] = I_x[n] + jQ_x[n]$$

$$y[n] = I_y[n] + jQ_y[n]$$

Thus if we multiply this out we see the full phase rotation process:

$$I_y[n] + jQ_y[n] = (I_x[n] + jQ_x[n])(\cos(\phi)+j\sin(\phi))$$

$$= (I_x[n]\cos(\phi) - Q_x[n]\sin(\phi)) + j(I_x[n]\sin(\phi) + Q_x[n]\cos(\phi))$$

Thus we see how a rotation by $$\phi$$ is done on each real and imaginary component according to:

$$I_y[n] = I_x[n]\cos(\phi) - Q_x[n]\sin(\phi)$$ $$Q_y[n] = I_x[n]\sin(\phi) + Q_x[n]\cos(\phi)$$

Note in the introduction how I mentioned the down-conversion process moving the signal at a carrier frequency at RF to at or near DC. For the case that it is near DC would be when we still have a "carrier offset" which is also removed through a frequency offset correction (in contrast to a phase offset correction detailed in this post). That is when we would use a "carrier recovery loop", again where a Costas Loop could be utilized. For further details please refer to this post.

How do I know this? I teach courses on DSP and Python related to wireless comm through dsprelated.com and the IEEE with new courses running soon!

• In this case as the signal is downsampled from 2.5 Ghz to 1 MHZ would this mean I could use this simpler approach? In addition do you have any book recommendation to learn more about these topics ? Thanks for the answer I will check as well the links you suggested. Jun 19 at 0:21
• Downsampling (resampling from a higher sampling rate to a lower one) is not the same as downconverting (translating a signal from one carrier frequency to another). What is actually done depends on the receiver you have- if you can determine the chipset you may be able to learn a lot from the manufacturers data sheets and app notes. That will likely lead to other questions that you can post here (keeping the posts here to specific Q&A as you progress). Jun 19 at 11:21
• Well according to the manufacturer and the BLE 5.3 specification for AoA, the signal is downconverted into baseband and the IQ samples are taken with 8 MSps directly on the baseband signal. I will conduct further experiments. On the side note I found very useful the book from Dr. Van Trees: Optimum Array Processing. Jun 19 at 12:45
• Perfect - then yes then what I wrote will well apply. Be aware that there will inevitably be a carrier offset which is a phase ramp with time (frequency is a change in phase divided by a change in time; d_phi/dt), so carrier recovery can remove both frequency and phase offsets. Jun 19 at 22:39