{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 11 : Test Signal Generation" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_1,pg 343\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# limits of duty cycle\n", "\n", "import math\n", "#Variable decl;aration\n", "R1=1.0*10**3 #input resistance\n", "R2=1.0*10**3 #feedback resistor\n", "R3=1.0*10**3 #non inverting ter. resistor\n", "R8=1.0*10**3 #potentiometer\n", "R4=1.0*10**3\n", "\n", "#Calculations\n", "DF1=(R1/((2*R1)+R8)) #duty factor lim.-1\n", "DF2=(R1+R4)/((2*R1)+R8) #duty factor lim.-2\n", "#T=(((2*R4*C*((2*R1)+R8)))/R1)*(Vt/Vi)=((6*R4*C*Vt)/Vi)\n", "\n", "#Result\n", "print(\"range of duty factor is DF1 to DF2 i.e.\")\n", "print(\"%.2f to %.2f \"%(DF1,DF2))\n", "print(\"\\nlimits of t1 and t2:\")\n", "print(\"(T/3) to (2T/3)\")" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "range of duty factor is DF1 to DF2 i.e.\n", "0.33 to 0.67 \n", "\n", "limits of t1 and t2:\n", "(T/3) to (2T/3)\n" ] } ], "prompt_number": 11 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_2,pg 344" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# determine sinewave amplitude and segment slopes\n", "\n", "import math\n", "#Variable declaration\n", "Vtx=5.0 #triangular peak(+/-)5\n", "Vsx=(2/math.pi)*Vtx #sinewave peak\n", "#if n=3 then there are 2*3=6 break points these are at o/p voltages\n", "n=3.0 #break point parameter\n", "\n", "#Calculations\n", "Vs1=(2/math.pi)*Vtx*math.sin((1*math.pi)/((2*n)+1))\n", "Vs2=(2/math.pi)*Vtx*math.sin((2*math.pi)/((2*n)+1))\n", "Vs3=(2/math.pi)*Vtx*math.sin((3*math.pi)/((2*n)+1))\n", "#calculating slopes\n", "ms1=(((2*n)+1)/math.pi)*(math.sin((math.pi*(1+1))/((2*n)+1))-math.sin((math.pi*1)/((2*n)+1)))\n", "ms2=(((2*n)+1)/math.pi)*(math.sin((math.pi*(2+1))/((2*n)+1))-math.sin((math.pi*2)/((2*n)+1)))\n", "ms3=(((2*n)+1)/math.pi)*(math.sin((math.pi*(3+1))/((2*n)+1))-math.sin((math.pi*3)/((2*n)+1)))\n", "\n", "#Result\n", "print(\"break points:\")\n", "print(\"output voltages:\")\n", "print(\"Vs1 = %.2f V \"%Vs1)\n", "print(\"Vs2 = %.2f V \"%Vs2)\n", "print(\"Vs3 = %.2f V\\n\"%Vs3)\n", "print(\"segment slopes:\")\n", "print(\"ms1 = %.2f \"%ms1)\n", "print(\"ms2 = %.2f \"%ms2)\n", "print(\"ms3 = %.2f \"%ms3)\n", "#Answers are slightly different than book" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "break points:\n", "output voltages:\n", "Vs1 = 1.38 V \n", "Vs2 = 2.49 V \n", "Vs3 = 3.10 V\n", "\n", "segment slopes:\n", "ms1 = 0.78 \n", "ms2 = 0.43 \n", "ms3 = 0.00 \n" ] } ], "prompt_number": 11 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_3,pg 505" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# find inductance\n", "\n", "import math\n", "#Variable declaration\n", "R1=0.0 #resistance\n", "C=0.1*10**-6 #capacitance\n", "f=1.0*10**3 #frequency\n", "\n", "#Calculations\n", "L=(1.0/(((2*math.pi*f)**2)*C))\n", "\n", "\n", "#Result\n", "print(\"Inductance of circuit:\")\n", "print(\"L = %.6f H \"%(L))\n", "#Answer do not matche with book" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Inductance of circuit:\n", "L = 0.253303 H \n" ] } ], "prompt_number": 20 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_4,pg 506" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# resonance frequency of crystal\n", "\n", "import math\n", "#Variable declaration\n", "C1=4*10**-12 #Capacitance\n", "L=94*10**-3 #inductance \n", "C=13*10**-9 #capacitance\n", "R=91.3 #resistance\n", "\n", "#Calculations\n", "f1=(1/(2*math.pi))*((L*C)**(-1.0/2)) #resonance frequency-1\n", "f2=(math.sqrt(1+(C/C1))/(2*math.pi*math.sqrt(L*C))) #resonance frequency-2\n", "\n", "#Result\n", "print(\"resonance frequency-1:\")\n", "print(\"f1 = %.2f kHz\\n\"%(f1/1000))\n", "print(\"resonance frequency-2:\")\n", "print(\"f2 = %.2f kHz\"%(f2/1000))\n", "#Answer for f2 is slightly different" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "resonance frequency-1:\n", "f1 = 4.55 kHz\n", "\n", "resonance frequency-2:\n", "f2 = 259.59 kHz\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_5,pg 506\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# find R in CR section\n", "\n", "import math\n", "#Result\n", "f=1.0*10**3 #frequency\n", "C=0.01*10**-6 #capacitance\n", "\n", "#Calculations\n", "#f=(1/(2*%pi))*(1/(6^(1/2)*RC))\n", "R=(1/(2*math.pi*(6**(0.5)*C*f)))\n", "\n", "#Result\n", "print(\"resistance of circuit\\n\")\n", "print(\"R = %.1f k-ohm\"%(R/1000))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "resistance of circuit\n", "\n", "R = 6.5 k-ohm\n" ] } ], "prompt_number": 24 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_6,pg 506" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# find phase difference in wein network\n", "\n", "import math\n", "#Variable declaration\n", "epsi=0.01 #detuning parameter\n", "eta1=1.0 #(f/fo)=1\n", "eta2=2.2 #(f/fo)=2.2\n", "\n", "#Calculations\n", "#case-1\n", "phi1=math.atan((3*eta1*((eta1**2)-1)*(3+(2*epsi)))/((((eta1**2)-1)**2)*(3+epsi)-(9*epsi*(eta1**2))))\n", "#case-2\n", "phi2=math.atan((3*eta2*((eta2**2)-1)*(3+(2*epsi)))/((((eta2**2)-1)**2)*(3+epsi)-(9*epsi*(eta2**2))))\n", "\n", "#Result\n", "print(\"phase difference for case-1:\")\n", "print(\"phi1 = %d rad\\n\"%phi1)\n", "print(\"phase difference for case-2:\")\n", "print(\"phi2 = %.2f rad\"%phi2)\n", "#Answer for phi2 is not matching with book" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "phase difference for case-1:\n", "phi1 = 0 rad\n", "\n", "phase difference for case-2:\n", "phi2 = 1.05 rad\n" ] } ], "prompt_number": 30 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_7,pg 507" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# digital frequency synthesizer\n", "\n", "import math\n", "#Variable declaration\n", "N=12.0 #12-bit synthesizer\n", "k1=1.0 #sampling rate at sampler's rate\n", "k2=4.0 #sampling rate at 4 times sampler's rate\n", "\n", "\n", "#Calculations\n", "#case-1\n", "adv1=(360/(2**N)) #advancement of o/p register \n", "#2pi rad=360 deg.\n", "#case-2\n", "adv2=(4.0*(360)/(2**N)) #advancement of o/p register \n", "\n", "#Result\n", "print(\"advancement of o/p register for case-1:\")\n", "print(\"adv1 = %.4f\u00b0 \\n\"%adv1)\n", "print(\"advancement of o/p register for case-2:\")\n", "print(\"adv2 = %.4f\u00b0\"%adv2)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "advancement of o/p register for case-1:\n", "adv1 = 0.0879\u00b0 \n", "\n", "advancement of o/p register for case-2:\n", "adv2 = 0.3516\u00b0\n" ] } ], "prompt_number": 31 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_8,pg 507" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# find controlling voltage\n", "\n", "import math\n", "#Variable declaration\n", "f=1.0*10**3 #frequency\n", "R6=10.0*10**3 #feed-back resistor\n", "R5=22.0*10**3 #feed-in resistor\n", "R4=10.0*10**3 #integrator resistor\n", "C=0.1*10**-6 #integrator capacitor\n", "Vsx=2.0 #comparator pulse amplitude\n", "\n", "#Calculations\n", "Vi=((f*R4*R5*C)/(R6*4*Vsx)) #controlling voltage\n", "\n", "#Result\n", "print(\"controlling voltage:\")\n", "print(\"Vi = %.3f V\"%Vi)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "controlling voltage:\n", "Vi = 0.275 V\n" ] } ], "prompt_number": 33 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_9,pg 507" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# find limits of duty factor\n", "\n", "import math\n", "#Variable declaration\n", "R1=10.0*10**3\n", "R8=10.0*10**3\n", "R4=10.0*10**3\n", "\n", "#Calculations\n", "lim1=(R1/((2*R1)+R8)) #limit-1 of duty factor\n", "lim2=((R1+R4)/((2*R1)+R8)) #limit-2 of duty factor\n", "\n", "#Result\n", "print(\"duty factors are given by (t1/T) and (t2/T). the limits are giiven by\\n\")\n", "print(\"lim1 = %.2f\"%lim1)\n", "print(\"lim2 = %.2f\"%lim2)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "duty factors are given by (t1/T) and (t2/T). the limits are giiven by\n", "\n", "lim1 = 0.33\n", "lim2 = 0.67\n" ] } ], "prompt_number": 19 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example11_10,pg 507" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# find output voltage V1 and V2\n", "\n", "import math\n", "#Variable declaration\n", "Vi=1.3 #input voltage\n", "R2=10.0*10**3\n", "R3=10.0*10**3\n", "R8=10.0*10**3 #potentiometer\n", "B=1.0/3 #wiper distance\n", "\n", "\n", "#Calculations\n", "V1=((R3*Vi)/(R3+(B*R8))) #output voltage-1\n", "V2=-((R2*Vi)/(R3+((1-B)*R8)))#output voltage-2\n", "\n", "#Result\n", "print(\"ouput voltage-1:\")\n", "print(\"V1 = %.4f V\"%V1)\n", "print(\"ouput voltage-2:\")\n", "print(\"V2 = %.4f V\"%V2)\n", "#Answers are slightly different than book" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "ouput voltage-1:\n", "V1 = 0.9750 V\n", "ouput voltage-2:\n", "V2 = -0.7800 V\n" ] } ], "prompt_number": 36 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }