LoginSignup
10
10

More than 5 years have passed since last update.

pythonでAM変調、復調

Last updated at Posted at 2016-08-11

概要

pythonで、AM変調、復調やってみた。
復調は、IQ復調。

写真

py.jpeg

サンプルコード

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

sample_rate = 48000.
nsamples = 320
F_1KHz = 1000.
A_1KHz = 1.0
F_15KHz = 15000.
A_15KHz = 0.5
F_14KHz = 14800.
A_14KHz = 0.8
t = arange(nsamples) / sample_rate
vin = A_1KHz * sin(2 * pi * F_1KHz * t) 
vam = (A_1KHz * sin(2 * pi * F_1KHz * t) + 1.0) * A_15KHz * sin(2 * pi * F_15KHz * t)
i1 = vam * np.cos(2 * np.pi * F_14KHz * t)
q1 = vam * np.sin(2 * np.pi * F_14KHz * t)
nyq_rate = sample_rate / 2.
cutoff_hz = 6000.0
numtaps = 29
lpf = firwin(numtaps, cutoff_hz / nyq_rate)
i2 = sg.lfilter(lpf, 1, i1)
q2 = sg.lfilter(lpf, 1, q1)
o = np.sqrt(i2 * i2 + q2 * q2) 
fig = plt.figure(1)
ax = fig.add_subplot(311)
ax.plot(vin[1:300])
ax = fig.add_subplot(312)
ax.plot(vam[1:300])
ax = fig.add_subplot(313)
ax.plot(o[1:300])
fig.set_tight_layout(True)
plt.show()
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10