Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Modify the code Code_02_03.py. What if, instead of using ? = 716? rad, we use ? = 12? rad for the phase shift? Try different values for ?.

import numpy as np
# import scipy.signal as signal
import matplotlib.pyplot as plt

if __name__ == '__main__':
# Test bench area
print("Hello")

T = 0.00005 # Sampling period (sec)
fs = 1 / T # Sampling frequency (20KHz)
N = 1000 # Number of samples
t = np.arange(0.0, N * T, T) # N samples for total interval
f = np.arange(0.0, (N / 2) * (fs / N) / 1000, (fs / N) / 1000) # N / 2 samples for Nyquist interval (KHz)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Transmission:
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Signal 1 with 100, 200 and 300 Hz components:
g1 = np.cos(2 * np.pi * 100 * t) + 0.1 * np.sin(2 * np.pi * 200 * t) + 0.4 * np.cos(2 * np.pi * 300 * t) # %Sign1
# Signal 2 with 100, 200 and 300 Hz components:
g2 = 0.4 * np.sin(2 * np.pi * 100 * t) + 0.1 * np.cos(2 * np.pi * 200 * t) + np.sin(2 * np.pi * 300 * t) # %Sign2
# Quadrature modulation with 1KHz carriers:
s = g1 * np.cos(2 * np.pi * 1000 * t) - g2 * np.sin(2 * np.pi * 1000 * t) # QAM signal
S = np.fft.fft(s)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Reception:
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 1KHz local oscillator:
teta = np.pi * 1 / 8 # Angle of phase with respect to the carrier
lo_i = np.cos(2 * np.pi * 1000 * t + teta) # Local oscillator in phase
lo_q = -np.sin(2 * np.pi * 1000 * t + teta) # Quadrature local oscillator
# Unfiltered demodulated channels:
y1 = s * lo_i
y2 = s * lo_q

# LP filter with cutoff at 1000 Hz (baseband):
# b_lp with 32 Coefficients for the FIR filter:
b_lp = signal.firwin(32, 0.1) # Taps, Cutoff = 2*1KHz/20KHz

# Filtered demodulated channels:
z1 = signal.lfilter(b_lp, 1, y1)
Z1 = np.fft.fft(z1)
z2 = signal.lfilter(b_lp, 1, y2)
Z2 = np.fft.fft(z2)

# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Graphics:
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fig1, axarr = plt.subplots(2, 1)
axarr[0].plot(t, s)
axarr[0].set_title('QAM signal s (t)')
axarr[0].set_xlabel('Time[s]')
axarr[1].stem(f[0:100], abs(S[0:100]))
axarr[1].set_title('|S(f)|')
axarr[1].set_xlabel('Frecuency[KHz]')
fig1.subplots_adjust(hspace=0.5)

fig2, axarr = plt.subplots(2, 1)
axarr[0].plot(t, z1)
axarr[0].set_title('Demodulated signala z1(t)')
axarr[0].set_xlabel('Time[s]')
axarr[1].stem(f[0:100], abs(Z1[0:100]))
axarr[1].set_title('|Z1(f)|')
axarr[1].set_xlabel('Frequency[KHz]')
fig2.subplots_adjust(hspace=0.5)

fig3, axarr = plt.subplots(2, 1)
axarr[0].plot(t, z2)
axarr[0].set_title('Demodulated signal z2 (t)')
axarr[0].set_xlabel('Time[s]')
axarr[1].stem(f[0:100], abs(Z2[0:100]))
axarr[1].set_title('|Z2(f)|')
axarr[1].set_xlabel('Frequency[KHz]')
fig3.subplots_adjust(hspace=0.5)

plot.show()

Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY