37 lines
679 B
Python
37 lines
679 B
Python
import numpy as np
|
|
import scipy as sp
|
|
import matplotlib.pyplot as plt
|
|
|
|
f_c = 100E+6
|
|
f_m = 1E3
|
|
T_c = 1/f_c
|
|
|
|
f_s = 1E9
|
|
T_s = 1/f_s
|
|
|
|
A_c = 500
|
|
D_p = 100
|
|
D_f = 1E+6
|
|
|
|
omega_m = 2*np.pi*f_m
|
|
omega_c = 2*np.pi*f_c
|
|
|
|
# Time samples to 10 seconds at a samplig frequency of 8kHz
|
|
t = np.arange(0,10*T_c,T_s)
|
|
m_p = 0.2*np.cos(omega_m * t)
|
|
|
|
m_f = -2E-5*omega_m*np.sin(omega_m * t)
|
|
M_f = 2E-5*np.cos(omega_m*t)
|
|
theta = D_f * M_f
|
|
|
|
# The phase modulated signal
|
|
s_p = A_c*np.cos(omega_c*t + D_p*m_p)
|
|
s_f = A_c*np.cos(omega_c*t + theta)
|
|
|
|
c = A_c*np.cos(omega_c *t)
|
|
|
|
plt.plot(t, s_p, label="Phase Modulated Signal")
|
|
plt.plot(t, s_p-c)
|
|
#plt.plot(t, s_f, label="Frequency Modulated Signal")
|
|
plt.show()
|