diff options
Diffstat (limited to 'Electronic_Devices_by_T_L_Floyd/13-Basic_Opamp_Circuits.ipynb')
-rw-r--r-- | Electronic_Devices_by_T_L_Floyd/13-Basic_Opamp_Circuits.ipynb | 376 |
1 files changed, 376 insertions, 0 deletions
diff --git a/Electronic_Devices_by_T_L_Floyd/13-Basic_Opamp_Circuits.ipynb b/Electronic_Devices_by_T_L_Floyd/13-Basic_Opamp_Circuits.ipynb new file mode 100644 index 0000000..9b762b7 --- /dev/null +++ b/Electronic_Devices_by_T_L_Floyd/13-Basic_Opamp_Circuits.ipynb @@ -0,0 +1,376 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 13: Basic Opamp Circuits" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.1: Comparator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.1\n", +"R2=1*10^3;\n", +"R1=8.2*10^3;\n", +"V=15;\n", +"V_REF=R2*V/(R1+R2);\n", +"disp(V_REF,'V_REF in volts')\n", +"V_max=12; //maximum output level of op-amp\n", +"V_min=-12; //minimum output voltage of comparator\n", +"f=1; //assume frequency of input wave to be 1 hertz\n", +"t=0:0.001:3;\n", +"V_in=5*sin(2*%pi*f.*t)\n", +"clf();\n", +"subplot(121)\n", +"xtitle('Input to comparator-1')\n", +"plot(t,V_in)\n", +"subplot(122)\n", +"xtitle('Output of Comparator-1')\n", +"a=bool2s(V_in>=V_REF)\n", +"b=~a;\n", +"y=V_max*a+V_min*b;\n", +"plot(t,y)\n", +"disp(V_max,'max output voltage in volts')\n", +"disp(V_min,'min output voltage in volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.2: Trigger_points.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.2\n", +"R1=100*10^3;\n", +"R2=R1;\n", +"V_out_max=5;\n", +"V_UTP=R2*V_out_max/(R1+R2);\n", +"V_LTP=-V_out_max*R2/(R1+R2);\n", +"disp(V_UTP,'upper trigger point in volts')\n", +"disp(V_LTP,'lower trigger point in volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.3: Comparator_hysteris_Zener_bounding.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.3\n", +"R1=100*10^3;\n", +"R2=47*10^3;\n", +"V_R1=4.7+0.7; //one zener is always forward biased with forward voltage 0.7V \n", +"//V_R1 can be positive or negative\n", +"I_R1=V_R1/R1; \n", +"I_R2=I_R1;\n", +"V_R2=R2*I_R2;\n", +"V_out=V_R1+V_R2; //positive or negative\n", +"V_UTP=R2*V_out/(R1+R2);\n", +"V_LTP=-V_out*R2/(R1+R2);\n", +"f=1; //assume frequency of input as 1 Hertz\n", +"t=0:0.001:1;\n", +"T=1/f;\n", +"V_in=5*sin(2*%pi*f.*t)\n", +"subplot(121)\n", +"xtitle('Input to comparator-2')\n", +"plot(t,V_in)\n", +"subplot(122)\n", +"xtitle('Output of Comparator-2')\n", +"t1=(1/(2*%pi*f))*asin((V_UTP/5))\n", +"a=bool2s(t<t1)\n", +"b=bool2s(t>((T/2)+t1))\n", +"a=bool2s(a|b)\n", +"b=~a;\n", +"y=V_out*a-V_out*b;\n", +"plot(t,y)\n", +"disp(V_out,'max output voltage in volts')\n", +"disp(-V_out,'min output voltage in volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.4: Summing_amplifier_unity_gain.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.4\n", +"V_IN1=3;\n", +"V_IN2=1;\n", +"V_IN3=8;\n", +"//all resistors are of equal value so weight of each input is 1\n", +"V_OUT=-(V_IN1+V_IN2+V_IN3);\n", +"disp(V_OUT,'output voltage in volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.5: Summing_amplifier.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.5\n", +"R_f=10*10^3;\n", +"R1=1*10^3;\n", +"R2=R1;\n", +"R=R1;\n", +"V_IN1=0.2;\n", +"V_IN2=0.5;\n", +"V_OUT=-(R_f/R)*(V_IN1+V_IN2);\n", +"disp(V_OUT,'output voltage of the summing amplifier in volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.6: Averaging_amplifier.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.6\n", +"R_f=25*10^3;\n", +"R1=100*10^3;\n", +"R2=R1;\n", +"R3=R1;\n", +"R4=R1;\n", +"R=R1;\n", +"V_IN1=1;\n", +"V_IN2=2;\n", +"V_IN3=3;\n", +"V_IN4=4;\n", +"V_OUT=-(R_f/R)*(V_IN1+V_IN2+V_IN3+V_IN4);\n", +"disp(V_OUT,'output voltage in volts')\n", +"V_IN_avg=(V_IN1+V_IN2+V_IN3+V_IN4)/4;\n", +"if abs(V_OUT)==V_IN_avg then\n", +" disp('the amplifier produces an output whose magnitude is the mathematical average of the input voltages')\n", +"end" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.7: Scaling_adder.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.4\n", +"V_IN1=3;\n", +"V_IN2=2;\n", +"V_IN3=8;\n", +"R_f=10*10^3;\n", +"R1=47*10^3;\n", +"R2=100*10^3;\n", +"R3=10*10^3;\n", +"weight_of_input1=R_f/R1;\n", +"weight_of_input2=R_f/R2;\n", +"weight_of_input3=R_f/R3;\n", +"V_OUT=-(weight_of_input1*V_IN1+weight_of_input2*V_IN2+weight_of_input3*V_IN3);\n", +"disp(weight_of_input1,'weight_of_input1')\n", +"disp(weight_of_input2,'weight_of_input2')\n", +"disp(weight_of_input3,'weight_of_input3')\n", +"disp(V_OUT,'output voltage in volts')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.8: Opamp_integrator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.8\n", +"R_i=10*10^3;\n", +"C=0.01*10^-6;\n", +"V_in=2.5-(-2.5);\n", +"PW=100*10^-6; //pulse width\n", +"T=2*PW;\n", +"A=2.5;\n", +"op_change_cap_charge=-V_in/(R_i*C);\n", +"op_change_cap_discharge=V_in/(R_i*C);\n", +"disp(op_change_cap_charge,'rate of change of output voltage with respect to time when capacitor is charging (in Volts per sec)')\n", +"disp(op_change_cap_discharge,'rate of change of output voltage with respect to time when capacitor is discharging (in Volts per sec)')\n", +"del_V_OUT=op_change_cap_discharge*PW;\n", +"disp(-del_V_OUT,'when input is positive, the slope is negative, when input is negative , the slope is negative. So, the output is a triangular wave varying from zero to')\n", +"subplot(121)\n", +"xtitle('input voltage of op-amp differentiator')\n", +"t=0:10^-7:2*T;\n", +"a=bool2s(t>=T/2 & t<=T)\n", +"b=bool2s(t>=1.5*T & t<=2*T)\n", +"a=bool2s(a|b)\n", +"b=~a;\n", +"y=-A*b+A*a;\n", +"plot(t,y)\n", +"subplot(122)\n", +"xtitle('output voltage of op-amp diferentiator')\n", +"x=[];\n", +"A=del_V_OUT;\n", +"for t=0:10^-7:2*T \n", +" tcor = t- floor(t/T)*T;\n", +" if tcor >= 0 & tcor < (T/2) then\n", +" x_temp = -A +(2*A/T)*tcor;\n", +" end; \n", +" if tcor >= (T/2) & tcor <T then\n", +" x_temp = A - (2*A/T)*tcor;\n", +" end\n", +" x = [x, x_temp];\n", +" end;\n", +"t=0:10^-7:2*T;\n", +"plot(t,x)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 13.9: Opamp_differentiator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//ex13.9\n", +"R_f=2.2*10^3;\n", +"C=0.001*10^-6;\n", +"Vc=5-(-5);\n", +"A=5;\n", +"time_const=R_f*C;\n", +"T=10*10^-6;\n", +"t=T/2;\n", +"slope=Vc/t;\n", +"V_out=slope*time_const; //V_out is negative when input is positive and V_out is positive when input is negative\n", +"disp(V_out,'output voltage in volts is a square wave with peak voltages positive and negative of')\n", +"subplot(121)\n", +"xtitle('input voltage for integrator op-amp')\n", +"x=[];\n", +"for t=0:10^-8:2*T\n", +" tcor = t- floor(t/T)*T;\n", +" if tcor >= 0 & tcor < (T/2) then\n", +" x_temp = -A +(4*A/T)*tcor;\n", +" end; \n", +" if tcor >= (T/2) & tcor <T then\n", +" x_temp = 3*A - (4*A/T)*tcor;\n", +" end\n", +" x = [x, x_temp];\n", +" end;\n", +" t=0:10^-8:2*T;\n", +" plot(t,x)\n", +"subplot(122)\n", +"xtitle('output voltage of differentiator op-amp')\n", +"a=bool2s(t>=T/2 & t<=T)\n", +"b=bool2s(t>=1.5*T & t<=2*T)\n", +"a=bool2s(a|b)\n", +"b=~a;\n", +"y=V_out*a-V_out*b;\n", +"plot(t,y)\n", +"disp(V_out,'max output voltage in volts')\n", +"disp(-V_out,'min output voltage in volts')" + ] + } +], +"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 +} |