AM modulation and demodulation with python

Overview

I tried AM modulation and demodulation with python. Demodulation is IQ demodulation.

Photo

py.jpeg

Sample code

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()

Recommended Posts

AM modulation and demodulation with python
FM modulation and demodulation with Python
AM modulation and demodulation in Python Part 2
FM modulation and demodulation with Python Part 3
FM modulation and demodulation with Python Part 2
Programming with Python and Tkinter
Python and hardware-Using RS232C with Python-
python with pyenv and venv
Works with Python and R
Communicate with FX-5204PS with Python and PyUSB
Shining life with Python and OpenCV
Robot running with Arduino and python
Install Python 2.7.9 and Python 3.4.x with pip.
Neural network with OpenCV 3 and Python 3
[Python] font family and font with matplotlib
Scraping with Node, Ruby and Python
Scraping with Python, Selenium and Chromedriver
Scraping with Python and Beautiful Soup
JSON encoding and decoding with python
Hadoop introduction and MapReduce with Python
[GUI with Python] PyQt5-Drag and drop-
Reading and writing NetCDF with Python
I played with PyQt5 and Python3
Reading and writing CSV with Python
Multiple integrals with Python and Sympy
Coexistence of Python2 and 3 with CircleCI (1.0)
Easy modeling with Blender and Python
Sugoroku game and addition game with python
Communicate between Elixir and Python with gRPC
Data pipeline construction with Python and Luigi
Calculate and display standard weight with python
Monitor Mojo outages with Python and Skype
[Automation] Manipulate mouse and keyboard with Python
Passwordless authentication with RDS and IAM (Python)
Python installation and package management with pip
Using Python and MeCab with Azure Databricks
POST variously with Python and receive with Flask
Capturing images with Pupil, python and OpenCV
Fractal to make and play with Python
A memo with Python2.7 and Python3 on CentOS
Use PIL and Pillow with Cygwin Python
Create and decrypt Caesar cipher with python
CentOS 6.4 with Python 2.7.3 with Apache with mod_wsgi and Django
Reading and writing JSON files with Python
Dealing with "years and months" in Python
I installed and used Numba with Python3.5
Tweet analysis with Python, Mecab and CaboCha
Linking python and JavaScript with jupyter notebook
Traffic monitoring with Kibana, ElasticSearch and Python
Encrypt with Ruby (Rails) and decrypt with Python
Easily download mp3 / mp4 with python and youtube-dl!
Operate home appliances with Python and IRKit
Clean python environment with pythonz and virtualenv
Practice web scraping with Python and Selenium
Easy web scraping with Python and Ruby
Importing and exporting GeoTiff images with Python
I'm using tox and Python 3.3 with Travis-CI
Happy GUI construction with electron and python
Use Python and MeCab with Azure Functions
Touch AWS with Serverless Framework and Python
RaspberryPi L Chika with Python and C #