{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## PMOD ADC Reading Waveforms\n",
    "\n",
    "This demonstration shows how to use the PmodAD2. \n",
    "\n",
    "The PmodAD2, and an analog signal generator are required for this demonstration. \n",
    "\n",
    "In this demonstration, an analog waveform is generated using the Digilent Analog Discovery 2, and the Waveforms software.:\n",
    "\n",
    "1. [Digilent Analog Discovery 2](http://store.digilentinc.com/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply/)\n",
    "\n",
    "<tr>\n",
    "<td> <img src=http://cdn6.bigcommerce.com/s-7gavg/products/468/images/2617/Analog_Discovery_2_obl_Academic_600__01249.1447804398.1280.1280.png alt=\"Drawing\" style=\"width: 250px;\"/> </td>\n",
    "</tr>\n",
    "\n",
    "2. [WaveForms 2015](https://reference.digilentinc.com/waveforms3#newest):\n",
    "\n",
    "<tr>\n",
    "<td> <img src=http://cdn6.bigcommerce.com/s-7gavg/products/481/images/2623/TILE_WaveForms2015_150__84968.1447878611.1280.1280.png alt=\"Drawing\" style=\"width: 250px;\"/> </td>\n",
    "<td> <img src=http://cdn6.bigcommerce.com/s-7gavg/products/481/images/3961/img.07.0__38949.1458772469.1280.1280.png alt=\"Drawing\" style=\"width: 250px;\"/> </td>\n",
    "</tr>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the waveform to be displayed, we collect multiple points in each period. However, according to the Nyquist theorem, the sample rate only has to be $2\\times$ the frequency of the signal.\n",
    "\n",
    "The following block of code is just an example. For the PMOD ADC, the minimum delay between two samples is around $0.3\\,$ms (corresponding to a sampling period of $3\\,$kHz). So the maximum frequency of the input signal can be $1.5\\,$kHz."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Type in the PMOD ID of the ADC (1 or 2): 2\n",
      "Type in the frequency/Hz of the waveform: 200\n"
     ]
    },
    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P4gIs4AXgH8Xn5+\nVLpeIuJfgHUR8TPAmcBrJL2KitdL7h3AvU2PK1snw7oS/0Xg/ojYExE/Av4aeOOQXrtUIuIO4LGW\np98IfDS//1HgV4ZaqIJFxMMR8ZX8/n7gPuB0Kl4vABHxz/ndZ5C9Xx+j4vUi6XTg9cBHmp6ubJ0M\nK8THgQebHn8rf84yp0TEPsgCDTil4PIURtLzgbOA7cCpVa+XvNvgbuBhYC4i7sX18iHgnUDz1LrK\n1okHNsupkvM+JR0HfAJ4R35F3loPlauXiDiYd6ecDrxaUp0K14ukC4F9+V9ubedN5ypTJ8MK8b3A\n85oen54/Z5l9kk4FkPSTwCMFl2foJB1NFuDXRsQN+dOVr5dFEfEE8Gng56l2vbwKeIOkeeCvyMYJ\nrgUermqdDCvEvwT8lKS1ko4BfhO4cUivXUbi8KuIG4EN+f2LgRtaf6AC/gK4NyIub3qu0vUi6eTF\nWRaSngmcB9xNheslIv4wIp4XES8gy5FbI+KtwE1UtE6G9olNSRcAl5P94rg6Iv5kKC9cMpKuB+rA\nScA+YAr4FPBx4LnAHuA3IuLxoso4bPmMi9uBr5L9GRzAHwJ3AR+juvXyErJBOpG9b66NiM2STqTC\n9bJI0rnApoh4Q5XrxB+7NzNLmAc2zcwS5hA3M0uYQ9zMLGEOcTOzhDnEzcwS5hA3M0uYQ9zMLGEO\ncTOzhP1/z/8I2pW5+/IAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x3155ea70>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from time import sleep\n",
    "from pynq import Overlay\n",
    "from pynq.iop import Pmod_ADC\n",
    "\n",
    "ol = Overlay(\"base.bit\")\n",
    "ol.download()\n",
    "adc_id = int(input(\"Type in the PMOD ID of the ADC (1 or 2): \"))\n",
    "adc = Pmod_ADC(adc_id)\n",
    "freq = int(input(\"Type in the frequency/Hz of the waveform: \"))\n",
    "period = 1/freq\n",
    "log_interval_us = 0\n",
    "\n",
    "# Assume Channel 0 is connected to the waveform generator\n",
    "adc.start_log(1,0,0,log_interval_us)\n",
    "sleep(3*period)\n",
    "log = adc.get_log()\n",
    "\n",
    "# Draw the figure\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "plt.plot(range(len(log)), log, 'ro')\n",
    "plt.title('PMOD ADC Waveform')\n",
    "plt.axis([0, len(log), min(log), max(log)])\n",
    "plt.show()\n",
    "\n",
    "adc.reset()\n",
    "del adc,ol"
   ]
  }
 ],
 "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.4.3+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
