{
 "metadata": {
  "name": "",
  "signature": "sha256:931ccf820f91dc3bd263fe2430c73233b66e02ab90eedbd3236bc42b5727ead5"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3, Waveform generators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 1 - page : 145"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "R2 = 100.0  # ohm\n",
      "R1 = 50.0*10**3  # ohm\n",
      "Vref = 0  # V\n",
      "vi = 1  # V\n",
      "Vsat = 14.0   # V\n",
      "# Solution \n",
      "\n",
      "VUT = (R2*Vsat)/(R1+R2)  # V\n",
      "VLT = (R2*-Vsat)/(R1+R2) # V\n",
      "\n",
      "# Displaying the values\n",
      "\n",
      "print \"The value of Upper threshold voltage =  \",int(round(VUT*10**3,0)),\"mV\"\n",
      "print \"The value of Lower threshold voltage = \",int(round(VLT*10**3,0)),\"mV\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Upper threshold voltage =   28 mV\n",
        "The value of Lower threshold voltage =  -28 mV\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 2 - page : 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np \n",
      "# Given data\n",
      "\n",
      "VUT = 0\n",
      "VH = 0.3\n",
      "f = 10.0**3\n",
      "# Solution \n",
      "\n",
      "VLT = VUT - VH\n",
      "theta = round(np.arcsin(VH/2),1)\n",
      "T = 1/f\n",
      "Ttheta = theta/(2*np.pi*f) \n",
      "T1 = (T/2) + Ttheta\n",
      "T2 = (T/2) - Ttheta \n",
      "\n",
      "# Displayig the values \n",
      "\n",
      "print \"The value of Lower threshold voltage = \",VLT,\"V\"\n",
      "print \"The value of angle theta             = \",theta,\"Radian\"\n",
      "print \"The value of T1                      = \",round(T1*10**3,3),\"ms\"\n",
      "print \"The value of T2                      = \",round(T2*10**3,3),\"ms\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Lower threshold voltage =  -0.3 V\n",
        "The value of angle theta             =  0.2 Radian\n",
        "The value of T1                      =  0.532 ms\n",
        "The value of T2                      =  0.468 ms\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 3 - page : 152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Given data \n",
      "\n",
      "f = 100\n",
      "C = 0.1*10**-6\n",
      "\n",
      "# Solution \n",
      "\n",
      "R = 1/(math.sqrt(6)*2*math.pi*(10**-7)*100)\n",
      "R1 = 10*R\n",
      "Rf = 29*R1\n",
      "\n",
      "# Displaying the solutions \n",
      "\n",
      "print \"The value of R1 =\",int(round(R1*10**-3,0)),\"Kilo Ohms\"\n",
      "print \"The value of Rf =\",int(round(Rf*10**-3,0)),\"Kilo Ohms\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 = 65 Kilo Ohms\n",
        "The value of Rf = 1884 Kilo Ohms\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 4 - page 158"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Given data \n",
      "\n",
      "f = 50\n",
      "C = 0.2*10**-6\n",
      "\n",
      "# Solution \n",
      "\n",
      "R = 1/(math.sqrt(6)*2*math.pi*(10**-7)*100)\n",
      "R1 = 10*R\n",
      "Rf = 29*R1\n",
      "\n",
      "# Displaying the solutions \n",
      "\n",
      "print \"The value of R1 is %0.2f kohms\"%(R1*10**-3)\n",
      "print \"The value of Rf is %0.2f kohms\"%(Rf*10**-3)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R1 is 64.97 kohms\n",
        "The value of Rf is 1884.27 kohms\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 5 - page 162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import pi, arcsin \n",
      "# Given data\n",
      "\n",
      "VUT = 0\n",
      "VH = 0.5\n",
      "f = 1000\n",
      "# Solution \n",
      "\n",
      "VLT = VUT - VH\n",
      "theta = round(arcsin(VH/2),1)\n",
      "T = 1/f\n",
      "Ttheta = theta/(2*pi*f) \n",
      "T1 = (T/2) + Ttheta\n",
      "T2 = (T/2) - Ttheta \n",
      "\n",
      "# Displayig the values \n",
      "\n",
      "print \"The value of Lower threshold voltage = \",VLT,\"V\"\n",
      "print \"The value of angle theta             = \",theta,\"Radian\"\n",
      "print \"The value of T1                      = \",round(T1*10**3,3),\"ms\"\n",
      "print \"The value of T2                      = \",round(T2*10**3,3),\"ms\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Lower threshold voltage =  -0.5 V\n",
        "The value of angle theta             =  0.3 Radian\n",
        "The value of T1                      =  0.048 ms\n",
        "The value of T2                      =  -0.048 ms\n"
       ]
      }
     ],
     "prompt_number": 29
    }
   ],
   "metadata": {}
  }
 ]
}