Â
In this we are going to see generation of Non-return to zero (NRZ) AMI Line Code using python.
from matplotlib import pyplot as mt
def ami(y):
userInput = y.copy()
n = []
for i in range(len(userInput)):
if userInput[i] == volt:
n.append(i)
for j in range(1, len(n)):
if j % 2 == 1:
userInput.pop(n[j])
userInput.insert(n[j], -volt)
return userInput
def plot(n, d, x, b):
mt.subplot(1, 1, n)
mt.step(d, x, where='post')
mt.grid(True, which='both')
mt.xlim(0, len(y)+1)
mt.ylim(-b-0.1, volt+1)
y = input('Enter Binary Code: ')
volt = int(input('Enter the Voltage Level: '))
print('Binary of ', 'is', y)
y = y + '0'
y = int(y)
y1 = volt * y
y = list(map(int, str(y1)))
y1 = y.copy()
t = list(range(0, len(y1)))
t1 = t.copy()
fig, ax = mt.subplots(1, 1)
fig.tight_layout()
fig = mt.gcf()
ax.remove()
userInput = ami(y1)
plot(1, t, userInput, volt)
mt.title('AMI')
mt.show()
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP