Chapter 2: Measurement Of Electrical Quantities

Example2_1,pg 23

In [1]:
# output voltage 

import math
#Variable declaration
ic=1*10**-3                     #constant current source
Rf=15*10**3                     #feedback resistance
Rs=10*10**3                     #input resistance
Rx=1.0*10**3                    #unknown resistance
R1=10.0                         #unknown resistance
R2=1*10**3                      #input resistance

#Calculations

# for fig. 2.7
Vo1=ic*Rf*(Rx/(1+(Rx*Rs)))      #output voltage case-1
#for fig. 2.8
Vo2=ic*Rx*(R1/(1+R1*R2))        #output voltage case-2

#Result
print("output voltage for case-1:")
print("Vo1 = %.4f V\n"%Vo1)
print("output voltage for case-2:")
print("Vo2 = %.0f mV\n"%(Vo2*10**3))
#Answer for case-1 is different in the book
output voltage for case-1:
Vo1 = 0.0015 V

output voltage for case-2:
Vo2 = 1 mV

Example2_2,pg 27

In [3]:
# find Ad CMRR and Acm

import math
#Variable declaration
V1=5.0                      #input-1
V2=5.0                      #input-2
V12=50*10**-3               #difference input
Vo=2.0                      #output voltage
acc=0.01                    #accuracy

#Calculations
Ad=(Vo/V12)                 #diffrential gain
#error at the output should be less than (2/100)V or 20mV.if common mode gain is the only source of error then 
err=Vo*acc                  #error
Acm=(err/V1)                #common mode gain
CMRR=20*math.log10(Ad/Acm)  #common mode rejection ratio in dB

#Result
print("diffrential gain:")
print("Ad=%.1f \n"%Ad)
print("common mode gain:")
print("Acm=%.4f "%Acm)
print("\nCMRR=%.1f dB\n"%CMRR)
diffrential gain:
Ad=40.0 

common mode gain:
Acm=0.0040 

CMRR=80.0 dB

Example2_3,pg 484

In [8]:
# find full scale output and minimum input

import math
#Variable declaration
Aol=1.0*10**5              #open loop gain
R2=10.0*10**3              #Resistor R2
R3=10.0*10**3              #Resistor R3
R1=100*10**3               #input resistance
Vac=24.0                   #maximum input

#Calculations
Vo=(R2/R1)*Vac             #output full scale
Vth=0.6                    #threshold voltage
Vn=(Vth/Aol)               #minimum input

#Result
print("output FS voltage:")
print("Vo = %.2f V\n"%Vo)
print("minimum input voltage:")
print("Vn = %.1f micro-V\n"%(Vn*10**6))
#Answer for Vn is wrong in the book
output FS voltage:
Vo = 2.40 V

minimum input voltage:
Vn = 6.0 micro-V

Example2_4,pg 484

In [10]:
# output voltage

import math
#Variable declaration
Vp=1.0                    #peak input voltage
f=50.0                    #frequency
#R1=R2

#Calculations
#since halfwave rectification is done,integration gives the value
pi =math.floor(math.pi*100)/100
Vo=0.5*((2*Vp)/pi)         #output voltage,pi=3.14 

#Result
print("output voltage:")
print("Vo = %.3f V\n"%Vo)
output voltage:
Vo = 0.318 V

Example2_5,pg 484

In [12]:
# find unknown resistance

import math
#VBariable declaration
ic=0.1*10**-3               #constant current source
Vo=2.0                      #output voltage
Rf=22.0*10**3               #feedback resistance
Rs=10.0*10**3               #input resistance

#Calculations
Rx=(1/(((ic*Rf)/(Vo*Rs))-(1/Rs)))

#Result
print("unknown resistance:")
print("Rx = %.0f k-ohm\n"%(Rx/1000))
unknown resistance:
Rx = 100 k-ohm

Example2_6,pg 484

In [13]:
# find CMRR

import math
#Variable declaration
a=0.9                           #parameter of diff. amplr.
b=1.1                           #parameter of diff. amplr.

#Calculations
CMRR=0.5*(((1+a)*b+(1+b)*a))/((1+a)*b-(1+b)*a)

#Results
print("CMRR = %.2f"%CMRR)
CMRR = 9.95

Example2_7,pg 485

In [15]:
# tolerance in parameters

import math
#Variable declaration
CMRR=10.0*10**4                      #common mode rejection ratio


#Calculations
#set a=beta+k1*delbeta and b=beta(-/+)k2*delbeta
#CMRR=0.5*((4(+/-)3*delbeta*(k1-k2))/((+/-)delbeta*(k1-k2)))
#CMRR=0.5*((4(+/-)3*(a1-a2))/((+/-)(a1-a2)))
#a1->k1*delbeta, a2->k2*delbeta

delalpha=(2/CMRR)                 #a1-a2=delalpha

#Result
print("tolerance in parameters:")
print("delalpha = %.0f * 10^-5 "%(delalpha*10**5))
print("Therefore, if a varies by 1 percent, b should not vary more than 2*10^-3 percent of variation of a.")
tolerance in parameters:
delalpha = 2 * 10^-5 
Therefore, if a varies by 1 percent, b should not vary more than 2*10^-3 percent of variation of a.

Example2_8,pg 485

In [19]:
# output voltage

import math
#Variable declaration
R1=10*10**3             #resistor R1
R2=10*10**3             #resistor R2
V1=1.0                  #input voltage-1
V2=1.0                  #input voltage-2
R31=10.0*10**3          #Resistor R3,case-1
R32=100.0*10**3         #Resistor R3,case-2
R33=1000.0*10**3        #Resistor R3,case-3


#Calculations
Vo1=((1+(R2/R1)+(R2/R31))*V1)-(R2/R1)*V2
Vo2=((1+(R2/R1)+(R2/R32))*V1)-(R2/R1)*V2
Vo3=((1+(R2/R1)+(R2/R33))*V1)-(R2/R1)*V2
Vo4 = ((1+(R2/R1)+(0))*V1)-(R2/R1)*V2          #by substituting R3 = infinity in above equation abo
#Result
print("output voltage case-1:")
print("Vo1 = %.2f V\n"%Vo1)
print("output voltage case-2:")
print("Vo2 = %.2f V\n"%Vo2)
print("output voltage case-3:")
print("Vo3 = %.2f V\n"%Vo3)
print("output voltage case-4:")
print("Vo3 = %.2f V"%Vo4)
output voltage case-1:
Vo1 = 2.00 V

output voltage case-2:
Vo2 = 1.10 V

output voltage case-3:
Vo3 = 1.01 V

output voltage case-4:
Vo3 = 1.00 V

Example2_9,pg 486

In [5]:
# difference in output voltage

import math
#Variable declaration
#(R3/R1)=0.98^-1(R2/R4)
R1=10.0*10**3              # Resistor R1
R3=10.0*10**3              # Resistor R3
I1=130.0*10**-6            # Current 

#Calculations
Vo1=R1*(1+0.98)*I1       #output for case-1, (R2/R4)=0.98
#(R1/R3)=(R4/R2)
Vo2=R1*(1+(R3/R1))*I1    #output for case-2
Vo12=((Vo2-Vo1)/Vo2)*100 #percent difference

#Result
print("difference in output voltage:")
print("%% difference  = %.1f %%"%Vo12)
difference in output voltage:
% difference  = 1.0 %

Example2_10,pg 486

In [6]:
# find crest factor

import math
#Variable declaration
dutcyc=0.4                  #duty cycle

#Calculations
CF=math.sqrt((1-dutcyc)/dutcyc)  #crest factor

#Result
print("crest factor:")
print("CF = %.3f "%(math.floor(CF*1000)/1000))
crest factor:
CF = 1.224 

Example2_11,pg 486

In [9]:
# Find unknown resisance

import math
R1=10*10**3            #resistor R1
R4=10*10**3            #resistor R4
Idss=1*10**-3          #drain saturation current
Vp=2.2                 #peak voltage
Vo=10.0                #output voltage
V2=2.0                 #input-1
V1=-2.0                #input-2

#Calculations
R5=((R1*R4)/Vo)*((-2*Idss/(Vp**2)))*V1*V2

#Result
print("R5 = %.1f k-ohm"%(R5/1000))
#R5 should satisfy the condition R5=((1+R1*(-2*Idss*Vp)/R2)*R3*R6) and with Vp negative it is obiviously possible
R5 = 16.5 k-ohm