Chapter 19 : Wireless Network communication

Example 19.2 Page No : 605

In [9]:
b = [0, 23, 62, 8, 43, 16, 71, 47, 19, 61]
f9 = [0,0,0,0,0,0,0,0,0,0]
for i in range(10):
    f9[i] = b[i]+9+2
    if f9[i]>79:
        f9[i] = f9[i]-79

    print 'For i = %i ,(bi) = %i. Therefore.f9%i) = [%i+9]mod79)+2 = %i'%(i,b[i],i,b[i],f9[i])
For i = 0 ,(bi) = 0. Therefore.f90) = [0+9]mod79)+2 = 11
For i = 1 ,(bi) = 23. Therefore.f91) = [23+9]mod79)+2 = 34
For i = 2 ,(bi) = 62. Therefore.f92) = [62+9]mod79)+2 = 73
For i = 3 ,(bi) = 8. Therefore.f93) = [8+9]mod79)+2 = 19
For i = 4 ,(bi) = 43. Therefore.f94) = [43+9]mod79)+2 = 54
For i = 5 ,(bi) = 16. Therefore.f95) = [16+9]mod79)+2 = 27
For i = 6 ,(bi) = 71. Therefore.f96) = [71+9]mod79)+2 = 3
For i = 7 ,(bi) = 47. Therefore.f97) = [47+9]mod79)+2 = 58
For i = 8 ,(bi) = 19. Therefore.f98) = [19+9]mod79)+2 = 30
For i = 9 ,(bi) = 61. Therefore.f99) = [61+9]mod79)+2 = 72

Example 19.4 Page No : 607

In [10]:
# Variables
fd = .160;    #in MHz
Fc = 2411;

# Calculations and Results
print 'a)fd = %.2f MHz. a 0 is represented by %.2f MHz'%(fd,Fc-fd)
print 'b)A 1 is represented by %.2f MHz'%(Fc+fd)
a)fd = 0.16 MHz. a 0 is represented by 2410.84 MHz
b)A 1 is represented by 2411.16 MHz

Example 19.5 Page No : 607

In [11]:
# Variables
fd1 = .216;    #in MHz
fd2 = .072;    #in MHz
Fc = 2400+25 ;   #MHz

# Calculations and Results
print 'a)fd1 = %.2f MHz. a 00 is represented by %.3f MHz'%(fd1,Fc-fd1)
print 'b)A 01 is represented by %.3f MHz'%(Fc-fd2)
print 'c)A 10 is represented by %.3f MHz'%(Fc+fd1)
print 'b)A 11 is represented by %.3f MHz'%(Fc+fd2)    
#answer in part a is misprinted in the text
a)fd1 = 0.22 MHz. a 00 is represented by 2424.784 MHz
b)A 01 is represented by 2424.928 MHz
c)A 10 is represented by 2425.216 MHz
b)A 11 is represented by 2425.072 MHz

Example 19.6 Page No : 608

In [12]:
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace,sin
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math 

code = array([0, 1, 0, 1, 1, 0]);
t = arange(0,2.01,0.01)   #for x-axis
a = sin(2*math.pi*t)    #for y-axis
y = []
x = []
for i in range(len(code)):
    if code[i] == 1:
        a = -a;

    y = concatenate((y, a))
    x = concatenate((x, 2*math.pi*(t+2*(i-1))))

plot(x,y)
suptitle('DPSK used to encode 010110')
xlabel('Time')
ylabel('amplitude')
Out[12]:
<matplotlib.text.Text at 0x10a2824d0>

Example 19.7 Page No : 609

In [13]:
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace,sin
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math 

code = array([0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1]);
t = arange(0,2.01,.01)   #for x-axis
y = []
x = []
p = 0   #phase shift
for i in range(0,len(code),2):
    if code[i] == 0:
        if code[i+1] == 0:
            p = p+0
        else:
            p = p+math.pi/2
    else:
        if code[i+1] == 1:
            p = p+math.pi
        else:
            p = p+3*math.pi/2
    y = concatenate((y, sin(2*math.pi*t+p)));
    x = concatenate((x, 2*math.pi*(t+(i-1))));

plot(x,y);
suptitle('DQPSK used to encode 001110000001')
xlabel('Time')
ylabel('amplitude');