{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab 6, Digital Communication with Audio Frequency Shift Keying (AFSK)\n", "\n", "In this part of the lab we are going to experiment with Digital modulation and communication. Network Communication systems have layered architechture. The bottom layer is the physical which implements the modulation. Here we will use [AFSK](http://en.wikipedia.org/wiki/Frequency-shift_keying), which is a form of BFSK in the audio range (hence the 'A'). We will write a modulator/demodulator for AFSK. In the following part of lab we will leverage [AX.25](http://www.tapr.org/pub_ax25.html), which is an amateur-radio data-link layer protocol. [AX.25](http://www.tapr.org/pub_ax25.html) is a packet based protocol that will help us transmit data using packets. It implements basic synchronization, addressing, data encapsulation and some error detection. In the ham world, an implementation of AFSK and [AX.25](http://www.tapr.org/pub_ax25.html) together is also called a [TNC ( Terminal Node Controller )](http://en.wikipedia.org/wiki/Terminal_node_controller). In the past TNC's were separate boxes that hams used to attach to their radios to communicate with packet-based-communication. Today, it is easy to implement TNC's in software using the computer's soundcard.... as you will see here! \n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%pylab\n", "# Import functions and libraries\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pyaudio\n", "import Queue\n", "import threading,time\n", "import sys\n", "\n", "from numpy import pi\n", "from numpy import sin\n", "from numpy import zeros\n", "from numpy import r_\n", "from scipy import signal\n", "from scipy import integrate\n", "\n", "import threading,time\n", "import multiprocessing\n", "\n", "from rtlsdr import RtlSdr\n", "from numpy import mean\n", "from numpy import power\n", "from numpy.fft import fft\n", "from numpy.fft import fftshift\n", "from numpy.fft import ifft\n", "from numpy.fft import ifftshift\n", "import bitarray\n", "from scipy.io.wavfile import read as wavread\n", "import serial\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## AFSK1200, or Bell 202 modem\n", "\n", "AFSK1200 encodes digital binary data at a data-rate of 1200b/s. It uses the frequencies 1200Hz and 2200Hz ( center frequency of $1700$Hz $\\pm 500$ Hz) to encode the '0's and '1's (also known as space and mark) bits. Even though it has a relatively low bit-rate it is still the dominant standard for amature packet radio over VHF. It is a common physical layer for the AX.25 packet protocol and hence a physical layer for the Automatic Packet Reporting System (APRS), which we will describe later. \n", "\n", "The exact frequency spectrum of a general FSK signal is difficult to obtain. But, when the mark and space frequency difference $\\Delta f$ is much larger than the bit-rate, $B$, then the bandwidth of FSK is approximately $2\\Delta f + B$. This is not exactly the case for AFSK1200 where the spacing between the frequencies is 1000Hz and the bit-rate is 1200 baud.\n", "\n", "