%matplotlib inline
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)
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)
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)
g_m=1000.0*10**-6;
V_in=25*10**-3;
I_out=g_m*V_in;
print('output current = %f A'%I_out)
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)
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')
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)
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)
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)