{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Experiment 5 - FM demod" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refs [1]: http://ultra.sdk.free.fr/docs/DxO/FM%20DEMODULATION%20USING%20A%20DIGITAL%20RADIO%20AND%20DIGITAL%20SIGNAL%20PROCESSING%20Digradio.pdf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The FM demodulation technique we use is called polar discrimination, from [1]" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import os, sys\n", "nb_dir = os.path.split(os.getcwd())[0]\n", "if nb_dir not in sys.path:\n", " sys.path.append(nb_dir)\n", " \n", "%matplotlib inline\n", "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "from directdemod import fmDemod" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Chunking test\n", "\n", "The following is a result if the array 'a' is undergone FM demodulation," ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[-1.57079633 1.57079633 -1.57079633 1.57079633 -1.57079633]\n" ] } ], "source": [ "a = np.array([1+1j, 2-2j, 3+3j, 4-4j, 5+5j, 6-6j])\n", "\n", "fm = fmDemod.fmDemod(storeState = False)\n", "print(fm.demod(a))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we do it in parts," ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[-1.57079633 1.57079633]\n", "[ 1.57079633 -1.57079633]\n" ] } ], "source": [ "a1 = np.array([1+1j, 2-2j, 3+3j])\n", "a2 = np.array([4-4j, 5+5j, 6-6j])\n", "fm = fmDemod.fmDemod(storeState = False)\n", "print(fm.demod(a1))\n", "print(fm.demod(a2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instead of 5 values, we got 4. We lost one value because of chunking. It can be solved by using flag 'storeState = True'" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[-1.57079633 1.57079633]\n", "[-1.57079633 1.57079633 -1.57079633]\n" ] } ], "source": [ "a1 = np.array([1+1j, 2-2j, 3+3j])\n", "a2 = np.array([4-4j, 5+5j, 6-6j])\n", "fm = fmDemod.fmDemod(storeState = True)\n", "print(fm.demod(a1))\n", "print(fm.demod(a2))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "Now we see that this indeed solves the chunking problem" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Observation\n", "\n", "FM demodulation introduces a one sample delay, this must be taken into consideration. The solution to chunking is provided by enabling the flag 'storeState = True' " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }