{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter : 13 - Integrated Circuit Timer"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.1 : Page No - 496\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C *10**-6 # in F\n",
      "R_A = 2 # in  k ohm\n",
      "R_A = R_A * 10**3 # in ohm\n",
      "R_B = 100 # in k ohm\n",
      "R_B = R_B * 10**3 # in ohm\n",
      "T_HIGH = 0.693*(R_A+R_B)*C # in s\n",
      "T_HIGH = T_HIGH # in sec\n",
      "T_LOW = 0.693*R_B*C # in s\n",
      "T_LOW = T_LOW  # in sec\n",
      "T = T_HIGH + T_LOW # in sec\n",
      "f = 1/T # in Hz\n",
      "print \"The value of frequency = %0.1f Hz\" %f \n",
      "D = (T_HIGH/T)*100 # in %\n",
      "print \"Duty cycle = %0.1f %%\" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of frequency = 714.4 Hz\n",
        "Duty cycle = 50.5 %\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.2 : Page No - 497\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R_A = 4.7 # in k ohm\n",
      "R_A = R_A * 10**3 # in ohm\n",
      "R_B = 1 # in k ohm\n",
      "R_B = R_B * 10**3 # in ohm\n",
      "T_on = 0.693*(R_A+R_B)*C # in s\n",
      "T_on = T_on # in sec\n",
      "print \"Positive pulse width = %0.2f ms\" %(T_on * 10**3) \n",
      "T_off = 0.693*R_B*C # in s\n",
      "T_off = T_off # in ms\n",
      "print \"Negative pulse width = %0.3f ms\" %(T_off * 10**3) \n",
      "f = 1.4/((R_A+2*R_B)*C) # in Hz\n",
      "print \"Free running frequency = %0.2f Hz\" %f \n",
      "D = ((R_A+R_B)/(R_A+(2*R_B)))*100 # in %\n",
      "print \"The duty cycle = %0.f %%\" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Positive pulse width = 3.95 ms\n",
        "Negative pulse width = 0.693 ms\n",
        "Free running frequency = 208.96 Hz\n",
        "The duty cycle = 85 %\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.3 : Page No - 497\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f = 1 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "R_A = 1.44/(2*f*C) # in ohm\n",
      "R_A = R_A * 10**-3 # in k ohm\n",
      "R_B= R_A # in kohm\n",
      "print \"The value of both the resistors required = %0.f k\u03a9 (standard value 68 kohm)\" %R_A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of both the resistors required = 72 k\u03a9 (standard value 68 kohm)\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.4 : Page No - 497\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 700 # in Hz\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "a = 1.44 \n",
      "R_A = a/(2*f*C) # in ohm\n",
      "R_A = R_A * 10**-3 # in k ohm\n",
      "R_B =R_A # in k ohm\n",
      "print \"The the value of C = %0.2f \u00b5F\" %(C*10**6)\n",
      "print \"The value of both the resistors = %0.f k\u03a9\" %R_A \n",
      "print \"(Standard value of resistor is 100 k\u03a9)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The the value of C = 0.01 \u00b5F\n",
        "The value of both the resistors = 103 k\u03a9\n",
        "(Standard value of resistor is 100 k\u03a9)\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.5 : Page No - 498\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C *10**-6 # in F\n",
      "R_A = 2 # in  k ohm\n",
      "R_A = R_A * 10**3 # in ohm\n",
      "R_B = 100 # in k ohm\n",
      "R_B = R_B * 10**3 # in ohm\n",
      "T_HIGH = 0.693*(R_A+R_B)*C # in s\n",
      "T_HIGH = T_HIGH # in sec\n",
      "T_LOW = 0.693*R_B*C # in s\n",
      "T_LOW = T_LOW  # in sec\n",
      "T = T_HIGH + T_LOW # in sec\n",
      "f = 1/T # in Hz\n",
      "print \"The value fo frequency = %0.1f Hz\" %f \n",
      "D = (T_HIGH/T)*100 # in %\n",
      "print \"Duty cycle = %0.1f %%\" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value fo frequency = 714.4 Hz\n",
        "Duty cycle = 50.5 %\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.6 : Page No - 498\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R_A = 4.7 # in k ohm\n",
      "R_A = R_A * 10**3 # in ohm\n",
      "R_B = 1 # in k ohm\n",
      "R_B = R_B * 10**3 # in ohm\n",
      "T_on = 0.693*(R_A+R_B)*C # in s\n",
      "T_on = T_on # in sec\n",
      "print \"Positive pulse width = %0.2f ms\" %(T_on * 10**3) \n",
      "T_off = 0.693*R_B*C # in s\n",
      "T_off = T_off # in ms\n",
      "print \"Negative pulse width = %0.3f ms\" %(T_off * 10**3) \n",
      "f = 1.4/((R_A+2*R_B)*C) # in Hz\n",
      "print \"Free running frequency = %0.2f Hz\" %(f) \n",
      "D = ((R_A+R_B)/(R_A+(2*R_B)))*100 # in %\n",
      "print \"The duty cycle = %0.f %%\" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Positive pulse width = 3.95 ms\n",
        "Negative pulse width = 0.693 ms\n",
        "Free running frequency = 208.96 Hz\n",
        "The duty cycle = 85 %\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.7 : Page No - 498\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f = 1 # in kHz\n",
      "f = f* 10**3 # in Hz\n",
      "a = 1.44 \n",
      "R_A = a/(2*f*C) # in ohm\n",
      "R_A = R_A * 10**-3 # in k ohm\n",
      "R_B = R_A # in k ohm\n",
      "print \"The value of both the resistors required = %0.f k\u03a9 (standard value 68 kohm)\" %R_A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of both the resistors required = 72 k\u03a9 (standard value 68 kohm)\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.8 : Page No - 499\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 700 # in Hz\n",
      "C = 0.01 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "a = 1.44 \n",
      "R_A = a/(2*f*C) # in ohm\n",
      "R_A = R_A * 10**-3 # in k ohm\n",
      "R_B =R_A # in k ohm\n",
      "print \"The the value of C = %0.2f \u00b5F\" %(C*10**6)\n",
      "print \"The value of both the resistors = %0.f k\u03a9\" %R_A \n",
      "print \"(Standard value of resistor is 100 k\u03a9)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The the value of C = 0.01 \u00b5F\n",
        "The value of both the resistors = 103 k\u03a9\n",
        "(Standard value of resistor is 100 k\u03a9)\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.9 : Page No - 499\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 800 # in Hz\n",
      "C = 0.01 # in \u00b5F\n",
      "C =C * 10**-6 # in F\n",
      "R_A = 1.44/(5*f*C) # in ohm\n",
      "R_A = R_A * 10**-3 # in k ohm\n",
      "print \"The value of R_A = %0.f k\u03a9\" %R_A \n",
      "R_B = 2*R_A # in k ohm\n",
      "print \"The value of R_B = %0.f k\u03a9\" %R_B "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_A = 36 k\u03a9\n",
        "The value of R_B = 72 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.10 : Page No - 501\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 10 # in \u00b5F\n",
      "C = C*10**-6 # in F\n",
      "T_ON = 5 # in sec\n",
      "R = T_ON/(1.1*C) # in ohm\n",
      "print \"The resistor value = %0.1f ohm\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistor value = 454545.5 ohm\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.11 : Page No - 501\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 10 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "T_off = 1 # in sec\n",
      "#Formula T_off= 0.693*R2*C\n",
      "R2 = T_off/(0.693*C) # in ohm\n",
      "print \"The value of R2 = %0.f \u03a9\" %R2 \n",
      "T_on = 3 # in sec\n",
      "# Formula T_on= 0.693*(R1+R2)*C\n",
      "R1 =T_on/(C*0.693)-R2 # in ohm\n",
      "print \"The value of R1 = %0.f \u03a9\" %R1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R2 = 144300 \u03a9\n",
        "The value of R1 = 288600 \u03a9\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.12 : Page No - 502\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "#Given data\n",
      "C = 0.22 # in \u00b5F\n",
      "C=C*10**-6 # in F\n",
      "T_on = 10 # in ms\n",
      "T_on = T_on * 10**-3 # in s\n",
      "V_CC = 15 # in V\n",
      "V_BE = 0.7 # in V\n",
      "V_EC = 0.2 # in V\n",
      "V_LED= 1.4 # in V\n",
      "I_LED= 20*10**-3 # in A\n",
      "R = T_on/(C*1.1) # in ohm\n",
      "R = R *10**-3 # in k ohm\n",
      "print \"Values for first circuit : \"\n",
      "print \"The value of R = %0.1f k\u03a9\" %R \n",
      "V_o = V_CC-(2*V_BE) - V_EC # in V\n",
      "print \"The output voltage = %0.1f V\" %V_o \n",
      "R_LED = (V_o - V_LED)/(I_LED) # in ohm \n",
      "print \"The value of R_LED = %0.f \u03a9\" %R_LED\n",
      "# Part (ii)\n",
      "f= 1*10**3 # in Hz\n",
      "C=0.01*10**-6 # in F\n",
      "D= 95/100 # duty cycle\n",
      "# Formula f= 1.44/((R1+2*R2)*C)\n",
      "# R1+2*R2= 1.44/(f*C)                  (i)\n",
      "# D= (R1+R2)/(R1+2*R2) or\n",
      "# R2= (1-D)/(2*D-1)*R1           (ii)\n",
      "# From eq (i) and (ii)\n",
      "R1= 1.44/(f*C*(1+2*((1-D)/(2*D-1)))) # in ohm\n",
      "R2=  (1-D)/(2*D-1)*R1 # in ohm\n",
      "print \"\\nValues for second circuit : \"\n",
      "print \"The value of R1 = %0.1f k\u03a9\" %(R1*10**-3) \n",
      "print \"The value of R2 = %0.2f k\u03a9\" %(R2*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Values for first circuit : \n",
        "The value of R = 41.3 k\u03a9\n",
        "The output voltage = 13.4 V\n",
        "The value of R_LED = 600 \u03a9\n",
        "\n",
        "Values for second circuit : \n",
        "The value of R1 = 129.6 k\u03a9\n",
        "The value of R2 = 7.20 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.13 : Page No - 503\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "T = 5 # in msec\n",
      "T = T * 10**-3 # in sec\n",
      "C = 0.1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R = T/(C*1.1) # in ohm\n",
      "R = R * 10**-3 # in k ohm\n",
      "print \"The resistor = %0.2f k\u03a9\" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistor = 45.45 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.14 : Page No - 503\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 1 # in kHz\n",
      "f = f * 10**3 # in Hz\n",
      "T = 1/f # in s\n",
      "T = T * 10**3 # in msec\n",
      "T_d = T/2 # in msec\n",
      "T_d = T_d * 10**-3 # in sec\n",
      "C = 0.1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "R2 = T_d/(0.69*C) # in ohm\n",
      "R2 = R2 * 10**-3 # in k ohm\n",
      "print \"The value of C = %0.1f \u00b5F\" %(C*10**6)\n",
      "print \"The value of R2 = %0.2f k\u03a9\" %R2 \n",
      "print \"The value of R1 will be 100 \u03a9 +10 k\u03a9 pot\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C = 0.1 \u00b5F\n",
        "The value of R2 = 7.25 k\u03a9\n",
        "The value of R1 will be 100 \u03a9 +10 k\u03a9 pot\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.15 : Page No - 504\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 800 # in Hz\n",
      "D = 0.6 \n",
      "C = 0.1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "# Formula f= 1.44/((R_A+2*R_B)*C)\n",
      "# R_A+2*R_B= 1.44/(f*C)                  (i)\n",
      "# D= (R_A+R_B)/(R_A+2*R_B) or\n",
      "# R_B= (1-D)/(2*D-1)*R_A           (ii)\n",
      "# From eq (i) and (ii)\n",
      "R_A= 1.44/(f*C*(1+2*((1-D)/(2*D-1)))) # in ohm\n",
      "R_B=  (1-D)/(2*D-1)*R_A # in ohm\n",
      "print \"The value of R_A = %0.1f k\u03a9\" %(R_A*10**-3) \n",
      "print \"The value of R_B = %0.1f k\u03a9\" %(R_B*10**-3) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_A = 3.6 k\u03a9\n",
        "The value of R_B = 7.2 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.16 : Page No - 504\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "f = 700 # in Hz\n",
      "D = 0.5 \n",
      "C = 0.1 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "# Formula f= 1.44/((R_A+2*R_B)*C)\n",
      "# R_A+2*R_B= 1.44/(f*C)                  (i)\n",
      "# D= (R_A+R_B)/(R_A+2*R_B) or\n",
      "# R_A+R_B=D*1.44/(f*C)\n",
      "# From eq (i) and (ii)\n",
      "R_B=round(1.44/(f*C))*(1-D) \n",
      "R_A= round(D*1.44/(f*C))-R_B \n",
      "#R_A= 1.44/(f*C*(1+2*((1-D)/(2*D-1)))) # in ohm\n",
      "#R_B=  (1-D)/(2*D-1)*R_A # in ohm\n",
      "print \"The value of R_A = %0.f \u03a9\" %round(R_A)\n",
      "print \"The value of R_B = %0.3f k\u03a9\" %(R_B*10**-3) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_A = 1 \u03a9\n",
        "The value of R_B = 10.286 k\u03a9\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.17 : Page No - 507\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "R_A = 20 # in k ohm\n",
      "R_A = R_A * 10**3 # in ohm\n",
      "C = 0.1 # in \u00b5F\n",
      "C = C*10**-6 # in F\n",
      "pulse_width = 1.1*R_A*C # in s\n",
      "print \"The output pulse width = %0.f ms\" %(pulse_width*10**3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output pulse width = 2 ms\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.18 : Page No - 507\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import symbols, solve\n",
      "T= symbols('T')\n",
      "#Given data\n",
      "n=4 \n",
      "# t_p= X*T, where\n",
      "X= (0.2+(n-1)) # (assumed)\n",
      "t_p= X*T\n",
      "print \"The relation between t_p and T is :\"\n",
      "print \"t_p = \",t_p\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The relation between t_p and T is :\n",
        "t_p =  3.2*T\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13.19 : Page No - 507\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data\n",
      "C = 0.02 # in \u00b5F\n",
      "C = C * 10**-6 # in F\n",
      "f=2*10**3 #frequency in Hz\n",
      "T = 1/f # in sec\n",
      "n = 5 \n",
      "t_p = (0.2+(n-1))*T # in sec\n",
      "R_A = t_p/(1.1*C) # in ohm\n",
      "print \"The value of R_A = %0.2f k\u03a9 (standard value 100 kohm)\" %(R_A*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_A = 95.45 k\u03a9 (standard value 100 kohm)\n"
       ]
      }
     ],
     "prompt_number": 42
    }
   ],
   "metadata": {}
  }
 ]
}