A Python Based GUI For AM Modulation

By Akhtar Nadaf

- Advertisement -
 
Comment errors or corrections found for this circuit, and get the chance to win big!

Project Introduction

Amplitude modulation (AM) is a signal modulation technique. It is widely used for transmitting message signals with radio waves. Many courses provided by universities in Electronics and telecommunication domain include Amplitude modulation.

In this project we propose a Python GUI based simulator to study AM. A user can vary various parameters such as modulation index, amplitude and frequency of modulating signal and carrier signal and observe output. This project can also be used as teaching aid for analog communication courses.

This GUI is developed in python3.10.1 by using Juypeter Note book.

Components Used

- Advertisement -

We need the following software components : Python 3.10.1, Tkinter, Matplotlib, Numpy.

Amplitude Modulation

Amplitude modulation is commonly used electronic communication technique. In this technique the carrier waveform is modulated according to instantaneous amplitude of message signal (Baseband Signal). Let us consider a sinusoidal wave as message signal. The amplitude of message signal is Am and frequency is fm. The mathematical, time domain representation of message signal is given by eq. 1.

The carrier signal is a high frequency radio wave with amplitude Ac and frequency fc. It is represented by

The equation of modulated waveform is given by

Modulation Index

The modulation index defines modulation level which can be defined as

Software installation and running the project

Step 1: Install Anaconda Distribution for Windows from Link. Anaconda is an open source Python distribution platform. It installs Jupyter NoteBook, Spyder, R studio and other integrated development environments for Python.

Step 2: Launch Jupyter NoteBook from Anaconda. It creates an interactive web based Python computing environment in any browser that is selected while installation.

Step 3: Create new notebook from file menu of Jupyter IDE by selecting Python 3 as ipykernal. Rename the new notebook as Analog Communication Simulator.

Step 4: Import libraries: This project uses functions from Tkinter , Matplotlib, numpy libraries. Hence we import numpy,matplotlib.pyplot libraries. We can use pip install and conda install to install libraries.

Step 5: This GUI Includes a window with canvas to plot graph and entry boxes to get user data for amplitude, frequency of message signal and carrier signals and for Modulation Index. It also includes three buttons to plot message signal career signal and modulated signal and for clearing canvas.

Step 6: Coding

A. Importing packages: We import various packages of python for smooth operation of various functions as follows.

from tkinter import *
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
from tkinter import ttk
import numpy as np

B. Displaying root window and managing other components in this window. We use Tk() function for displaying root window. The event loop of this window is created by mainloop() function. The title of root window can be provided here. Following coding snippet shows this procedure.

root = Tk()
root.title(‘Amplitude Modulation’)
fig1 = Figure(figsize=(2, 2), dpi=100)

C. Canvas designing: An interface between the Figure and Tkinter Canvas is provided by the FigureCanvasTkAgg class. Here we design canvas of width=1050, height=650 by positioning it at x=230, y=50.

canvas = FigureCanvasTkAgg(fig1, master=tab1)
canvas.draw_idle()
canvas.get_tk_widget().place(x=230, y=50, width=1050, height=650)

D. Widgets for plotting Message signal, career signal and modulated signal. For user defined values of amplitude and frequency of signal we use entry widget from tkinter package. These values are stored in variables for further calculation. All widgets are grouped by using frame function. Two button widgets are used for plotting of message signal and carrier signals. The commands for these buttons are defined by taking inputs from entry widget variables (Amplitude and Frequency) and using sin function from numpy package of python.

E. Plotting Modulated signal

The mathematical equation for modulated signal is defined in eq. 3. This is plotted by using numpy package. The user defined modulation index is used for calculating and plotting modulated signal.

F. Clearing canvas

Here we designed a button for clearing plotting in canvas. This can be achieved by .clear() function.

G. Results: The out waveforms can be checked for various values of modulation index:

Perfect modulation: When modulation index is maintained for value 1. We get perfect modulation

Fig.1 Perfect Modulation.

Under Modulation: When modulation index is below 1 it is called under modulation. Following fig 2. shows under modulation.

Fig. 2 Under Modulation
Fig. 2 Under Modulation

Over Modulation: When modulation index is above 1 we get over modulation. Following fig. 3 shows over modulation.

Fig. 4 Over Modulation
Fig. 4 Over Modulation

 

SHARE YOUR THOUGHTS & COMMENTS

 
 

What's New @ Electronicsforu.com

Most Popular DIYs

Electronics Components

Truly Innovative Tech