{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter-9 : The 555 IC Timer"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.1 - Page No 295"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C=.01 # in micro F\n",
      "C=C*10**-6 # in  F\n",
      "R_A= 2 # in kohm\n",
      "R_A=R_A*10**3 # in ohm\n",
      "R_B= 100 # in kohm\n",
      "R_B=R_B*10**3 # in ohm\n",
      "T_High= 0.693*(R_A+R_B)*C # in seconds\n",
      "T_Low= 0.693*R_B*C # in seconds\n",
      "T=T_High+T_Low # in seconds\n",
      "f=1/T # in Hz\n",
      "print \"Frequency of oscillations = %0.1f Hz\" %f\n",
      "DutyCycle= T_High/T*100 # in percent\n",
      "print \"Duty cycle = %0.1f %%\" %DutyCycle "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of oscillations = 714.4 Hz\n",
        "Duty cycle = 50.5 %\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.2 - Page No 295\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C=1 # in micro F\n",
      "C=C*10**-6 # in  F\n",
      "C1=0.01 # in micro F\n",
      "C1=C1*10**-6 # in  F\n",
      "R_A=4.7 # in kohm\n",
      "R_B=1 # in kohm\n",
      "R_A=R_A*10**3 # in ohm\n",
      "R_B=R_B*10**3 # in ohm\n",
      "T_on= 0.693*(R_A+R_B)*C # in seconds\n",
      "T_on=T_on*10**3 # in ms\n",
      "print \"Positive pulse width = %0.2f mili seconds\" %T_on\n",
      "T_off= 0.693*R_B*C # in seconds\n",
      "T_off=T_off*10**3 # in ms\n",
      "print \"Negative pulse width = %0.3f mili seconds\" %T_off\n",
      "f=1.4/((R_A+2*R_B)*C) # in Hz\n",
      "print \"Free running Frequency = %0.f Hz\" %f\n",
      "DutyCycle= (R_A+R_B)/(R_A+2*R_B)*100# in percent\n",
      "print \"Duty cycle = %0.f %%\" %DutyCycle"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Positive pulse width = 3.95 mili seconds\n",
        "Negative pulse width = 0.693 mili seconds\n",
        "Free running Frequency = 209 Hz\n",
        "Duty cycle = 85 %\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.3 - Page No 296\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C=0.01 # in micro F\n",
      "C=C*10**-6 # in  F\n",
      "f=1 # in kHz\n",
      "f=f*10**3 # in Hz\n",
      "# R_A= R_B\n",
      "# T_on = T_off = T/2\n",
      "# Frequency is given by equation f= 1.44/((R_A+R_B)*C)\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 \n",
      "\n",
      "print \"The value of required resistors =\",int(round(R_A)),\"k ohm (68 ohm standart value)\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of required resistors = 72 k ohm (68 ohm standart value)\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.4 - Page No 296\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "f=700 # in Hz\n",
      "# R_A= R_B\n",
      "# T_on = T_off = T/2\n",
      "# Frequency is given by equation f= 1.44/((R_A+R_B)*C)\n",
      "C=0.01 # in micro F  (assumed value)\n",
      "C=C*10**-6 # in  F\n",
      "R_A= 1.44/(2*f*C) # in ohm\n",
      "R_A=R_A*10**-3 # in k ohm\n",
      "R_A=int(round(R_A) )\n",
      "R_B= R_A \n",
      "print \"The value of required resistors   =\",(R_A),\"k ohm (100 ohm standart value)\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of required resistors   = 103 k ohm (100 ohm standart value)\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.5 - Page No 296\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "f=800 # in Hz\n",
      "D=60 # in percent\n",
      "# Formula D= (R_A+R_B)/(R_A+2*R_B)*100 = 60\n",
      "# R_A + R_B = 0.6*R_A + 1.2*R_B\n",
      "# R_B= 2*R_A\n",
      "C=0.01 # in micro F  (assumed value)\n",
      "C=C*10**-6 # in  F\n",
      "# Frequency is given by equation f= 1.44/((R_A+R_B)*C)\n",
      "R_A= 1.44/(5*C*f) # in ohm\n",
      "R_A=R_A*10**-3 # in kohm\n",
      "R_B=2*R_A # in kohm\n",
      "print \"The value of C   = %0.2f micro F\" %(C*10**6)\n",
      "print \"The value of R_A = %0.f kohm\" %R_A\n",
      "print \"The value of R_B = %0.f kohm\" %R_B\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of C   = 0.01 micro F\n",
        "The value of R_A = 36 kohm\n",
        "The value of R_B = 72 kohm\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.6 - Page No 297\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C=.05 # in micro F\n",
      "C=C*10**-6 # in  F\n",
      "R= 12 # in kohm\n",
      "R=R*10**3 # in ohm\n",
      "V_CC= 5 # in volt\n",
      "V_BE= 0.7 # in volt\n",
      "V_D1= V_BE # in volt\n",
      "I_C= (V_CC-V_BE)/R # in A\n",
      "f_o= (3*I_C)/(V_CC*C) # in Hz\n",
      "f_o=f_o*10**-3 # in kHz\n",
      "print \"Frequency of free running ramp generator circuit = %0.1f kHz\" %f_o"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of free running ramp generator circuit = 4.3 kHz\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.7 - Page No 300\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "C=.1 # in micro F\n",
      "C=C*10**-6 # in  F\n",
      "R_A= 20 # in kohm\n",
      "R_A=R_A*10**3 # in ohm\n",
      "PulseWidth= 1.1*R_A*C # in seconds\n",
      "print \"The output pulse width = %0.1f mili seconds\" %(PulseWidth*10**3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output pulse width = 2.2 mili seconds\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example : 9.9 - Page No 300\n",
      "    "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "C=.02 # in micro F\n",
      "C=C*10**-6 # in  F\n",
      "f=2 # frequency of the outpur trigger in kHz\n",
      "f=f*10**3 # in Hz\n",
      "T=1/f # in seconds\n",
      "# In a divide-by-5 circuit , n=5, so the pulse width, t_p= [0.2 + (n-1)]*T = [0.2 + (5-1)]*T = 4.2*T\n",
      "t_p=4.2*T # in soconds\n",
      "# Formula t_p = 1.1*R_A*C\n",
      "R_A= t_p/(1.1*C) # in ohm\n",
      "R_A=R_A*10**-3 # in kohm\n",
      "print \"The value of R_A = %0.2f k ohm (Standard value 100 kohm)\" %R_A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R_A = 95.45 k ohm (Standard value 100 kohm)\n"
       ]
      }
     ],
     "prompt_number": 40
    }
   ],
   "metadata": {}
  }
 ]
}