Encoding Modulation
Encoding Modulation
import numpy as np
f=list(map(int,arr.split(' ')))
unipolar=[0]
if f[0]==1:
unipolar = [1]
else:
unipolar = [0]
for i in range(0,len(f)):
unipolar.append(f[i]) Example 2:
plt.subplot(321)
plt.title("Unipolar Encoding")
plt.xlabel("Time")
plt.ylabel("Bit")
plt.step(time,unipolar)
plt.tight_layout()
plt.xticks(time)
plt.yticks([0,1])
plt.xlim(0,len(f))
plt.grid(True)
plt.show()
Polar NRZ-L technique:
from copy import copy
plt.figure()
f = [0, 1, 0, 0, 1, 1]
plt.subplot(321)
k = f[int(i)]
if k == 0:
nrz_f.append(1)
Example 2:
else:
nrz_f.append(-1)
t = np.arange(0, len(nrz_f))
nrz_t = t
plt.title("NRZ-L Encoding")
plt.xlabel("Time")
plt.ylabel("Bit")
plt.step(nrz_t, nrz_f)
plt.xticks(nrz_t)
plt.axhline(y=0, color="r")
plt.xlim(0, len(nrz_f))
plt.tight_layout()
plt.show()
Polar NRZ-I Technique :
from copy import copy Example 1:
import numpy as np
f = [0,1,0,0,1]
bit= 1
nrz_i=[1]
for i in range(0,len(f)):
if f[i]==1:
Example 2:
if bit==1:
bit=-1
else:
bit=1
nrz_i.append(bit)
nrz_t=np.arange(0,len(nrz_i))
plt.subplot(311)
plt.grid(True)
plt.axhline(y=0,color="r")
plt.title("NRZ-I Encoding")
plt.xlabel("Time")
plt.ylabel("Bit level")
plt.step(nrz_t,nrz_i)
plt.xticks(nrz_t)
plt.xlim(0,len(nrz_i))
plt.show()
Polar RZ Technique: plt.grid(True)
import numpy as np
plt.figure()
f = [0,1,0,0,1,1]
t = np.arange(0, len(f))
plt.subplot(321)
plt.title("RZ encoding")
for i in range(0,len(f)):
k=f[int(i)]
Example 2:
if k == 0:
rz_bit.append(-1)
rz_bit.append(0)
else:
rz_bit.append(1)
rz_bit.append(0)
rz_time=np.arange(0,len(rz_bit))
plt.step(rz_time,rz_bit)
label=np.arange(0,len(rz_time))
plt.xticks(ticks=label,labels=label_name)
plt.ylabel("Bit level")
plt.xlabel("Time")
plt.xlim(0,len(rz_bit))
Polar Biphase-Manchester: Example 1:
import numpy as np
f = [0,1,0,0]
t = np.arange(0, len(f))
plt.subplot(321)
plt.title("Manchester encoding")
Example 2:
rz_bit=[1 if f[0]==0 else 0]
for i in range(0,len(f)):
k=f[int(i)]
if k == 0:
rz_bit.append(1)
rz_bit.append(-1)
else:
rz_bit.append(-1)
rz_bit.append(1)
rz_time=np.arange(0,len(rz_bit))
plt.step(rz_time,rz_bit)
label=np.arange(0,len(rz_time))
plt.xticks(ticks=label,labels=label_name)
plt.ylabel("Bit level")
plt.xlabel("Time")
plt.xlim(0,len(rz_bit))
plt.grid(True)
plt.show()
Differential Manchester Encoding: Example 1:
import numpy as np
data = [1]
for d in data_temp:
Example 2:
if (d == 1 and data[len(data) - 1] == 1) or (d == 0 and
data[len(data) - 1] == -1):
data.extend([1, -1])
else:
data.extend([-1, 1])
time = np.arange(0,len(data))
plt.step(time,data)
label=np.arange(0,len(data))
plt.subplot(321)
plt.xticks(ticks=label,labels=label_name)
plt.ylabel("Bit level")
plt.xlabel("Time")
plt.grid(True)
plt.show()
ASK Modulation:
import matplotlib.pyplot as plt Example 1:
import numpy as np
low_amp=1
high_amp=2
f=2
time=np.arange(0,1,0.01)
b1=2*np.sin(2*np.pi*f*time)
b0=1*np.sin(2*np.pi*f*time)
for x in or_data:
if x==1:
data.extend(b1)
else:
data.extend(b0)
time=np.arange(0,len(data))
plt.plot(time,data)
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.grid()
plt.show()
FSK Modulation:
import matplotlib.pyplot as plt Example 1:
import numpy as np
phase=0
f=2
time=np.arange(0,1,0.01)
b1=2*np.sin(2*np.pi*4*time)
b0=1*np.sin(2*np.pi*2*time)
data=[]
for x in or_data:
if x==1:
data.extend(b1)
else:
data.extend(b0)
time=np.arange(0,len(data))
plt.plot(time,data)
plt.grid()
plt.show()
PSK Modulation: Example 1:
import numpy as np
phase=0
f=2
p0=np.pi
time=np.arange(0,1,0.01)
b1=1*np.sin(2*np.pi*f*time) Example 2:
b0=1*np.sin(2*np.pi*f*time+p0)
print_data=copy(or_data)
data=[]
for x in or_data:
if x==1:
data.extend(b1)
else:
data.extend(b0)
time=np.arange(0,len(data))
plt.plot(time,data)
plt.grid()
plt.show()
AM Modulation: plt.tight_layout()
print('Amplitude Modulation')
time= np.arange(0,10,0.01)
fc=2
ac=2
plt.subplot(3,1,1)
carrier_signal=ac*np.sin(2*np.pi*fc*time)
plt.title('Carrier')
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.plot(carrier_signal)
Example 2:
message_amplitude=.2
message_frequency=.2
plt.subplot(3,1,2)
plt.title('Message Signal')
message_signal=message_amplitude*np.sin(2*np.pi*m
essage_frequency*time)
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.plot(message_signal)
plt.subplot(3,1,3)
modulated_s=carrier_signal*message_signal
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.plot(modulated_s)
FM Modulation: plt.xlabel('Time')
carrier_frequency = 40.0
product = np.zeros_like(modulator)
for i, t in enumerate(time):
plt.subplot(3, 1, 1)
plt.title('Modulator')
plt.plot(modulator)
plt.ylabel('Amplitude')
plt.xlabel('Time')
plt.subplot(3, 1, 2)
plt.title('Carrier')
plt.plot(carrier)
plt.ylabel('Amplitude')
plt.xlabel('Time')
plt.subplot(3, 1, 3)
plt.plot(product)
plt.ylabel('Amplitude')
PM Modulation : plt.show()
import numpy as np
carrier = 220.0
modulator = 440.0
beta = 1.0
carrierWave = np.cos
modulatorWave = np.cos
plt.subplot(3, 1, 1)
plt.title('Phase Modulation')
plt.ylabel('Carrier')
plt.subplot(3, 1, 2)
plt.ylabel('Modulator')
plt.subplot(3, 1, 3)
plt.xlabel('time (s)')
plt.ylabel('Modulated Carrier')
plt.tight_layout()