{
 "metadata": {
  "name": "",
  "signature": "sha256:da9731a08909e4ad4cafbaaa3667ca4e507b854221c0c6168fb27a7fc7f1c9cc"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter7 - The 555 timer"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.1 - page : 233"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "th=4 #ms\n",
      "VCC=10 #V\n",
      "C=0.05 #micro F(choosen between 0.01<=C<=1)\n",
      "R=th*10**-3/(1.1*C*10**-6)/1000 #kohm\n",
      "C1=0.01 #micro F(assumed)\n",
      "C2=0.01 #micro F(choosen between 0.01<=C<=1)\n",
      "R2=th*10**-3/(10*C2*10**-6)/1000 #kohm\n",
      "C3=10 #micro F\n",
      "print \"Design values are : \"\n",
      "print \"Capacitance C = %0.2f micro F \" %C \n",
      "print \"Resistance R = %0.1f kohm \" %R \n",
      "print \"Capacitance C1 = %0.2f micro F \" %C1 \n",
      "print \"Capacitance C2 = %0.2f micro F \" %C2 \n",
      "print \"Resistance R2 = %0.2f kohm \" %R2 \n",
      "print \"Capacitance C3 = %0.2f micro F \" %C3 \n",
      "#Answer of R2 is wrong in the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are : \n",
        "Capacitance C = 0.05 micro F \n",
        "Resistance R = 72.7 kohm \n",
        "Capacitance C1 = 0.01 micro F \n",
        "Capacitance C2 = 0.01 micro F \n",
        "Resistance R2 = 40.00 kohm \n",
        "Capacitance C3 = 10.00 micro F \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.2 - page : 236"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "ft=2 #kHz\n",
      "C=0.01 #micro F\n",
      "T=1/ft #ms\n",
      "n=3 #for divide-by-3 circuit\n",
      "th=(0.2+(n-1))*T #ms\n",
      "R=th/(1.1*C) #kohm\n",
      "print \"Value of Resistance R = %0.2f kohm \" %R"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of Resistance R = 100.00 kohm \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.3 - page 239"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "fo=2 #kHz\n",
      "D=70 #%(duty cycle)\n",
      "T=1/fo #ms\n",
      "VCC=12 #V\n",
      "tC=D*T/100 #ms\n",
      "tD=T-tC #ms\n",
      "C=0.05 #micro F(choosen between 0.01<=C<=1)\n",
      "RB=tD*10**-3/(0.69*C*10**-6)/1000 #kohm\n",
      "RA=tC*10**-3/(0.69*C*10**-6)/1000-RB #kohm\n",
      "print \"Design values are : \"\n",
      "print \"Capacitance C = %0.2f micro F \" %C  \n",
      "print \"Resistance RA = %0.1f kohm \" %RA \n",
      "print \"Resistance RB = %0.1f kohm \" %RB\n",
      "#Answer is not accurate in the textbook."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are : \n",
        "Capacitance C = 0.05 micro F \n",
        "Resistance RA = 5.8 kohm \n",
        "Resistance RB = 4.3 kohm \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.4 : page 243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "fo=2 #kHz\n",
      "D=50 #%(duty cycle)\n",
      "T=1/fo #ms\n",
      "VCC=10 #V\n",
      "tC=D*T/100 #ms\n",
      "tD=T-tC #ms\n",
      "C=0.1 #micro F(choosen between 0.01<=C<=1)\n",
      "RB=tD*10**-3/(0.69*C*10**-6)/1000 #kohm\n",
      "RA=T*10**-3*1.45/(C*10**-6)/1000-RB #kohm\n",
      "print \"Design values are : \"\n",
      "print \"Capacitance C= %0.2f micro F \" %C \n",
      "print \"Resistance RA = %0.1f kohm \" % RA \n",
      "print \"Resistance RB = %0.1f kohm \" %RB \n",
      "# RA & RB should be equal for 50% duty cycle."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are : \n",
        "Capacitance C= 0.10 micro F \n",
        "Resistance RA = 3.6 kohm \n",
        "Resistance RB = 3.6 kohm \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.5 - page : 244"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "fo=2 #kHz\n",
      "D=40 #%(duty cycle)\n",
      "T=1/fo #ms\n",
      "VCC=10 #V\n",
      "tC=D*T/100 #ms\n",
      "tD=T-tC #ms\n",
      "C=0.22 #micro F(choosen between 0.01<=C<=1)\n",
      "RB=tD*10**-3/(0.69*C*10**-6)/1000 #kohm\n",
      "RA=T*10**-3*1.45/(C*10**-6)/1000-RB #kohm\n",
      "print \"Design values are : \" \n",
      "print \"Capacitance C = %0.2f micro F \" %C \n",
      "print \"Resistance RA = %0.1f kohm \" %RA \n",
      "print \"Resistance RB = %0.f kohm \" %round(RB) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are : \n",
        "Capacitance C = 0.22 micro F \n",
        "Resistance RA = 1.3 kohm \n",
        "Resistance RB = 2 kohm \n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.6 - page : 245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "fo=700 #Hz\n",
      "D=50 #%(duty cycle)\n",
      "T=1/fo*1000 #ms\n",
      "VCC=10 #V\n",
      "tC=D*T/100 #ms\n",
      "tD=T-tC #ms\n",
      "C=0.05 #micro F(choosen between 0.01<=C<=1)\n",
      "RB=tD*10**-3/(0.69*C*10**-6)/1000 #kohm\n",
      "RA=T*10**-3*1.45/(C*10**-6)/1000-RB #kohm\n",
      "print \"Design values are : \"\n",
      "print \"Capacitance C = %0.2f micro F \" %C \n",
      "print \"Resistance RA = %0.2f kohm \" %round(RA) \n",
      "print \"Resistance RB = %0.2f kohm \" %round(RB) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are : \n",
        "Capacitance C = 0.05 micro F \n",
        "Resistance RA = 21.00 kohm \n",
        "Resistance RB = 21.00 kohm \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex 7.7 - page : 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "fo=800 #Hz\n",
      "D=60 #%(duty cycle)\n",
      "T=1/fo*1000 #ms\n",
      "VCC=10 #V\n",
      "tC=D*T/100 #ms\n",
      "tD=T-tC #ms\n",
      "C=0.047 #micro F(choosen between 0.01<=C<=1)\n",
      "RB=tD*10**-3/(0.69*C*10**-6)/1000 #kohm\n",
      "RA=tC*10**-3*1.45/(C*10**-6)/1000-RB #kohm\n",
      "print \"Design values are : \"\n",
      "print \"Capacitance C = %0.3f micro F \" %C \n",
      "print \"Resistance RA = %0.2f kohm \" %round(RA) \n",
      "print \"Resistance RB = %0.2f kohm \" %round(RB)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Design values are : \n",
        "Capacitance C = 0.047 micro F \n",
        "Resistance RA = 8.00 kohm \n",
        "Resistance RB = 15.00 kohm \n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}