diff --git a/README.md b/README.md index 6c55153..2f17055 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,69 @@ Write a simple Python program for the modulation and demodulation of PCM, and DM # Tools required # Program ``` -Attach the program +import numpy as np +import matplotlib.pyplot as plt + +# ---------------- PARAMETERS ---------------- +fs = 1000 # sampling frequency +Tb = 1 # bit duration +fc = 5 # carrier frequency +data = [1,0,1,1,0,1] + +t = np.arange(0, Tb, 1/fs) + +# ---------------- MESSAGE ---------------- +message = np.repeat(data, len(t)) +time = np.arange(len(message)) / fs + +# ---------------- CARRIER ---------------- +carrier = np.sin(2*np.pi*fc*time) + +# ---------------- PSK MODULATION ---------------- +# 1 -> +1 , 0 -> -1 +polar_data = 2*message - 1 +psk = polar_data * carrier + +# ---------------- DEMODULATION ---------------- +demod = psk * carrier +reconstructed = (demod > 0).astype(int) + +# ---------------- PLOTS ---------------- +plt.figure(figsize=(12,8)) + +plt.subplot(4,1,1) +plt.plot(time, message) +plt.title("Message Signal") +plt.ylim(-0.5,1.5) +plt.grid() + +plt.subplot(4,1,2) +plt.plot(time, carrier) +plt.title("Carrier Signal") +plt.grid() + +plt.subplot(4,1,3) +plt.plot(time, psk) +plt.title("PSK Modulated Signal") +plt.grid() + +plt.subplot(4,1,4) +plt.plot(time, reconstructed) +plt.title("Demodulated Signal") +plt.ylim(-0.5,1.5) +plt.grid() + +plt.tight_layout() +plt.show() + + ``` # Output Waveform ``` -Attach the output waveform +download (2) + ``` # Results ``` -Attach the output waveform +Thus the modulation and demodulation of PCM, and DM is Verified ``` -# Hardware experiment output waveform.