No BSD License  

Highlights from
Home Networking Basis

Home Networking Basis

by

 

11 Aug 2003 (Updated )

M-files for chapters 2-10 and Simulink models for Ethernet and Wireless Ethernet.

homepna2.m
%SYMBOL ENCODING
SEQ16=[1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0];
PREA64=[SEQ16 SEQ16 SEQ16 SEQ16];
% Call for hcs.m routine
hcs
FC=[FT RSVD PRI SI PE rrx];
ET=ceil(rand(1,16)*2-1);
EOF=[1 1 1 1 1 1 0 0];
PKT=[PREA64 FC DA SA ET EOF];
%2 Mbaud with zero insertion
x=zeros(1,280);
x(1:2:280)=PKT(2:2:280)*2-1;
ak=x;
y=zeros(1,280);
y(1:2:280)=PKT(1:2:280)*2-1;
bk=y;
%MODULATION
%7 times up sampling
xup7=zeros(1,1960);
xup7(1:7:1960)=x;
yup7=zeros(1,1960);
yup7(1:7:1960)=y;
% Call for filter gx routine
sqnqf7
xfilt=conv(xup7,gx);
yfilt=conv(yup7,gx);
t=[0:2128]/28e6;
cos2pift=cos(2*pi*7e6*t);
sin2pift=sin(2*pi*7e6*t);
xcos=xfilt.*cos2pift(1:2030);
ysin=yfilt.*sin2pift(1:2030);
ft=xcos+ysin;
%PASSING CHANNEL
% Get channel impulse response
load loop8
%loop8=zeros(100,1);
%loop8(13:15)=[0.5 1 0.5];
ftlp=conv(loop8,ft);
%DEMODULATION
xlp=ftlp.*cos2pift;
ylp=ftlp.*sin2pift;
xlpf=2*conv(xlp,gx);
ylpf=2*conv(ylp,gx);
xlpfd=xlpf(70:7:2199);
ylpfd=ylpf(70:7:2199);
%EQUALIZER INITILIZATION
rxx=zeros(20,20);
ryy=zeros(20,20);
rxy=zeros(20,20);
ryx=zeros(20,20);
rax=zeros(20,1);
ray=zeros(20,1);
rbx=zeros(20,1);
rby=zeros(20,1);
xk=zeros(20,1);
yk=zeros(20,1);
for i=1:128
    xk(:,1)=xlpfd(i:i+19)';
    yk(:,1)=ylpfd(i:i+19)';    
    rxx=rxx+xk*xk'/128;
    ryy=ryy+yk*yk'/128;
    rxy=rxy+xk*yk'/128;
    ryx=ryx+yk*xk'/128;
    rax=rax+ak(i)*xk/128;
    ray=ray+ak(i)*yk/128;
    rbx=rbx+bk(i)*xk/128;
    rby=rby+bk(i)*yk/128;
end
eq=inv([rxx rxy; ryx ryy])*[rax' ray']';
eq1=inv([ryy ryx; rxy rxx])*[rby' rbx']';
eqi=eq(1:20)/2+eq1(1:20)/2;
eqx=eq(21:40)/2-eq1(21:40)/2;
%ADAPTIVE EQUALIZATION
for i=1:280
    xf=xlpfd(i:i+19);
    yf=ylpfd(i:i+19);
    xout(i)=xf*eqi+yf*eqx;
    yout(i)=yf*eqi-xf*eqx;
    e1=ak(i)-xout(i);
    e2=bk(i)-yout(i);
    eqi=eqi+0.001*xf'*e1;
    eqx=eqx+0.001*yf'*e1;
    eqi=eqi+0.001*yf'*e2;
    eqx=eqx+0.001*xf'*e2;
end
figure(1)
plot([1:280],xout)
xlabel('Real Data')
figure(2)
plot([1:280],yout)
xlabel('Imaginary Data')
figure(3)
plot([1:20],eqi,[1:20],eqx)
xlabel('Equalizer Coefficients')
%DATA RECOVERY
for i=1:280
    if xout(i)>0
        xr(i)=1;
    else
        xr(i)=0;
    end
    if yout(i)>0
        yr(i)=1;
    else
        yr(i)=0;
    end
end
PKTR=zeros(1,280);
PKTR(2:2:280)=xr(1:2:280);
PKTR(1:2:280)=yr(1:2:280);

Contact us