# Chapter 2: Circuits With Resistive Feedback¶

## Example 2.1, Page 62¶

In :
import math

#Variable Declaration

R = 1.0      # Mega ohm
a = 200.0    # V/mV
rd = 2.0     # 2 MV
ro = 75.0    # ohm

#Calculation

T = a/(10**(-3))*rd*(10**6)/((rd*(10**6))+(R*(10**6))+ro)           # equation 2.2
A = (-1)/(1+1/T)
Ri = rd*(10**6)*((R*(10**6))+ro)/((rd*(10**6))+(R*(10**6))+ro)/(1+T) # equation 2.3
Ro = ro/(1+T)                                                        # equation 2.3

print "T =",int(round(T))
print "A =",round(A,7),"V/micro Ampere"
print "Ri =",round(Ri),"ohm"
print "Ro =",round(Ro*(10**5)),"mili ohm"

# answer of A has precision error in the book

T = 133330
A = -0.9999925 V/micro Ampere
Ri = 5.0 ohm
Ro = 56.0 mili ohm


## Example 2.2, Page 62¶

In :
import math

#Variable Declaration

kR = 0.1/(10**(-9))      # ohm
R = 1*(10**6)            # High starting value of R
R1 = 1*(10**3)           # Assumption

#Calculation

R2 = (100-1)*R*R1/(R+R1)   # equation 2.4b

print "One possible combination is:"
print "  R1 =",R1/(10**3),"kilo ohm"
print "  R2 =",R2/(10**3),"kilo ohm (100 closest standard)"

One possible combination is:
R1 = 1 kilo ohm
R2 = 98 kilo ohm (100 closest standard)


## Example 2.3, Page 65¶

In :
#Variable Declaration

vt = 5.0     # V
R = 10.0     # kilo ohm
Vsat1 = 13.0  # V
Vsat2 = -13.0  # V

#Calculation

io = vt/R                # equation 2.6
Vl1 = Vsat1-vt           # vo = vt + vl
Vl2 = Vsat2-vt
Rl1 = Vl1/io
Rl2 = Vsat1/io

print "a)\n  Io =",io,"mA, flowing from left to right in Fig. 2.4a and right to left in Fig. 2.4b"
print "b)\n  For Fig. 2.4a ",Vl2,"< VL <",Vl1,"and for Fig. 2.4b ",Vsat2,"< VL <",Vsat1
print "c)\n  For Fig. 2.4a RL <",Rl1,"kilo ohm and for Fig. 2.4b RL <",Rl2,"kilo ohm"

a)
Io = 0.5 mA, flowing from left to right in Fig. 2.4a and right to left in Fig. 2.4b
b)
For Fig. 2.4a  -18.0 < VL < 8.0 and for Fig. 2.4b  -13.0 < VL < 13.0
c)
For Fig. 2.4a RL < 16.0 kilo ohm and for Fig. 2.4b RL < 26.0 kilo ohm


## Example 2.4, Page 67¶

In :
#Variable Declaration

Vt = 15.0        # V
Io = 1.0         # mA

#Calculation

R1 = Vt/Io             # equation 2.10
R3 = R1
R2 = (13.0/10*R1)-R1
R4 = R2

print "R1 =",R1,"Kilo ohm"
print "R2 =",R2,"Kilo ohm"
print "R3 =",R3,"Kilo ohm"
print "R4 =",R4,"Kilo ohm"

R1 = 15.0 Kilo ohm
R2 = 4.5 Kilo ohm
R3 = 15.0 Kilo ohm
R4 = 4.5 Kilo ohm


## Example 2.5, Page 68¶

In :
import math

#Variable Declaration

R1=15*10**3      #From the result of Example 2.4
p=0.01           #For 1% tolerance p=t /100=1/100=0.01

#Calculation

emax=4*p         #imbalace factor
Romina=R1/emax
p=0.001
emax=4*p         #imbalace factor
Rominb=R1/emax
Romin=50*10**6
emax=float(R1)/Romin
p=emax/4
pper=p*100

print "a)\n  Ro can be anywhere in the range Ro >=",round(Romina*10**(-3),2),"kilo ohm"
print "b)\n  Ro can be anywhere in the range Ro >=",round(Rominb*10**(-6),2),"mega ohm"
print "c)\n  Resistance tolerance Required =",round(pper,5),"%"

a)
Ro can be anywhere in the range Ro >= 375.0 kilo ohm
b)
Ro can be anywhere in the range Ro >= 3.75 mega ohm
c)
Resistance tolerance Required = 0.0075 %


## Example 2.6, Page 69¶

In :
import math

#Variable Declaration

p = 0.01
R1 = 15     # kilo ohm

#Calculation

Rs = round(R1-4.0*p*R1)                   #Rs must be smaller than R1 by 4pR1
Rpot = 2*(R1-Rs)

print "Rpot =",Rpot,"Kilo ohm"
print "Rs =",Rs,"Kilo ohm"

Rpot = 2.0 Kilo ohm
Rs = 14.0 Kilo ohm


## Example 2.7, Page 70¶

In :
import math

#Variable Declaration

a = 200
R1 = 15.0              #kilo ohm
R2 = 3.0               #kilo ohm

#Calculation

Ro = (R1*R2/(R1+R2))*(1+(a/(1+(R2/R1))))

print "Output Resistance =",round(Ro),"Mega ohm"

#Answer is 417 in book cause of precision loss

Output Resistance = 419.0 Mega ohm


## Example 2.8, Page 74¶

In :
import math

#Variable Declaration

R1 = R3 = 10.0     #kilo ohm
R2= R4 = 100.0    #kilo ohm

#Calculation

def find_Vo(V1,V2):
global R1,R2;
Vo = R2/R1*(V2-V1)
return Vo

def find_Vo_mismatched(V1,V2):
global R1,R2,R3,R4
A1 = R2/R1
A2 = (1+A1)/(1+R3/R4)
Vo = (A2*V2)-(A1*V1)
return Vo

print "a)"
print "  Input voltage pair(-0.1V,+0.1V), Vo =",find_Vo(-0.1,0.1),"V"
print "  Input voltage pair(4.9V,5.1V), Vo =",find_Vo(4.9,5.1),"V"
print "  Input voltage pair(9.9V,10.1V), Vo =",find_Vo(9.9,10.1),"V"

R1 = 10      #kilo ohm
R2 = 98      #kilo ohm
R3 = 9.9     #kilo ohm
R4 = 103     #kilo ohm

print "b"
print "  Input voltage pair(-0.1V,+0.1V), Vo =",round(find_Vo_mismatched(-0.1,0.1),3),"V"
print "  Input voltage pair(4.9V,5.1V), Vo =",round(find_Vo_mismatched(4.9,5.1),3),"V"
print "  Input voltage pair(9.9V,10.1V), Vo =",round(find_Vo_mismatched(9.9,10.1),3),"V"

a)
Input voltage pair(-0.1V,+0.1V), Vo = 2.0 V
Input voltage pair(4.9V,5.1V), Vo = 2.0 V
Input voltage pair(9.9V,10.1V), Vo = 2.0 V
b
Input voltage pair(-0.1V,+0.1V), Vo = 1.812 V
Input voltage pair(4.9V,5.1V), Vo = 2.428 V
Input voltage pair(9.9V,10.1V), Vo = 3.043 V


## Example 2.9, Page 76¶

In :
import numpy as np
from sympy import Symbol
from sympy.solvers import solve
import math

#Variable Declaration

p = 0.01
R1 = R3 = 10.0    #kilo ohm
R2= R4 = 100.0    #kilo ohm
Vcm = 10          # V
new_CMRR = 80.0   # dB

#Calculation

Emax = 4*p
Adm = round(R2/R1*(1-((R1+(2*R2))/(R1+R2)*Emax/2)),2)      #equation 2.24b
Acm = round(R2/(R1+R2)*Emax,4)                                      #equation 2.24c
CMRRdb =round(20*np.log10((1+(R2/R1)/Emax)),1)                  #equation 2.26
Vo = Acm*Vcm
x = Symbol('x')
st = 10**(new_CMRR/20.0)
ans = solve (st*x-1-(R2/R1),x)

print "a)"
print "  Adm =",Adm,"V/V\n  Acm =",Acm,"V/V\n  CMRRdb =",CMRRdb,"dB"
print "b)"
print "  Vo =",Vo,"V"
print "c)"
print "  p =",round(ans/4*100,4),"%"

#part a, CMMRdb value is 48.4 in book

a)
Adm = 9.62 V/V
Acm = 0.0364 V/V
CMRRdb = 48.0 dB
b)
Vo = 0.364 V
c)
p = 0.0275 %


## Example 2.10, Page 80¶

In :
from sympy import Symbol
from sympy.solvers import solve
import math

#Variable Declaration

Amin=1.0           #V/V
Amax=10**3         #V/V

#Calculation

AI=0.5
R1=100*10**3          # Tolerance (1%)
R2=AI*R1              # Tolerance (1%)
AImin=Amin/AI
AImax=Amax/AI
#AImin<=AI<=AImax
#AImin=1+((2∗R3) /(R4+R1) ) −> 1+((2∗R3) /(R4+R1) )− Amin=0 −> (1−AImin)∗R4+2∗R3+(1−AImin)∗R1=0...( i )
#and AImax=1+((2∗R3) /(R4+0)) −>(1−AImax)∗R4+2∗R3 =0 ... .( i i )
#Solving these two equations will give R3 and R4
x=Symbol('x')
y=Symbol('y')
ans=solve([(1-AImin)*y+2*x+(1-AImin)*R1,(1-AImax)*y+2*x],[x,y])
R3=ans[x]
R4=ans[y]
p=0.01
e=4*p*R2
R5=100*10**3
R2red=R2-e-500           # to be on the safer side 0.5 kohms more is reduced
Rpot=2*(R2-R2red)        #Potentiometer Resistance

print "a)\n  Designed Instrumentation Amplifier : "
print "  R1 =",round(R1*10**(-3),2),"kilo ohm"
print "  R2 =",round(R2*10**(-3)-0.1,2),"kilo ohm"
print "  R3 =",round(R3*10**(-3)),"kilo ohm"
print "  R4 =",round(R4),"ohm"
print "b)\n  Designed Instrumentation Amplifier with trimmed resistances : "
print "  R1 =",round(R1*10**(-3),2),"kilo ohm"
print "  R2 =",round(R2*10**(-3)-0.1,2),"kilo ohm"
print "  R3 =",round(R3*10**(-3)),"kilo ohm"
print "  R4 =",round(R4),"ohm"
print "  R5 =",round(R5*10**(-3)),"kilo ohm"
print "  R6 =",round(R2red*10**(-3),2),"kilo ohm"
print "  R7 =",round(Rpot*10**(-3),2),"kilo ohm"
print "c)\n  To calibrate the circuit , tie the inputs together and set the 100 kilo ohm pot for the "
print "  maximum gain (wiper allthe way up). Then , switching the common inputs back and forth between −5V and +5V,"
print "  adjust the 5 kilo ohm pot for the minimum change at the output . "

a)
Designed Instrumentation Amplifier :
R1 = 100.0 kilo ohm
R2 = 49.9 kilo ohm
R3 = 50.0 kilo ohm
R4 = 50.0 ohm
b)
Designed Instrumentation Amplifier with trimmed resistances :
R1 = 100.0 kilo ohm
R2 = 49.9 kilo ohm
R3 = 50.0 kilo ohm
R4 = 50.0 ohm
R5 = 100.0 kilo ohm
R6 = 47.5 kilo ohm
R7 = 5.0 kilo ohm
c)
To calibrate the circuit , tie the inputs together and set the 100 kilo ohm pot for the
maximum gain (wiper allthe way up). Then , switching the common inputs back and forth between −5V and +5V,
adjust the 5 kilo ohm pot for the minimum change at the output .


## Example 2.11, Page 92¶

In :
import math
import sympy

#Variable Declaration

alpha = 0.00392    # per degree celsius
R0 = 100           # ohm
delT = 10.0          # degree celsius
#Calculation

T = Symbol('T')
expr = R0*(1+alpha*T)

def find_R(t):
global T,expr
return expr.subs(T,t)

delR = R0*alpha*delT
delta = alpha*delT*100

print "a)"
print "  R(T) =",expr
print "b)"
print "  R(25 degree celsius) =",round(find_R(25),1),"ohm"
print "  R(100 degree celsius) =",round(find_R(100),1),"ohm"
print "  R(-15 degree celsius) =",round(find_R(-15),2),"ohm"
print "c)"
print "  Change in R =",delR,"ohm"
print "  Delta =",delta,"%"

a)
R(T) = 0.392*T + 100
b)
R(25 degree celsius) = 109.8 ohm
R(100 degree celsius) = 139.2 ohm
R(-15 degree celsius) = 94.12 ohm
c)
Change in R = 3.92 ohm
Delta = 3.92 %


## Example 2.12, Page 93¶

In :
from sympy import Symbol
from sympy.solvers import solve
import math

#Variable Declaration

PRTD = 0.2      # mW
R = 100         # ohm
Vref = 15       # V
delVo = 0.1     # V
delT = 1.0      # degree celsius
alpha = 0.00392

#Calculation

#part a)

i = round(math.sqrt(PRTD/1000/R)*1000)
R1 = Vref/i
delta = alpha*delT
x = Symbol('A')
A = solve(x*(delta*Vref/(2+(R/R1/1000)+(R1/R*1000)))-delVo,x)              # equation 2.47

#part b)

delT = 100
delta = alpha*delT
Vo1 = round(A*Vref*delta/(1+(R1/R*1000)+((1+(R/R1/1000))*(1+delta))),3) # equation 2.46
Vo2 = round(A*Vref*delta/(2+(R/R1/1000)+(R1/R*1000)))
error = (Vo2-Vo1)/delVo

print "a)"
print "  R1 =",R1,"kilo ohm\n  A =",round(A,1),"V/V"
print "b)"
print "  Error =",error,"degree celsius"

a)
R1 = 15.0 kilo ohm
A = 258.5 V/V
b)
Error = 0.26 degree celsius


## Example 2.14, Page 96¶

In :
import math

#Variable Declaration

R = 120              #ohm
i = 20*(10**(-3))    # A
Vref = 15            # V

#Calculation

Vb = 2*R*i
v1 = 0.01*Vb/2+Vb/2
v2 = -0.01*Vb/2+Vb/2
ir1 = (v1-v2)/R*2*1000
R1 = Vb/2/ir1
R2 = 1                    # kilo ohm,  Assumption
ir3 = round((2*i+Vb/1000)*1000)
R3 = round(2/ir3*1000)
R4 = round((Vref-(25*ir3/1000)-Vb)/(ir3/1000))


a)