# Least-Square circle fit and DC-offset estimation

42534total sites visits.

Zero-IF based radio receivers, because of phenomenon called “self-mixing” generate DC offset that can be much greater than the desired signal. Following are undesired effect of DC-offset:

Low level frequency amplifiers can be saturated by large DC offsets before the desired signal is amplified. The DC offset should be removed before the frequency correction of the received baseband signal can be performed, or the signal will turn into a tone at frequency correction with the AFC loop correcting the DC offset.

METHOD OF REMOVING DC OFFSET FOR A ZF-BASED GSM RADIO SOLUTION WITH DIGITAL FREQUENCY CORRELATION, US20040082302A1

Therefore, wireless communication systems that utilize Zero-IF radios have to overcome large DC offsets in the baseband signal.

In wireless communication systems where modulated symbols lie on a circle, the center of the circle can be seen as “DC-offset” and radius of the circle can be indicative of the power of the data signals. In case of no DC-offset, center of the circle lie on origin. And, any DC-offset displaces the the coordinates of the center of the circle (As can be seen from below figure).

Therefore, Problem of DC-offset estimation can be seen as finding the coordinates of center of the displaced circle. Once the coordinates of the center point are obtained, they can be subtracted from the received signal, thereby obtaining the corrected DC offset-free signal.

Below is octave script that estimates the center of circle based on Least square method.

% Create data for a circle + noise
th = linspace(0,2*pi,20)';
R=1.1111111;
sigma = R/10;
x = R*cos(th)+randn(size(th))*sigma;
y = R*sin(th)+randn(size(th))*sigma;
plot(x,y,'
o'), title(' measured points')
pause(1)

% Details and derivation of Least square circle fit algorithm
% here https://dtcenter.org/met/users/docs/write_ups/circle_fit.pdf

% coordinates of the barycenter
x_m = mean(x);
y_m = mean(y);

% calculation of the reduced coordinates
u = x - x_m;
v = y - y_m;

% linear system defining the center (uc, vc) in reduced coordinates:
%    Suu * uc +  Suv * vc = (Suuu + Suvv)/2
%    Suv * uc +  Svv * vc = (Suuv + Svvv)/2

uu = u.^2;
vv = v.^2;

Suv  = sum(u.*v);
Suu  = sum(u.^2);
Svv  = sum(v.^2);

Suuv = sum(uu.<em>v);
Suvv = sum(u.</em>vv);
Suuu = sum(u.^3);
Svvv = sum(v.^3);

% Solving the linear system
A = [ Suu, Suv; Suv, Svv];
B = [ (Suuu + Suvv)/2; (Svvv + Suuv)/2 ];
[ss] = A\B;

uc = ss(1);
vc = ss(2);
xc_hat = x_m + uc
yc_hat = y_m + vc

R_hat     = sqrt((x-xc_hat).^2 + (y-yc_hat).^2);

% reconstruct circle from data
xe = R_hat.*cos(th)+xc_1; ye = R_hat.*sin(th)+yc_1;
plot(x,y,'
o',[xe;xe(1)],[ye;ye(1)],'-.',R*cos(th),R*sin(th)),
title('
measured fitted and true circles')
legend('
measured','fitted','true')
text(xc-R*0.9,yc,sprintf('
center (%g , %g );  R=%g',xc,yc,Re))
xlabel x, ylabel y
axis equal