from __future__ import division
# Given data
A_V = -100
R1 = 2.2 # in kohm
R1 = R1*10**3 # in ohm
R_f =-( A_V*R1) # in ohm
R_f = R_f * 10**-3 # in kohm
print "The resistance value = %0.f kΩ" %R_f
# Given data
R_f = 200 # in kohm
R1 = 2 # in kohm
A_V = - (R_f/R1)
V_in = 2.5 # in mV
V_in= V_in*10**-3 # in V
V_o = (A_V * V_in) # in V
print "The output voltage = %0.2f V" %V_o
# Given data
V1 = 2 # in V
R_f = 500 # in kohm
R_f = R_f*10**3 # in ohm
R1 = 100 # in kohm
R1 = R1 * 10**3 # in ohm
V_o = (1+(R_f/R1))*V1 # in V
print "The output voltage = %0.f V" %V_o
# Given data
R_f = 1 # in Mohm
R_f = R_f * 10**6 # in ohm
print "Part (a)"
V1 = 1 # in V
V2 = 2 # in V
V3 = 3 # in V
R1 = 500 # in kohm
R1 = R1 * 10**3 # in ohm
R2 = 1 # in Mohm
R2 = R2 * 10**6 # in ohm
R3 = 1 # in Mohm
R3 = R3 * 10**6 # in ohm
V_o = -(R_f) * ( (V1/R1)+(V2/R2)+(V3/R3) ) # in V
print "The output voltage = %0.f V" %V_o
print "Part (b)"
V1 = -2 # in V
V2 = 3 # in V
V3 = 1 # in V
R1 = 200 # in kohm
R1 = R1 * 10**3 # in ohm
R2 = 500 # in kohm
R2 = R2 * 10**3 # in ohm
R3 = 1 # in Mohm
R3 = R3 * 10**6 # in ohm
V_o = -(R_f) * ( (V1/R1)+(V2/R2)+(V3/R3) ) # in V
print "The output voltage = %0.f V" %V_o
# Given data
R_f = 0 # in V
R1 = 2 # in kohm
R1 = R1 * 10**3 # in ohm
A_vmin = (1+(R_f/R1))
print "The minimum closed loop voltage gain = %0.f" %A_vmin
R_f1 = 100 # in kohm
R_f1 = R_f1 * 10**3 # in ohm
A_vmax = (1+(R_f1/R1))
print "The maximum closed loop voltage gain = %0.f" %A_vmax
# Given data
V1 = 745 # in µV
V1 = V1 * 10**-6 # in V
V2 = 740 # in µV
V2 = V2 * 10**-6 # in V
Av = 5*10**5
CMRR = 80 # in dB
# Formula CMRR in dB= 20*log(Av/Ac)
Ac= Av/(10**(CMRR/20))
print "The common mode gain = %0.2f" %Ac
V_o = Av*(V1-V2)+Ac*((V1+V2)/2) # in V
print "The output voltage = %0.2f V" %V_o
# Note: In the book the calculation of finding the value of common mode gain (i.e. Ac) is wrong,
# so the answer in the book is wrong
# Given data
R_f = 1 # in Mohm
R_f = R_f * 10**6 # in ohm
Ri= 1*10**6 # in ohm
R1 = Ri # in ohm
A_VF = -(R_f/R1)
print "The Voltage gain = %0.f" %A_VF
# Given data
R_F = 3 # in kohm
R1 = 1 # in kohm
V1 = 2 # in V
V2 = 3 # in V
V_o1 = (1+(R_F/R1))*V1 # in V
V_o2 = (1+(R_F/R1))*V2 # in V
V_o = V_o1+V_o2 # in V
print "The output voltage = %0.f V" %V_o
# Given data
R_i = 10 # in kΩ
R_im = 20 # in kΩ
R_f = 500 # in kΩ
A_vmin = -(R_f/R_i)
print "Closed loop voltage gain corresponding to minimum resistance = %0.f" %A_vmin
A_vmax = -(R_f/R_im)
print "Closed loop voltage gain corresponding to maximum resistance = %0.f" %A_vmax
# Given data
R_f = 200 # in kohm
R1 = 20 # in kohm
A_v = -(R_f/R1)
V_i = 0.1 # in V
V_im = 0.5 # in V
V_omin = -10*V_i # in V
print "The minimum output voltage = %0.f V" %V_omin
V_omax = -10*V_im # in V
print "The maximum output voltage = %0.f V" %V_omax
print "Output voltage ranges : from",int(V_omin,),"to",int(V_omax)
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
# Given data
R = 133 # in kohm
R = R *10**3 # in ohm
C = 0.1 # in µF
C = 0.1 * 10**-6 # in F
Vi= 15 # in V
plt.subplot(2,1,1)
plt.plot([0,10],[1.5,1.5])
plt.ylabel("Vi in volts")
plt.xlabel("t")
plt.title("Input voltage")
t=np.arange(0,1,0.1)
Vo= -1/(R*C)*t
plt.subplot(2,1,2)
plt.plot(t,Vo)
plt.xlabel("t")
plt.ylabel("Vo in volts")
plt.title("Output voltage")
print ""
# Given data
Rf = 250 # in kohm
Vo= '-5*Va+3*Vb' # given expression
# But output voltage of difference amplifier is
# Vo= -Rf/R1*Va+(R2/(R1+R2))*(1+Rf/R1)*Vb (i)
# By comparing (i) with given expression
R1 = Rf/5 # in kohm
print "The value of R1 = %0.f kΩ" %R1
# (R2/(R1+R2))*(1+Rf/R1)= 3
R2= 3*R1**2/(R1+Rf-3*R1) # in kΩ
print "The value of R2 = %0.f kΩ" %R2
# Note: There is calculation error to find the value of R2 in the book.
# Given data
V_i1 = 150 # in µV
V_i2 = 140 # in µV
V_d = V_i1-V_i2 # in µV
V_C = (1/2)*(V_i1+V_i2) # in µV
print "Part (i)"
CMRR = 100
A_d = 4000
V_o = (A_d * V_d)*(1+(1/CMRR)*(V_C/V_d)) # in µV
V_o = V_o * 10**-3 # in mV
print "The output voltage = %0.1f mV" %V_o
print "Part(ii)"
CMRR = 10**5
V_o = (A_d * V_d)*(1+(1/CMRR)*(V_C/V_d)) # in µV
V_o = V_o * 10**-3 # in mV
print "The output voltage = %0.3f mV" %V_o
# Given data
R_f = 470 # in kΩ
R1 = 4.3 # in kΩ
R2 = 33 # in kΩ
R3 = R2 # in kΩ
A1 = (1+R_f/R1)
A2 = -(R_f/R2)
A3 = -(R_f/R3)
A = A1*A2*A3
V_i = 80 # in µV
V_i= 80*10**-6 # in V
V_o = A*V_i
print "The output voltage = %0.2f V" %V_o
# Given data
R4 = 300 # in kΩ
R2 = 150 # in kΩ
R3 = 10 # in kΩ
R1 = 10 # in kΩ
V1 = 1 # in V
V2 = 2 # in V
V_o = ( (1+(R4/R2))*((R3/(R1+R3))*V1)-((R4/R2)*V2) ) # in V
print "The output voltage = %0.1f V" %V_o
# Given data
V_o = 2 # in V
R_i = 20 # in kΩ
R_f = 1 # in MΩ
V_i = -((V_o*R_i)/R_f) # in mV
print "The input volatge = %0.f mV" %V_i
# Given data
R_f = 200 # in kΩ
R_i = 30 # in kΩ
V_i = 0.1 # in V
V_im = 0.5 # in V
Vo_min = -((R_f/R_i)*V_i) # in V
print "The minimum output voltage = %0.2f V" %Vo_min
Vo_max = -((R_f/R_i)*V_im) # in V
print "The minimum output voltage = %0.2f V" %Vo_max
print "The output voltage range is : ",round(Vo_min,2),"V to",round(Vo_max,2),"V"
# Given data
R_f = 360 # in kohm
R_i = 12 # in kohm
V1 = - 0.3 # in V
V_o = (1+(R_f/R_i))*V1 # in V
print "The output voltage = %0.1f V" %V_o
V_o1 = 2.4 # in V
V_i = V_o1/(1+(R_f/R_i)) # in V
print "The input voltage = %0.2f mV" %(V_i*10**3)
# Given data
R_f = -68 # in kohm
R1 = 33 # in kohm
R2 = 22 # in kohm
R3 = 12 # in kohm
V1 = 0.2 # in V
V2 = - 0.5 # in V
V3 = 0.8 # in V
V_o = ((R_f/R1)*V1) + ((R_f/R2)*V2) + ((R_f/R3)*V3) # in V
print "The output voltage = %0.3f V" %V_o
# Given data
R_f = 1.8 # in kohm
R_f = R_f * 10**3 # in ohm
R1 = 180 # in ohm
A_v = (R_f/R1)
print "Closed loop gain = %0.f" %A_v
F = 1 # in MHz
F = F * 10**6 # in Hz
f2 = F/A_v # in Hz
print "Closed loop bandwidth = %0.f Hz" %f2
V_in = 25 # in mV
V_in = V_in * 10**-3 # in V
V_o = A_v*V_in # in V
print "The output voltage = %0.2f V" %V_o
from __future__ import division
# Given data
R_f = 3 # in K ohm
R_f = R_f * 10**3 # in ohm
R1 = 150 # in ohm
A_v = (R_f/R1) + 1
print "Close loop gain for inverting amplifier = %0.f" %A_v
f = 1 # in MHz
f = f * 10**6 # in Hz
f2 = f/A_v # in Hz
f2 = f2 * 10**-3 # in KHz
print "The closed loop bandwidth = %0.2f KHz" %f2