diff options
Diffstat (limited to 'Engineering_Circuit_Analysis_by_W_Hayt/16-Frequency_Response.ipynb')
-rw-r--r-- | Engineering_Circuit_Analysis_by_W_Hayt/16-Frequency_Response.ipynb | 438 |
1 files changed, 438 insertions, 0 deletions
diff --git a/Engineering_Circuit_Analysis_by_W_Hayt/16-Frequency_Response.ipynb b/Engineering_Circuit_Analysis_by_W_Hayt/16-Frequency_Response.ipynb new file mode 100644 index 0000000..f23243d --- /dev/null +++ b/Engineering_Circuit_Analysis_by_W_Hayt/16-Frequency_Response.ipynb @@ -0,0 +1,438 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 16: Frequency Response" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.10: Bode_diagrams.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.10\n", +"s=poly(0,'s')\n", +"h=syslin('c',(10*s)/((1+s)*(s^2+20*s+10000)))\n", +"disp(h)\n", +"fmin=0.01\n", +"fmax=10^4\n", +"scf(1);clf;\n", +"//Calculate Bode plot\n", +"bode(h,fmin,fmax)\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.11: Filters.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.11\n", +"disp('Given')\n", +"disp('A high pass filter with cutoff frequency of 3k Hz')\n", +"//Cutoff frequency(wc)=1/(R*C)\n", +"//Let us select some standard value of resistor\n", +"disp('Let R=4.7k ohm')\n", +"fc=3*10^3;R=4.7*10^3;\n", +"wc=2*%pi*fc\n", +"C=1/(R*wc)\n", +"printf('\n C=%3.2f nF ',C*10^9);\n", +"s=poly(0,'s')\n", +"h=syslin('c',(R*C*s)/((1+s*R*C)))\n", +"disp(h)\n", +"HW = frmag(h,512);\n", +"w=0: %pi /511: %pi ;\n", +"plot(w,HW)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.12: Filters.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.12\n", +"disp('Given')\n", +"disp('Bandwidth = 1M Hz and high frequency cutoff = 1.1M Hz')\n", +"B=10^6;fH=1.1*10^6\n", +"//B=fH-fL\n", +"fL=fH-B\n", +"printf('Low frequency cutoff fL= %d kHz \n',fL*10^-3);\n", +"wL=2*%pi*fL\n", +"printf('wL= %3.2f krad/s \n',wL*10^-3);\n", +"wH=2*%pi*fH\n", +"printf('wH= %3.3f Mrad/s \n',wH*10^-6);\n", +"//Now we need to find values for R,L and C\n", +"//Let X=1/LC\n", +"B=2*%pi*(fH-fL)\n", +"X=(wH-B/2)^2-(B^2/4)\n", +"disp(X)\n", +"disp('Let L=1H')\n", +"L=1;\n", +"C=1/(L*X)\n", +"disp(C,'C=')\n", +"//B=R/L\n", +"R=L*B\n", +"printf('R= %3.3f Mohm \n',R*10^-6);\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.13: Filters.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.13\n", +"disp('Given')\n", +"disp('Voltage gain = 40dB and cutoff frequency = 10k Hz')\n", +"Av_dB=40\n", +"Av=10^(Av_dB/20)\n", +"f=10*10^3\n", +"B=2*%pi*f\n", +"//From figure 16.41(a)\n", +"disp('1+Rf/R1=100(Gain)')\n", +"//From figure 16.41(b)\n", +"//The transfer function is \n", +"disp('V+= Vi*(1/sC)/(1+1/sC)')\n", +"//Combining two transfer functions\n", +"disp('V0 = Vi*(1/sC)/(1+1/sC)*(1+Rf/R1)')\n", +"//The maximum value of the combined transfer function is\n", +"disp('Maximum value is V0 = Vi*(1+Rf/R1)')\n", +"disp('Let R1=1k ohm')\n", +"R1=10^3\n", +"Rf=(Av-1)*R1\n", +"printf('Rf= %d kohm \n',Rf*10^-3);\n", +"disp('C=1 uF')\n", +"C=10^-6\n", +"//B=1/(R2*C)\n", +"R2=1/(C*B)\n", +"printf('R2= %3.2f ohm \n',R2);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.1: Parallel_Resonance.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.1\n", +"disp('Given')\n", +"disp('L=2.5mH Q0=5 C=0.01uF')\n", +"L=2.5*10^-3; Q0=5; C=0.01*10^-6;\n", +"w0=1/sqrt(L*C)\n", +"printf('w0= %3.1f krad/s \n',w0*10^-3);\n", +"f0=w0/(2*%pi)\n", +"alpha=w0/(2*Q0)\n", +"printf('alpha= %3.1f Np/s \n',alpha);\n", +"wd=sqrt(w0^2-alpha^2)\n", +"printf('wd= %3.1f krad/s \n',wd*10^-3);\n", +"R=Q0/(w0*C)\n", +"printf('R= %3.2f ohm \n',R*10^-3);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.2: Bandwidth_and_high_Q_circuits.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.2\n", +"disp('Given')\n", +"disp('R=40Kohm L=1H C=1/64 uF w=8.2krad/s')\n", +"R=40*10^3; L=1; C=1/64 *10^-6; w=8.2*10^3;\n", +"//The value of Q0 must be at least 5 \n", +"Q0=5;\n", +"w0=1/sqrt(L*C)\n", +"printf('w0= %3.1f krad/s \n',w0*10^-3);\n", +"f0=w0/(2*%pi)\n", +"B=w0/Q0\n", +"printf('Bandwidth= %3.1f krad/s \n',B*10^-3);\n", +"//Number of half bandwidths be N\n", +"N=2*(w-w0)/B\n", +"disp(N)\n", +"//Admittance Y(s)=(1+i*N)/R\n", +"//Finding the magnitude and angle\n", +"magY=sqrt(1+N^2)/R\n", +"angY=atan(N)*(180/%pi)\n", +"disp(angY,'angY=')\n", +"printf('admittance value=%3.2f uS',magY*10^6)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.3: Series_Resonance.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.3\n", +"disp('Given')\n", +"disp('R=10 ohm L=2mH C=200 nF w=48 krad/s vs=100*cos(wt) mV')\n", +"R=10; L=2*10^-3; C=200*10^-9; w=48*10^3;\n", +"vsamp=100;\n", +"w0=1/sqrt(L*C)\n", +"printf('w0= %3.1f krad/s \n',w0*10^-3);\n", +"Q0=w0*L/R\n", +"printf('Q0=%d \n',Q0)\n", +"B=w0/Q0\n", +"printf('Bandwidth= %3.1f krad/s \n',B*10^-3);\n", +"//Number of half bandwidths be N\n", +"N=2*(w-w0)/B\n", +"disp(N)\n", +"//Impedance Z(s)=(1+i*N)*R\n", +"//Finding the magnitude and angle\n", +"magZ=sqrt(1+N^2)*R\n", +"angZ=atan(N)*(180/%pi)\n", +"disp(angZ,'angZ=')\n", +"printf('Equivalent impedance value=%3.2f ohm \n',magZ)\n", +"//Approx current magnitude is\n", +"Iamp=vsamp/magZ\n", +"printf('\n Approx current magnitude= %3.2f mA \n',Iamp);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.4: Other_resonant_forms.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.4\n", +"disp('Given')\n", +"disp('R1=2 ohm R2=3 ohm L=1H C=125mF')\n", +"R1=2;R2=3 ; L=1;C=125*10^-3;\n", +"w0=sqrt(1/(L*C)-(R1/L)^2)\n", +"printf('w0=%d rad/s \n',w0)\n", +"//Input admittance is 1/R2+i*w*C+1/(R+I*w*L)\n", +"Y=1/3+%i/4+1/(2+%i*2)\n", +"printf('Y= %3.4f S \n',Y)\n", +"//Now input impedance at resonance \n", +"Z=1/Y\n", +"printf('Z= %3.4f ohm \n',Z)\n", +"//Resonant frequency f=1/sqrt(L*C)\n", +"f=1/sqrt(L*C)\n", +"printf('f=%3.2f rad/s \n',f);\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.5: Equivalent_Series_and_parallel_combination.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.5\n", +"disp('Given')\n", +"disp('R=5 ohm L=100mH w=100 rad/s')\n", +"Rs=5; Ls=100*10^-3 ;w=100;\n", +"//Let Xs be the capacitive and inductive reactance \n", +"Xs=w*Ls\n", +"Q=Xs/Rs\n", +"//As Q is greater than 5 we can approximate as\n", +"Rp=Q^2*Rs\n", +"Lp=Ls\n", +"printf('The parallel equivalent is \n');\n", +"printf('Rp= %d ohm \t Lp=%d mH',Rp,Lp*10^3);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.6: Scaling.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.6\n", +"disp('Given')\n", +"disp('Km=20 Kf=50')\n", +"Km=20; Kf=50;\n", +"s=poly(0,'s')\n", +"//From figure 16.20(a)\n", +"C=0.05; L=0.5;\n", +"//Performing magnitude as well as frequency scaling simultaneously\n", +"Cscaled =C/(Km*Kf)\n", +"Lscaled = L*Km/Kf\n", +"printf('Scaled values are \n')\n", +"printf('Cscaled =%d uF \t Lscaled =%d mH \n',Cscaled*10^6,Lscaled*10^3)\n", +"//Converting the Laplace transform of the circuit\n", +"//From figure 16.20(c)\n", +"disp('Vin=V1+0.5s*(1-0.2*V1)')\n", +"disp('V1=20/s')\n", +"//On substituting V1 in equation of Vin\n", +"\n", +"Zin=(s^2-4*s+40)/(2*s)\n", +"disp(Zin,'Zin=')\n", +"//Now we need to scale Zin\n", +"//We will multiply Zin by Km and replace s by s/Kf\n", +"Zinscaled=horner(Km*Zin,s/Kf)\n", +"disp(Zinscaled,'Zinscaled')\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.8: Bode_diagrams.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc\n", +"//Example 16.8\n", +"//From figure 16.26\n", +"disp('Writing the expression for voltage gain')\n", +"disp('Vout/Vin=4000*(-1/200)*(5000*10^8/s)/((5000+10^8/s)*(5000+10^6/20s))')\n", +"//On simplification\n", +"s=poly(0,'s')\n", +"h=syslin('c',(-2*s)/((1+s/10)*(1+s/20000)))\n", +"disp(h)\n", +"fmin=0.01\n", +"fmax=10^7\n", +"scf(1);clf;\n", +"bode(h,fmin,fmax)\n", +"" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |