ECE 660 Assgnment 6 Solutons for Sprng 003 1. Wrte a matlab ode to do the modulaton and demodulaton for a bnary FSK usng a) oherent detetor and b) a nonoherent detetor. Modfy the programs that are posted to the web. Experment wth the strength of the nput sgnal by modfyng the parameter A. In eah ase, determne a smallest value where you start to see onsstent errors. For the homework, turn n your ode and the level of the threshold. Coherent: Errors our onsstently at about A = 0.03. Smulaton of a oherent detetor for FSK ommunatons. Input sgnal strength, A, and a bnary sequene of data. See how small you an make A before you start to note errors (e., make SNR small). Plot r versus t to see f you an determne the data sequene vsually. T = 1;delt = 0.01; t = 0:delt:T-delt; A = nput('input A: '); u = nput('input a bnary sequene of 5 haraters (enter as a vetor n brakets): '); f = 5; delf = 1/T; r = []; out = []; for = 1:5, modulaton alulatons n =.*randn(sze(t)); generates nose s1 = A*os(*p*f*t); s = A*os(*p*(f+delf)*t); f u() == 0,r = s1 +n; else r = s +n; demodulaton alulatons r1a = s1.*r; ra = s.*r; r1=0;r=0; for k = 1:length(t)-1, uses trapezodal rule for ntegraton r1 = r1+r1a(k)*delt/+r1a(k+1)*delt/; r = r+ra(k)*delt/+ra(k+1)*delt/; r = [r r]; f r1 >= r, out = [out 0]; else, out = [out 1]; out plots the sgnals on the last nterval that need to be ntegrated for the orrelaton alulaton t = 4*T:delt:5*T-delt; t = 0:delt:5*T-delt; fgure(1)
subplot(11),plot(t,r1a) ylabel('r1a') xlabel('tme') subplot(1),plot(t,ra) ylabel('ra') xlabel('tme') fgure() plot(t,r) ttle('reeved sgnal') xlabel('tme (se)') Nonoherent: Errors our onsstently at about A = 0.07 (a hgher level than that for the oherent detetor).. Smulaton of a square law detetor for FSK ommunatons. Input sgnal strength, A, and a bnary sequene of data. See how small you an make A before you start to note errors (e., make SNR small). Plot r versus t to see f you an determne the data sequene vsually. T = 1;delt = 0.01; t = 0:delt:T-delt; A = nput('input A: '); u = nput('input a bnary sequene of 5 haraters (enter as a vetor n brakets): '); f = 5; delf = 1/T; r = []; out = []; for = 1:5, modulaton alulatons n =.*randn(sze(t)); generates nose theta = rand(1)**p; random phase s1 = A*os(*p*f*t-theta); s = A*os(*p*(f+delf)*t-theta); f u() == 0,r = s1 +n; else r = s +n; demodulaton alulatons (from Fg 5-4-3) r1a = os(*p*t*f).*r; rs1a = sn(*p*t*f).*r; ra = os(*p*t*(f+delf)).*r; rsa = sn(*p*t*(f+delf)).*r; r1=0;r=0;rs1=0;rs=0; for k = 1:length(t)-1, uses trapezodal rule for ntegraton r1 = r1+r1a(k)*delt/+r1a(k+1)*delt/; rs1 = rs1+rs1a(k)*delt/+rs1a(k+1)*delt/; r = r+ra(k)*delt/+ra(k+1)*delt/; rs = rs+rsa(k)*delt/+rsa(k+1)*delt/; r = [r r]; square law deteton R1 = r1^+rs1^; R = r^+rs^; f R1 >= R, out = [out 0]; else,
out = [out 1]; out prnt to sreen plots the sgnals on the last nterval that need to be ntegrated for the orrelaton alulaton t = 4*T:delt:5*T-delt; t = 0:delt:5*T-delt; fgure(1) subplot(3),plot(t,rs1a) ylabel('r1sa') xlabel('tme') subplot(),plot(t,ra) ylabel('ra') xlabel('tme') subplot(1),plot(t,r1a) ylabel('r1a') xlabel('tme') subplot(4),plot(t,rsa) ylabel('rsa') xlabel('tme') fgure() plot(t,r) ttle('reeved sgnal') xlabel('tme (se)')
. Consder a (10,) blok ode as gven below. Compute all the ntermedate quanttes for ths ase f the frst ode word s sent (a, r,y, et.) as was done n lass. Assume that b = 0 110001101. Compute the CM for eah of the ases. What would the sgnal to nose rato need to be for a probablty of bt error to be less than 10-5 for ths ode? Use the Gaussan assumpton. 0001 0110 11 1001 0001 01 0111 1010 11 1110 1101 00 You may use Matlab to help ompute a value. I wrote a program for the Q funton as follows: plottng Q(sqrt(a*gamma))versus 10log_10(gamma) q = Q(gamma,a); Q(x) = 1//p * nt from x to nf of exp(-t^/) dt funton q = Q(gamma,a); q =.5*erf(sqrt(gamma*a/)); gammadb = 10*log10(gamma); semlogy(gammadb,q) grd Soluton: use the relatonshps: r (t)=g(t) f a = 0 and g(t) f a = 1 E + v f a = 0 r g = E + v f a = 1 y = (b 1)(r g) = ( 1)E + (b 1) v b a r r g y 0 0 0 g(t)+z(t) E -v 1 -E -v 1 0 1 1 -g(t)+z(t) -E -v -E +v 0 1 1 -g(t)+z(t) -E -v 3 -E +v 3 1 0 1 -g(t)+z(t) -E -v 4 E -v 4 0 0 0 g(t)+z(t) E -v 5 -E -v 5 1 0 1 -g(t)+z(t) -E -v 6 E -v 6 1 1 0 g(t)+z(t) E -v 7 E +v 7 0 1 1 -g(t)+z(t) -E -v 8 -E +v 8 1 0 1 -g(t)+z(t) -E -v 9 E -v 9 1 1 0 g(t)+z(t) E -v 10 E +v 10 n k = (j 1)y j, 1,..., j= 1 CM = ( s the number of the ode word, where j represents the j th bt) CM 1 =0E +v 1 v v 3 v 4 +v 5 - v 6 +v 7 - v 8 -v 9 +v 10 CM = E (-1+1+1+1+1-1-1-1-1-1+1) -v 1 v v 3 v 4 +v 5 + v 6 -v 7 + v 8 +v 9 +v 10 = -v 1 v v 3 v 4 +v 5 + v 6 -v 7 + v 8 +v 9 +v 10 CM 3 = E (+1-1-1+1-1-1+1+1+1+1) +v 1 +v +v 3 v 4 -v 5 + v 6 +v 7 -v 8 -v 9 +v 10 = 4E +v 1 +v +v 3 v 4 -v 5 + v 6 +v 7 -v 8 -v 9 +v 10
CM 4 = E (-1-1-1-1-1+1-1-1-1-1) -v 1 +v +v 3 +v 4 -v 5 - v 6 -v 7 +v 8 +v 9 -v 10 = -16E -v 1 +v +v 3 +v 4 -v 5 - v 6 -v 7 +v 8 +v 9 -v 10 let D m = CM 1 -CM 4E w m P(Dm < 0) = Q, where w m represents the number of bts that dffer between the frst ode E(v ) word and the m th ode word 4 Unon bound for P Q ( R γw ) where R = 1/5. So, P M Q M m= ( γ ) + Q( 8γ / 5) + Q( 18γ / 5) The rght-hand sde an be plotted versus γ m 4 x 10-5 3.5 3.5 1.5 1 0.5 0 10 11 1 13 14 15 16 17 18 19 0 To guarantee P M less than 10-5, then γ 11.5
3. Wrte a matlab ode that uses DSSS to smulate the modulaton and demodulaton of the system desrbed n Problem. You an use a random number generator to generate b, just make sure that you pass the generated sequene to the reever. Turn n your ode n the homework. DS spread spetrum transmsson smulaton lnear blok ode of (10,) s used ode = [0 0 0 1 0 1 1 0 1 1 ; 1 0 0 1 0 0 0 1 0 1; 0 1 1 1 1 0 1 0 1 1; 1 1 1 0 1 1 0 1 0 0]; t = 0.0001; f = 50000; delt = t()-t(1); nput numbers from 0 to 3, ths s equvalent to bts values x = nput('nput sequene of 4 numbers from 0 to 3 as a vetor: ') J = nput('nput level of nterferene'); = []; rtest =[]; for = 1:4, f x() == 0, = [ ode(1,:)]; elsef x() == 1, = [ ode(,:)]; elsef x() ==, = [ ode(3,:)]; else = [ ode(4,:)]; b = rand(1,40)-0.5; b = 0.5*sgn(b); onverts to bnary -.5 and.5 depng on sgn b = b+.5; a = xor(b,); gves exat value for, but ths s not used later reate pulse t = 0.0001; t = 0:t/50:t*49/50; t = 0:t/50:40*t-t/50; tp = nput('selet type of pulse: 1 for square, for half-sne'); f tp == 1, g = ones(1,length(t)); else g = sn(t/t*p); sl = []; y = []; r = []; for = 1:40, s = (*b()-1)*(*()-1)*g; r = (s + J*randn(1,length(s))).*os(f**p*t); for broadband nterferene r = [r r]; rl = r.*g.*os(f**p*t); ra = 0; for k = 1:length(t)-1, uses trapezodal rule for ntegraton ra = ra+rl(k)*delt/+rl(k+1)*delt/; rtest = [rtest ra]; y = ra*(*b()-1); y = [y y]; CM = zeros(1,4); out = []; for = 1:4, for m = 1:4, CM(m) = (*ode(m,:)-1)*y((-1)*10+1:(*10))'; [X,I] = max(cm); I s the ndex f I == 1,out = [out 0];, elsef I ==, out = [out 1];
elsef I == 3, out = [out ]; else out = [out,3]; out plot(t,r) ttle('reeved sgnal wth nterferane') xlabel('tme (se)') ylabel('r(t)') Problem 13.1 n the text (usng method from lass) g(t) = 16E 3T os π T t T E (v ) = G G(0) = P M (0)J AV T T 16E g(t)dt = 0 3T M m= Q 4E w m E(v ) M 3E br w m So: P M Q( ) J T m= av