Tuesday, November 26, 2019

dpsk

from __future__ import division
from numpy import ones,arange,cos,sin,pi
import numpy as np
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show,legend,grid,subplot
Fs =150.0;  # sampling rate
Ts = 1.0/Fs; # sampling interval
freq=10
t = np.arange(0,2,Ts)
bk = [1,0,0,1,0,0,1,1]##input digital sequence
bk_not=[]
for i in range(0,len(bk)):
  if(bk[i]==1):
   bk_not.append(0)
  else:
    bk_not.append(1)
dk_1 = [ 1 and bk[0]]#  #initial value of differential encoded sequence
dk_1_not =[ 0 and bk_not[0]]
dk = [dk_1[0]^dk_1_not[0]] #first bit of dpsk encoder
for i in range(1,len(bk)):
  dk_1.append(dk[(i-1)])
  if dk[(i-1)]==1:
     x=0
  else:
    x=1
  dk_1_not.append(x)
  dk.append(((dk_1[i] and bk[i])^(dk_1_not[i] and bk_not[i])))
dk_radians=[]
for i in range(0,len(dk)):
  if(dk[i]==1):
    dk_radians.append(0)
  elif(dk[i]==0):
    dk_radians.append(180)
print ('Table 7.3 Illustrating the Generation of DPSK Signal')
print ('_____________________________________________________')
print ('\n(bk)',bk)
print ('\n(bk_not)',bk_not)
print ('\nDifferentially encoded sequence (dk)')
for dd in dk:
    print (dd,'\t')
print ('\n\nTransmitted phase in radians')
for ddd in dk_radians:
    print (ddd,'\t')
print ('\n\n_____________________________________________________')
bit_arr =np.array([0,180,0,0,180])
samples_per_bit = 2*Fs/bit_arr.size
dd = np.repeat(bit_arr, samples_per_bit)
y= np.sin(2 * np.pi * (freq) * t+(np.pi*dd/180))
plot(t,y)
show()

No comments:

Post a Comment

qpsk

from numpy import ones,arange,cos,sin,pi from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show M =4# i = range(0,M) t = a...