Lab2

Teacher assistants:
Chun-Kai Tseng
Guan-Yu Lu
Yi-Chu Yang
Block Diagram
(Unit 1-3 p.32)
2
1
3
4
2
Matlab Code
1
x=round(rand(2,num_of_bits(1,index)));
symbol
if (x(1,i) == 1)&&(x(2,i) == 0)
delta=pi/4;
else if (x(1,i) == 0)&&(x(2,i) == 0)
delta=pi*3/4;
else if (x(1,i) == 0)&&(x(2,i) == 1)
delta=pi*5/4;
else
delta=pi*7/4;
end
end
end
3
Matlab Code
2
int_interval = [0:Ts:Tb];
s(i,:) = sqrt(2*E_normal/Tb)*cos(2*pi*fc*int_interval)*cos(delta)
- sqrt(2*E_normal/Tb)*sin(2*pi*fc*int_interval)*sin(delta);
4
Matlab Code
3
rx(1,i) = sum((s(i,:) +randn(1,length(phi1_1))*sqrt(N_0/2)/sqrt(Ts)).*phi1_1)*Ts;
rx(2,i) = sum((s(i,:) +randn(1,length(phi1_2))*sqrt(N_0/2)/sqrt(Ts)).*phi1_2)*Ts;
5
Matlab Code
4
if rx(1,i) > 0
y(1,i) = 1;
else
y(1,i) = 0;
end
if rx(2,i) > 0
y(2,i) = 0;
else
y(2,i) = 1;
end
if y(1,i) ~= x(1,i)
error_bits_QPSK(1,index) = error_bits_QPSK(1,index) +1;
end
if y(2,i) ~= x(2,i)
error_bits_QPSK(1,index) = error_bits_QPSK(1,index) +1;
end
6
Teacher assistants:
Chun-Kai Tseng
Guan-Yu Lu
Yi-Chu Yang
Offset-QPSK
Transmitter
1
8
Offset-QPSK
Receiver
3
2
9
Offset-QPSK
1
base_cos_part = [kron(info_sym(1:2:end),ones(1,T_num)), zeros(1,T_num/2)
base_sin_part
];
= [zeros(1,T_num/2), kron(info_sym(2:2:end),ones(1,T_num)) ];
10
Offset-QPSK
2
est_cos_part = conv(yt.*ct,ones(1,T_num));
est_sin_part = conv(yt.*st,ones(1,T_num));
est_info_bits = zeros(1,N(idx));
est_info_bits(1:2:end) = est_cos_part(T_num:T_num:end-T_num)>0;
est_info_bits(2:2:end) = est_sin_part(3*T_num/2:T_num:end-T_num/2) > 0;
Error(idx) = sum(dd_bits(1:end-1) ~= est_info_bits (1:end-1));
BER(idx)=Error(idx)/N(idx);
11
Offset-QPSK
3
12
BER
13
Teacher assistants:
Chun-Kai Tseng
Guan-Yu Lu
Yi-Chu Yang
15
Modulation
if (x(1,1) == 1)&&(x(2,1) == 0)
if (x(1,i) == 1)&&(x(2,i) == 0)
theta(1,1)=pi/4;
delta = -pi/4;
else if (x(1,1) == 0)&&(x(2,1) == 0)
else if (x(1,i) == 0)&&(x(2,i) == 0)
theta(1,1)=pi*3/4;
delta = pi/4;
else if (x(1,1) == 0)&&(x(2,1) == 1)
else if (x(1,i) == 0)&&(x(2,i) == 1)
theta(1,1)=pi*5/4;
delta = pi*3/4;
else
else
theta(1,1)=pi*7/4;
delta = -pi*3/4;
end
end
end
end
end
end
For the first symbol
For the other symbols
theta(1,i) = theta(1,i-1) + delta;
s(i,:) = sqrt(2*Eb_normal/Tb)*cos(2*pi*fc*int_interval)*cos(theta(1,i))
-sqrt(2*Eb_normal/Tb)*sin(2*pi*fc*int_interval)*sin(theta(1,i));
16
Demodulation
17
Demodulation
rx(1,i) = sum( s(i,:).*phi_1 )*Ts+randn(1)/(2);
rx(2,i) = sum( s(i,:).*phi_2 )*Ts+randn(1)/(2);
after_arctan(1,i) = atan(rx(2,i)/rx(1,i));
if rx(1,i)<0
after_arctan(1,i) = after_arctan(1,i) + pi;
end
ya(1,i) = mod( after_arctan(1,i) - after_arctan(1,i-1), 2*pi);
if ( ya(1,i)<pi/2 )
y(1,i)=0; y(2,i)=0;
else if ( ya(1,i)<pi )
y(1,i)=0; y(2,i)=1;
else if ( ya(1,i)<pi*3/2 )
y(1,i)=1; y(2,i)=1;
else
y(1,i)=1; y(2,i)=0;
end
end
end
18
BER
19