# Chapter 14: Special-purpose Op-amp cicuits

### Example 14.1, Page Number: 458

In [1]:
%matplotlib inline

Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.
In [2]:
R1=25*10**3;
R2=R1;
A_cl=500;    #closed loop voltage gain
R_G=2*R1/(A_cl-1);
print('value of the external gain setting resistor in ohms = %d'%R_G)

value of the external gain setting resistor in ohms = 100

### Example 14.2, Page Number: 460

In [3]:
R1=25.25*10**3;    #internal resistors
R2=R1;
R_G=510.0;
A_v=(2*R1/R_G)+1;
print('voltage gain = %f'%A_v)
BW=60.0*10**3;
print('bandwidth from graph = %d hertz'%BW)

voltage gain = 100.019608
bandwidth from graph = 60000 hertz

### Example 14.3, Page Number: 462

In [4]:
R_f1=22.0*10**3;
R_i1=2.2*10**3;
R_f2=47.0*10**3;
R_i2=10.0*10**3;
A_v1=(R_f1/R_i1)+1;    #voltage gain of input stage
A_v2=(R_f2/R_i2)+1;    #voltage gain of output stage
A_v=A_v1*A_v2;
print('total voltage gain of the isolation amplifier = %.1f'%A_v)

total voltage gain of the isolation amplifier = 62.7

### Example 14.5, Page Number: 466

In [5]:
g_m=1000.0*10**-6;
V_in=25*10**-3;
I_out=g_m*V_in;
print('output current = %f A'%I_out)

output current = 0.000025 A

### Example 14.6, Page Number: 468

In [6]:
V_BIAS=9.0;
V=V_BIAS;
R_BIAS=33.0*10**3;
R_L=10.0*10**3;
K=16.0;    #in microSiemens per microAmpere
I_BIAS=(V_BIAS-(-V)-1.4)/R_BIAS;
g_m=K*I_BIAS;
A_v=g_m*R_L;
print('voltage gain = %f'%A_v)

voltage gain = 80.484848

### Example 14.7, Page Number: 469

In [7]:
import pylab
import numpy

V_MOD_max=10.0;
V_MOD_min=1.0;
V=9.0;
V_in=50.0*10**-3;
R_BIAS=56.0*10**3;
R_L=10.0*10**3;
K=16.0;    #in microSiemens per microAmpere
I_BIAS_max=(V_MOD_max-(-V)-1.4)/R_BIAS;

g_m_max=K*I_BIAS_max;
A_v_max=g_m_max*R_L;
V_out_max=A_v_max*V_in;

I_BIAS_min=(V_MOD_min-(-V)-1.4)/R_BIAS;

g_m_min=K*I_BIAS_min;
A_v_min=g_m_min*R_L;
V_out_min=A_v_min*V_in;

###############PLOT#############################
f=1.0;    #assume frequency 1 hertz
t = arange(0.0001, 4.0, 0.0005)
y=(((V_out_max/4)-(V_out_min/4))*sin(2*pi*f*t)+((V_out_min/2)+(V_out_max/2))/2)*sin(2*9*pi*f*t);

plot(t,y)
plot(t,0.61*t/t,'r')
plot(t,-0.61*t/t,'r')
ylim( (-2,2) )
ylabel('Vout')
title('Modulated Output Voltage')

Out[7]:
<matplotlib.text.Text at 0xa98084c>

### Example 14.8, Page Number: 473

In [8]:
import math
V_in=2;
I_R=50.0*10**-9;
R1=100.0*10**3;
#voltage output for log amplifier
V_OUT=-0.025*math.log(V_in/(I_R*R1));
print('output voltage = %f volts'%V_OUT)

output voltage = -0.149787 volts

### Example 14.9, Page Number: 474

In [9]:
import math
V_in=3;
I_EBO=40*10**-9;
R1=68*10**3;
#voltage output for log amplifier
V_OUT=-0.025*math.log(V_in/(I_EBO*R1));
print('output voltage = %f Volts'%V_OUT)

output voltage = -0.175143 Volts

### Example 14.10, Page Number: 475

In [10]:
import math
I_EBO=40.0*10**-9;
V_in=175.1*10**-3;
R_f=68.0*10**3;
V_OUT=-I_EBO*R_f*math.exp(V_in/0.025);
print('output voltage = %f Volts'%V_OUT)

output voltage = -2.994797 Volts