{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 - Tuned Amplifiers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.1 Page No. 5-45"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R_p = omega_0 * L * Q =471.24 kohm\n",
      "R_s = omega_0*L / Q =5.24 ohm\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "rp=2*pi*10**6*250*300*10**-9\n",
    "print \"R_p = omega_0 * L * Q =%0.2f kohm\"%rp\n",
    "rs=(2*pi*250)/300\n",
    "print \"R_s = omega_0*L / Q =%0.2f ohm\"%rs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.2 Page No. 5-45"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "From equation 9 we have\n",
      "  BW = 1 / 2*pi*R*C\n",
      "Therefore,  R*C = 1 / 2*pi*BW =0.00\n",
      "From equation 3 we have\n",
      "  R = r_i || R_p || r_b''e\n",
      "where  r_i = 4 k-ohm\n",
      "r_b''e = h_fe / g_m =2500.00 ohm\n",
      "R_p = Q_c * omega_0 * L = Q_c / omega_0*C\n",
      "Therefore,  R = 4*10**3 || 2500 || Q_c/omega_0*C\n",
      "C = 1 / 2*pi*10*10**3*R\n",
      "Therefore,  C = 1 / 2*pi*10*10**3*[4*10**3 || 2500 || Q_c/2*pi*500*10**3*C]\n",
      "The typical range for Q_c is 10 to 150. However, we have to assume Q such that value of C_p should be positive. Let us assume Q = 100\n",
      "Therefore,  C = 1 / 2*pi*10*10**3*[1538.5 || 1/2*pi*5000*C]\n",
      "              = 1 / 2*pi*10*10**3*[1 / 1/1538.5+2*pi*5000*C]\n",
      "Solving for C we get\n",
      "  C = 0.02 uF\n",
      "We have\n",
      "  C = C'' + C_b''e + (1+g_m*R_L)*C_b''e\n",
      "Therefore,  C'' = C - [C_b''e + (1+g_m*R_L)*C_b''e]\n",
      "Therefore,  C'' = 0.02 uF\n",
      "We have,\n",
      "omega_0**2 = 1 / L*C\n",
      "Therefore,  L = 1 / omega_0**2*C =5.07 uH\n",
      "From equation 2 we have,\n",
      "R_p = omega*L*Q_c =1570.80 ohm\n",
      "Therefore,  R = r_i || R_p || r_b''e =777.04 ohm\n",
      "We have mid frequency gain as\n",
      "A_v(max) = -g_m*R =-31.08\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"From equation 9 we have\"\n",
    "print \"  BW = 1 / 2*pi*R*C\"\n",
    "rc=1/(2*pi*10*10**3)\n",
    "print \"Therefore,  R*C = 1 / 2*pi*BW =%0.2f\"%rc\n",
    "print \"From equation 3 we have\"\n",
    "print \"  R = r_i || R_p || r_b''e\"\n",
    "print \"where  r_i = 4 k-ohm\"\n",
    "rbe=100/0.04\n",
    "print \"r_b''e = h_fe / g_m =%0.2f ohm\"%rbe\n",
    "print \"R_p = Q_c * omega_0 * L = Q_c / omega_0*C\"\n",
    "print \"Therefore,  R = 4*10**3 || 2500 || Q_c/omega_0*C\"\n",
    "print \"C = 1 / 2*pi*10*10**3*R\"\n",
    "print \"Therefore,  C = 1 / 2*pi*10*10**3*[4*10**3 || 2500 || Q_c/2*pi*500*10**3*C]\"\n",
    "print \"The typical range for Q_c is 10 to 150. However, we have to assume Q such that value of C_p should be positive. Let us assume Q = 100\"\n",
    "print \"Therefore,  C = 1 / 2*pi*10*10**3*[1538.5 || 1/2*pi*5000*C]\"\n",
    "print \"              = 1 / 2*pi*10*10**3*[1 / 1/1538.5+2*pi*5000*C]\"\n",
    "print \"Solving for C we get\"\n",
    "print \"  C = 0.02 uF\"\n",
    "print \"We have\"\n",
    "print \"  C = C'' + C_b''e + (1+g_m*R_L)*C_b''e\"\n",
    "print \"Therefore,  C'' = C - [C_b''e + (1+g_m*R_L)*C_b''e]\"\n",
    "c=((0.02*10**-6)-((1000*10**-12)+((1+(0.04*510))*100*10**-12)))*10**6\n",
    "print \"Therefore,  C'' = %0.2f uF\"%c\n",
    "print \"We have,\"\n",
    "print \"omega_0**2 = 1 / L*C\"\n",
    "l=(1/(((2*pi*500*10**3)**2)*(0.02*10**-6)))*10**6\n",
    "print \"Therefore,  L = 1 / omega_0**2*C =%0.2f uH\"%l\n",
    "print \"From equation 2 we have,\"\n",
    "rp=2*pi*500*5*100*10**-3\n",
    "print \"R_p = omega*L*Q_c =%0.2f ohm\"%rp\n",
    "r=(4000*1570*2500)/((1570*2500)+(4000*2500)+(4000*1570))\n",
    "print \"Therefore,  R = r_i || R_p || r_b''e =%0.2f ohm\"%r\n",
    "print \"We have mid frequency gain as\"\n",
    "av=-0.04*777\n",
    "print \"A_v(max) = -g_m*R =%0.2f\"%av"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.3 Page No. 5-46"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) We know that,\n",
      "BW_n = BW_1 * sqrt(2**1/n - 1) =10.20 kHz\n",
      "(ii) BW_n = BW_1 * sqrt(2**1/n - 1) =8.70 kHz\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"(i) We know that,\"\n",
    "bw=((20*10**3)*sqrt(((2)**(1/3))-1))*10**-3\n",
    "print \"BW_n = BW_1 * sqrt(2**1/n - 1) =%0.2f kHz\"%bw\n",
    "bw1=((20*10**3)*sqrt(((2)**(1/4))-1))*10**-3\n",
    "print \"(ii) BW_n = BW_1 * sqrt(2**1/n - 1) =%0.2f kHz\"%bw1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.6 Page No. 5-48"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a) We have,\n",
      "A_vmid=(-g_m*R)= -15\n",
      "Therefore R(in ohms)=(-15)/(-5*10**-3)= 3000.00\n",
      "b) The Miller effect capacitance is given by \n",
      "C_d = C_gs+(1+g_m*R)*(C_g*d)\n",
      " = (1*10**-12)+(1+15)*(3*10**-12)=0.00 F\n",
      "c) The limit frequency of the uncompemsated amplifier is \n",
      "f2 =1/(2*pi*C_d*R)= 1082686.69 Hz\n",
      "d) L =q*C_d*R**2= 0.00 H\n",
      "e) Possible extension of frequency range\n",
      "f''2 =1.72*f2= 1857600.00 Hz\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"a) We have,\"\n",
    "print \"A_vmid=(-g_m*R)= -15\"\n",
    "r=15/(5*10**-3)\n",
    "print \"Therefore R(in ohms)=(-15)/(-5*10**-3)= %0.2f\"%r\n",
    "print \"b) The Miller effect capacitance is given by \"\n",
    "print \"C_d = C_gs+(1+g_m*R)*(C_g*d)\"\n",
    "c=(10**-12)+((1+15)*(3*10**-12))\n",
    "print \" = (1*10**-12)+(1+15)*(3*10**-12)=%0.2f F\"%c\n",
    "print \"c) The limit frequency of the uncompemsated amplifier is \"\n",
    "f=1/(2*pi*49*3*10**-9)\n",
    "print \"f2 =1/(2*pi*C_d*R)= %0.2f Hz\"%f\n",
    "l=0.414*((3*10**3)**2)*(49*10**-12)\n",
    "print \"d) L =q*C_d*R**2= %0.2f H\"%l\n",
    "print \"e) Possible extension of frequency range\"\n",
    "e=1.72*1.08*10**6\n",
    "print \"f''2 =1.72*f2= %0.2f Hz\"%e"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.8 Page No. 5-49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) Resonant frequency:\n",
      "f_r = 1 / 2*pi*sqrt(LC) =1.59 MHz\n",
      "(ii) We know that\n",
      "Q_r = R_p / omega_r*L\n",
      "Therefore,  Impedance of tuned circuit R_p = Q_r * omega_r * L =5994.16\n",
      "(iii) Voltage gain of stage A_v,\n",
      "A_v = A_I*R''_L / R''_i =-299.94\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"(i) Resonant frequency:\"\n",
    "fr=(1/(2*pi*sqrt(20*500*10**-18)))*10**-6\n",
    "print \"f_r = 1 / 2*pi*sqrt(LC) =%0.2f MHz\"%fr\n",
    "print \"(ii) We know that\"\n",
    "print \"Q_r = R_p / omega_r*L\"\n",
    "rp=30*2*pi*1.59*20\n",
    "print \"Therefore,  Impedance of tuned circuit R_p = Q_r * omega_r * L =%0.2f\"%rp\n",
    "print \"(iii) Voltage gain of stage A_v,\"\n",
    "av=(-50*((5994*1500)/(5994+1500)))/200\n",
    "print \"A_v = A_I*R''_L / R''_i =%0.2f\"%av"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.10 Page No. 5-50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i) f_r=Resonant frequency\n",
      "= 1/(2*pi*sqrt(L*C))= 159154.94\n",
      "ii) Tuned circuit dynamic resistance=R_p=L/CR\n",
      "= (400 microH)/(2500pF)*(5ohm)= 32000.00\n",
      "iii) Gain at resonance=A_v=(-g_m*R_L)=(-g_m*R_p)\n",
      " = 6mA/V * 32kohm = -192.00\n",
      "iv) The signal bandwidth =BW=(f_r)/Q\n",
      "Q=(omega_r*L)/R= 79.92\n",
      "BW =(f_r)/Q= 1989.49 Hz\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"i) f_r=Resonant frequency\"\n",
    "f=1/((2*pi)*sqrt(0.0004*2500*10**-12))\n",
    "print \"= 1/(2*pi*sqrt(L*C))= %0.2f\"%f\n",
    "print \"ii) Tuned circuit dynamic resistance=R_p=L/CR\"\n",
    "r=(80*10**6)/2500\n",
    "print \"= (400 microH)/(2500pF)*(5ohm)= %0.2f\"%r\n",
    "print \"iii) Gain at resonance=A_v=(-g_m*R_L)=(-g_m*R_p)\"\n",
    "a=-6*32\n",
    "print \" = 6mA/V * 32kohm = %0.2f\"%a\n",
    "print \"iv) The signal bandwidth =BW=(f_r)/Q\"\n",
    "q=(2*pi*0.159*400)/5\n",
    "print \"Q=(omega_r*L)/R= %0.2f\"%q\n",
    "b=159000/79.92\n",
    "print \"BW =(f_r)/Q= %0.2f Hz\"%b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.11 Page No. 5-51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i)  R_L = r_d || R_p\n",
      "R_p = Tank circuit impedance at resonance = L / CR\n",
      "f_r = 1 / 2*pi*sqrt(L*C)\n",
      "Therefore,  C = 1 / 4*pi**2*f_r**2*L =50.10 pF\n",
      "Q = omega_r*L / R = 2*pi*f_r*L / R\n",
      "Therefore,  R = 2*pi*f_r*L / Q =39.96 ohm\n",
      "R_F = L / C*R =100.00 kohm\n",
      "R_L = r_d*R_p / r_d+R_p =83.33 kohm\n",
      "A_v = -g_m*R_L = 416.65       at resonance frequency omega_r\n",
      "(ii) At  f = f_r+10 kHz = 1.6 MHz\n",
      "|A_v / A_v(at resonance)| = 1 / sqrt(1+(f/f_r)**2)\n",
      "Therefore,  |A_v| = |A_v(at resonance| / sqrt(1+(f/f_r)**2) =293.71\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"(i)  R_L = r_d || R_p\"\n",
    "print \"R_p = Tank circuit impedance at resonance = L / CR\"\n",
    "print \"f_r = 1 / 2*pi*sqrt(L*C)\"\n",
    "c=(1/(4*pi**2*200*1.59**2*10**6))*10**12\n",
    "print \"Therefore,  C = 1 / 4*pi**2*f_r**2*L =%0.2f pF\"%c\n",
    "print \"Q = omega_r*L / R = 2*pi*f_r*L / R\"\n",
    "r=(2*pi*200*1.59)/50\n",
    "print \"Therefore,  R = 2*pi*f_r*L / Q =%0.2f ohm\"%r\n",
    "rf=((200*10**-6)/(50*40*10**-12))*10**-3\n",
    "print \"R_F = L / C*R =%0.2f kohm\"%rf\n",
    "rl=(500*100)/600\n",
    "print \"R_L = r_d*R_p / r_d+R_p =%0.2f kohm\"%rl\n",
    "av=5*83.33\n",
    "print \"A_v = -g_m*R_L = %0.2f       at resonance frequency omega_r\"%av\n",
    "print \"(ii) At  f = f_r+10 kHz = 1.6 MHz\"\n",
    "print \"|A_v / A_v(at resonance)| = 1 / sqrt(1+(f/f_r)**2)\"\n",
    "ava=416.67/sqrt(1+((1.6/1.59)**2))\n",
    "print \"Therefore,  |A_v| = |A_v(at resonance| / sqrt(1+(f/f_r)**2) =%0.2f\"%ava"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.12 Page No. 5-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) Resonant frequency f_r = 1 / 2*pi*sqrt(L*C) =503292.12 kHz\n",
      "(ii) Tank circuit impedance at resonance can be given as\n",
      "R_P = L / C*R =20.00 kohm\n",
      "(iii)  A_v = -g_m*R_L = -g_m*(r_d||R_P) =-96.15\n",
      "(iv)  BW = f_r/Q\n",
      "      BW = f_r*R / omega_r*L    Therefore, Q = omega_r*L / R\n",
      "      BW = R / 2*pi*L =7.96 kHz\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "fr=1/(2*pi*sqrt(100*1000*10**-18))\n",
    "print \"(i) Resonant frequency f_r = 1 / 2*pi*sqrt(L*C) =%0.2f kHz\"%fr\n",
    "print \"(ii) Tank circuit impedance at resonance can be given as\"\n",
    "rp=((100*10**6)/5000)*10**-3\n",
    "print \"R_P = L / C*R =%0.2f kohm\"%rp\n",
    "av=(-5*10**-3)*((500*20*10**3)/(520))\n",
    "print \"(iii)  A_v = -g_m*R_L = -g_m*(r_d||R_P) =%0.2f\"%av\n",
    "bw=(5/(2*pi*100*10**-6))*10**-3\n",
    "print \"(iv)  BW = f_r/Q\"\n",
    "print \"      BW = f_r*R / omega_r*L    Therefore, Q = omega_r*L / R\"\n",
    "print \"      BW = R / 2*pi*L =%0.2f kHz\"%bw"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.13 Page No. 5-53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BW = f_r / Q\n",
      "Therefore,  Q = f_r / BW =53.50\n",
      "Q = omega_r*L / R = 2*pi*f_r*L / R\n",
      "Therefore,  L/R = Q / 2*pi*f_r =0.00\n",
      "|A_v| = g_m*R_L = 30\n",
      "Therefore,  R_L = (r_d || R_p) =6.00 kohm\n",
      "Therefore,  R_p = 6383 ohm\n",
      "We know that\n",
      "R_p = L/C*R\n",
      "Therefore,  C = 124.55 pF\n",
      "We know that\n",
      "f_r = 1 / 2*pi*sqrt(L*C)\n",
      "Therefore,  L = 1.78 uH\n",
      "We have\n",
      "R_p = L / C*R\n",
      "Therefore,  R = L / C*R_p =2.24 ohm\n",
      "Therefore, elements of tank circuit are:\n",
      "L = 1.777 uH,  C = 124.5 pF  and  R = 2.236 ohm\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division  \n",
    "print \"BW = f_r / Q\"\n",
    "q=10700/200\n",
    "print \"Therefore,  Q = f_r / BW =%0.2f\"%q\n",
    "print \"Q = omega_r*L / R = 2*pi*f_r*L / R\"\n",
    "lr=53.5/(2*pi*10.7*10**6)\n",
    "print \"Therefore,  L/R = Q / 2*pi*f_r =%0.2f\"%lr\n",
    "print \"|A_v| = g_m*R_L = 30\"\n",
    "rl=(30/5)\n",
    "print \"Therefore,  R_L = (r_d || R_p) =%0.2f kohm\"%rl\n",
    "print \"Therefore,  R_p = 6383 ohm\"\n",
    "print \"We know that\"\n",
    "print \"R_p = L/C*R\"\n",
    "c=((795*10**-9)/6383)*10**12\n",
    "print \"Therefore,  C = %0.2f pF\"%c\n",
    "print \"We know that\"\n",
    "l=(1/(4*pi**2*((10.7*10**6)**2)*124.5*10**-12))*10**6\n",
    "print \"f_r = 1 / 2*pi*sqrt(L*C)\"\n",
    "print \"Therefore,  L = %0.2f uH\"%l\n",
    "print \"We have\"\n",
    "print \"R_p = L / C*R\"\n",
    "r=(1.777*10**-6)/(6383*124.5*10**-12)\n",
    "print \"Therefore,  R = L / C*R_p =%0.2f ohm\"%r\n",
    "print \"Therefore, elements of tank circuit are:\"\n",
    "print \"L = 1.777 uH,  C = 124.5 pF  and  R = 2.236 ohm\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
