{
 "metadata": {
  "name": "ch_7"
 }, 
 "nbformat": 2, 
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown", 
     "source": [
      "<h1>Chapter 7: Waveform Generators<h>"
     ]
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.7.1 , Page NO: 324<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declarartion:", 
      "import math", 
      "f=300.0                        #frequency in hertz", 
      "C=0.1*10**-6                   #capacitance in farad", 
      "", 
      "#Calculations:", 
      "t=f*C                           ", 
      "R=1/(2*math.pi*t*math.sqrt(6))  #Calculating resistance value", 
      "R=R/1000                        #Calculating resistance value", 
      "R1=22000.0                      #Calculating resistance value", 
      "Rf=29.0*R1                      #Calculating resistance value", 
      "Rf=Rf/1000.0                    #Calculating resistance value", 
      "", 
      "#Results:", 
      "print('R= %.2f kohm'%R)", 
      "print('\\nLet R=2.2 kohm, hence R1=22 kohm')", 
      "print('\\nRf= %d kohm'%Rf)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "R= 2.17 kohm", 
        "", 
        "Let R=2.2 kohm, hence R1=22 kohm", 
        "", 
        "Rf= 638 kohm"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 7.2, Page No: 326<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "import math", 
      "f=2000.0                     #Frequency in hertz", 
      "C=0.05*10**-6                #Capacitance in farad", 
      "", 
      "#Calculations:", 
      "t=f*C", 
      "R=1/(2*math.pi*t)            #Calculating resistance value", 
      "R=R/1000.0                   #Calculating resistance value", 
      "R1=1800.0                    #Calculating resistance value", 
      "Rf=2.0*R1                    #Calculating resistance value", 
      "Rf=Rf/1000.0                 #Calculating resistance value", 
      "", 
      "#Results:", 
      "print('R= %.3f kohm'%R)", 
      "print('\\nLet R=1.8 kohm')", 
      "print('\\nRf= %3f kohm'%Rf)", 
      "print('\\nStandard value Rf= 3.3 kohm')"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "R= 1.592 kohm", 
        "", 
        "Let R=1.8 kohm", 
        "", 
        "Rf= 3.600000 kohm", 
        "", 
        "Standard value Rf= 3.3 kohm"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No.7.3, Page No: 329<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "R1=116.0*10**3          #Resistance in ohm", 
      "R2=100.0*10**3          #Resistance in ohm", 
      "Vsat=14.0               #Voltage in volt", 
      "", 
      "#Calculations:", 
      "# Part A", 
      "f=1000.0                #Frequency in hertz     ", 
      "", 
      "T=1/f               ", 
      "# As log value is approx 1", 
      "RC=T/2                  #Calculating time constant", 
      "RC1=RC*1000.0           #Calculating time constant", 
      "", 
      "# Part B", 
      "C=0.01*10**-6           #Capacitance in farad", 
      "R=RC/C                  #Calculating resistance", 
      "Rn=R/1000.0             #Calculating resistance", 
      "", 
      "# Part C", 
      "Vmax=2*Vsat*(R2/(R1+R2))     #Calculating maximum value of differential voltage", 
      "", 
      "#Results:", 
      "print('RC= %.1f *10^-3 sec'%RC1)", 
      "print('\\nR= %d kohm'%Rn)", 
      "print('\\nMaximum value of differential input voltage= %.2f V'%Vmax)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "RC= 0.5 *10^-3 sec", 
        "", 
        "R= 50 kohm", 
        "", 
        "Maximum value of differential input voltage= 12.96 V"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Exa ple NO. 7.4,Page NO: 330<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "fo=1000.0                 #Frequency in hertz", 
      "Vcc=12.0                  #Voltage Vcc in volt", 
      "R1=10.0*10**3             #Resistance in ohm", 
      "R2=10.0*10**3             #Resistance in ohm", 
      "C=0.1*10**-6              #Capacitance value in farad", 
      "", 
      "#Calculations:", 
      "R=1/(2.2*C*fo)            #Calulating resistance value", 
      "R=R/1000.0                #Calculating resistance value", 
      "", 
      "#Results:", 
      "print('R= %.3f kohm'%R)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "R= 4.545 kohm"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 7.5, Page No: 334<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "R1=100.0*10**3           #Resistance in ohm", 
      "R3=20.0*10**3            #Resistance in ohm", 
      "C1=0.01*10**-6           #Capacitance in farad", 
      "Vsat=14.0                #Voltage in volt", 
      "", 
      "#Calculations:", 
      "# Part A", 
      "T=4*R1*R2*C1/R3          #Calculating time period", 
      "Tn=T*1000                #Calculating time period", 
      "", 
      "# Part B", 
      "f=1/T                    #Calculating frequency", 
      "", 
      "# Part C", 
      "", 
      "# Part D", 
      "Vp=R2*Vsat/R3           #Calculating peak value of the triangular wave", 
      "", 
      "#Results:", 
      "print('Time period T= %d ms'%Tn)", 
      "print('\\nfrequency f= %d Hz'%f)", 
      "print('\\nPeak value is +14V and -14V')", 
      "print('\\nTriangular wave oscillates between  %d V and - %d V'%(Vp,Vp))"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Time period T= 2 ms", 
        "", 
        "frequency f= 500 Hz", 
        "", 
        "Peak value is +14V and -14V", 
        "", 
        "Triangular wave oscillates between  7 V and - 7 V"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example NO. 7.6, Page No: 336<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "Ri=10.0*10**3              #Resitance in ohm", 
      "Vp=10.0                    #Voltage in volt", 
      "Vref=10.0                  #Voltage in volt", 
      "fo=200.0                   #Frequency in hertz", 
      "C1=0.1*10**-6              #Capacitance in farad", 
      "Vi=2.0                     #Voltage in volt", 
      "", 
      "#Calculations:", 
      "t=Vi/Vref                  ", 
      "f=t/(Ri*C1)               #Calculating frequency", 
      "", 
      "#Result:", 
      "print('Frequency f= %d Hz'%f)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Frequency f= 200 Hz"
       ]
      }
     ], 
     "prompt_number": 6
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 7.7, Page no: 345<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "# Answer in textbook is wrong", 
      "#Varible Declaration:", 
      "C=0.1*10**-6          #Capacitance in farad", 
      "t=1*10**-3            #time in second", 
      "", 
      "#Calculations:", 
      "R=t/(1.22*C)          #Calculating resistance value", 
      "R=R/1000              #Calculating resistance value", 
      "", 
      "#Result:", 
      "print('R= %.1f kohm'% R)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "R= 8.2 kohm"
       ]
      }
     ], 
     "prompt_number": 7
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 7.8, Page No: 351<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "D=20.0 # 20 percent            #Duty cycle", 
      "Ton=1.0*10**-3                 #On time period in seconds ", 
      "", 
      "#Calculatins:", 
      "Tonpoff=100.0*Ton/D            #Calculating total time period  ", 
      "Tonpoff1=Tonpoff*1000.0        #Calculating total time period", 
      "f=1/Tonpoff                    #Calculating frequency of oscillation", 
      "", 
      "#Results:", 
      "print('Ton + Toff= %d ms'%Tonpoff1)", 
      "print('\\nFrequency of oscillation= %d Hz'%f)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Ton + Toff= 5 ms", 
        "", 
        "Frequency of oscillation= 200 Hz"
       ]
      }
     ], 
     "prompt_number": 8
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example No. 7.9, Page No: 351<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "D=0.7                      #Duty cycle ", 
      "f=1000.0                   #Frequency in hertz", 
      "", 
      "RB=10.0**4/(6.43/3.0)  #Resistance value in ohm", 
      "", 
      "#Calculations:", 
      "RA=4.0*RB/2.75              #Calculating resistance value", 
      "RB1=RB/1000.0                #Calculating resistance value", 
      "RA1=RA/1000.0                #Calculating resistance value", 
      "", 
      "#Results:", 
      "print('RB= %.1f kohm'%RB1)", 
      "print('\\nRA= %.1f kohm'%RA1)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "RB= 4.7 kohm", 
        "", 
        "RA= 6.8 kohm"
       ]
      }
     ], 
     "prompt_number": 12
    }, 
    {
     "cell_type": "markdown", 
     "source": [
      "<h3>Example 7.10, Page No: 352<h3>"
     ]
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "", 
      "#Variable Declaration:", 
      "f1=1070.0                   #Frequency in hertz", 
      "RA=50000.0                  #Resistance in ohm", 
      "C=0.01*10**-6               #Capacitance value in farad", 
      "Rc=76.0#Standard Value      #Resistance in ohm", 
      "", 
      "#Calculations:", 
      "t=1.45/(f1*C)               ", 
      "RB=(t-RA)/2                 #Calculating value of resistance   ", 
      "RB=RB/1000                  #Calculating value of resistance", 
      "", 
      "#Results:", 
      "print('Assuming RA= 50 kohm and C= 0.01 uF')", 
      "print('\\nHence, RB= %.2f kohm'%RB)", 
      "print('\\nRc= %d ohm (Standard Value)'%Rc)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Assuming RA= 50 kohm and C= 0.01 uF", 
        "", 
        "Hence, RB= 42.76 kohm", 
        "", 
        "Rc= 76 ohm (Standard Value)"
       ]
      }
     ], 
     "prompt_number": 10
    }
   ]
  }
 ]
}