# Given data
A= 92 # in dB
A= 10**(92.0/20)
V_CC= 15 # in volt
Vout= 30 # in volt
InputOffsetVoltage= 0 # in V
InputVoltage= Vout/A # in V
print "Input Voltage = %0.4f mV" %(InputVoltage*10**3)
# Given data
R1= 2 # in kohm
Rf= 390.0 # in kohm
V_sat= 12 # in V
Bita= R1/(R1+Rf)
UTP= Bita*V_sat # in volt
LTP= -Bita*V_sat # in volt
print "Value of UTP = %0.1f mv" %(UTP*10**3)
print "Value of LTP = %0.1f mv" %(LTP*10**3)
# Note : In the book, there is an error to convert the value of UTP from volts to milli volts.
from math import exp
# Given data
t=0
Vc=0
Vo=5 #in volt
# V1= 2*R/(2*R+3*R)= 2/5*Vo
# Vco= 1/5*VR +4/5*Vo = 1/5*(VR+4*Vo)
# Req= R||4*R= 4/5*R
# Vct= Vco*(1-%e**(-t/(Req*C)))= 1/5*(VR+4*Vo)*(1-%e**(-t/(4*R*C/5)))= 1/5*(VR+4*Vo)*(1-%e**(-1.25*t/(R*C)))
# T= 2*Rf*C*log(1+2*R3/R2)= 2*R*C*log(7/3)= 1.7*R*C
# t= T/2= .85*R*C, Hence
Vct=2 #in volt
# Vct= 1/5*(VR+4*Vo)*(1-%e**1.0625)
VR= Vct*5/(1-exp(-1.0625))-4*Vo
print "Value of VR = %0.2f volt" %VR
from numpy import pi
from math import asin
# Given data
omega= 200*pi # in radians/seconds
f=omega/(2*pi) # in Hz
T=1/f # in sec
T=T*10**3 #in ms
Vin= 7 #in volt
t1= 1/omega*asin(6.0/Vin) # in sec
t1=t1*10**3 # in ms
# The output of the schmitt trigger is at -10 volt
t1= T/2+t1 # in ms
# The output of the schmitt trigger is at +10 volt
t2= 10-t1 # in ms
print "The output of the schmitt trigger is at -10 volt = %0.2f ms" %t1
print "The output of the schmitt trigger is at +10 volt = %0.2f ms" %t2
# Given data
R1= 150 # in ohm
R2= 68.0 # in kohm
R2=R2*10**3 # in ohm
Vin= 500 # in mv
V_sat= 14 #in volt
V_pos= R1/(R1+R2)*V_sat # in volt
V_UT= V_pos #in volt
# In the same way when output is -14 volts and starts increasing in negative direcition
V_sat=-14 #in volt
V_pos= R1*V_sat/(R1+R2) # in volt
V_LT= abs(V_pos) #in volt
print "Value of V_UT = %0.4f volts" %V_UT
print "Value of V_LT = %0.4f volts" %V_LT
# Given data
V_UT= 5 # in V
V_LT= -5 # in V
V_sat= 10 # in V (Assume)
# V_UT= (R1/(R1+R2))*V_sat = 5
# V_LT= (-R1/(R1+R2))*V_sat = -5
# 10*R1/(R+R2)= 5
V_hy= V_UT-V_LT # in volt
print "Hysteresis voltage = %0.f volt" %V_hy
# Given data
V_REF= 10 # in V
V_REF= float(V_REF) # converting into float
MSB2= V_REF/2 # in volt
print "The second MSB weight = %0.f volt" %MSB2
MSB3= V_REF/4 # in volt
print "The third MSB weight = %0.1f volt"%MSB3
MSB4= V_REF/8 # in volt
print "The forth MSB (or LSB) weight = %0.2f volt" %MSB4
DAC= MSB4
print "The resolution of the DAC = %0.2f volt" %DAC
FullScaleOutput= V_REF+MSB2+MSB3+MSB4 #in volt
print "Full scale output = %0.2f volt" %FullScaleOutput
print "IF Rf is reduced to one-forth then the value of full scale output =" ,round(FullScaleOutput/4,4)," volt"
# Given data
V_REF= -5 # in V
V_B= 0 # in volt
V_A= -5 # in volt
V_A= float(V_A) # converting into float
V_C=V_A
V_D=V_C
Vout= -1*(V_A+V_B/2+V_C/4+V_D/8) # in volt
print "Output voltage = %0.3f volt" %Vout
# Given data
Dn=16 # in volt
Dn= float (Dn) #converting into float
MSB1= Dn/2 # in volt
print "The first MSB output = %0.f volt" %MSB1
MSB2= Dn/4 # in volt
print "The second MSB output = %0.f volt" %MSB2
MSB3= Dn/8 # in volt
print "The third MSB output = %0.f volt" %MSB3
MSB4= Dn/16 # in volt
print "The forth MSB output = %0.f volt" %MSB4
MSB5= Dn/32 # in volt
print "The fifth MSB output = %0.1f volt" %MSB5
MSB6= Dn/64 # in volt
print "The sixth MSB (LSB) output = %0.2f volt" %MSB6
resolution= MSB6 # in volt
print "The resolution = %0.2f volt" %resolution
fullScaleOutput= MSB1+MSB2+MSB3+MSB4+MSB5+MSB6
print "Full scale output occurs for digital input of 111111 = %0.2f volt" %fullScaleOutput
# For digital input 101011
D0=16
D1=16
D2=0
D3=16
D4=0
D5=16
Vout= float(D0*2**0 + D1*2**1 + D2*2**2 + D3*2**3 + D4*2**4 + D5*2**5)/2**6 # in volt
print "The voltage output for a digital input of 101011 = %0.2f volt" %Vout
# Given data
# For the word 100100
N=6 # Number of bits
a5= 1 # Value of bits
a4= 0 # Value of bits
a3= 0 # Value of bits
a2= 1 # Value of bits
a1= 0 # Value of bits
a0= 0 # Value of bits
Vo= 3.6 # in volt
# Formula Vo= (2**(N-1)*a5 + 2**(N-2)*a4 + 2**(N-3)*a3 + 2**(N-4)*a2 + 2**(N-5)*a1 + 2**(N-6)*a0 ) * K
K= Vo/(2**(N-1)*a5 + 2**(N-2)*a4 + 2**(N-3)*a3 + 2**(N-4)*a2 + 2**(N-5)*a1 + 2**(N-6)*a0 )
# For the word 110011
N=6 # Number of bits
a5= 1 # Value of bits
a4= 1 # Value of bits
a3= 0 # Value of bits
a2= 0 # Value of bits
a1= 1 # Value of bits
a0= 1 # Value of bits
Vo= (2**(N-1)*a5 + 2**(N-2)*a4 + 2**(N-3)*a3 + 2**(N-4)*a2 + 2**(N-5)*a1 + 2**(N-6)*a0 ) * K # in volt
print "(i) : The value of Vo for the word 110011 = %0.1f volt" %Vo
# Part(ii)
# For the word 1010
N=4 # Number of bits
a3= 1 # Value of bits
a2= 0 # Value of bits
a1= 1 # Value of bits
a0= 0 # Value of bits
VR= 6 # in volt
Vo= float(VR)/2**N*( 2**(N-1)*a3 + 2**(N-2)*a2 + 2**(N-3)*a1 + 2**(N-4)*a0 )
print "(ii) : Value of output voltage = %0.2f volt" %Vo
# Given data
R=100 # in kohm
R=R*10**3 # in ohm
C= 1 # in micro F
C=C*10**-6 # in F
V_REF= 5 # in volt
t=0.2 # time taken to read an unknown voltage in second
T=R*C # in second
Vx= T/t*V_REF # in volt
print "Unknown voltage = %0.1f volt" %Vx
# Given data
f=75 # in MHz
f=f*10**6 # in Hz
# For an 8-bit converter reference voltage
V_REF= 100 # in volt
# For setting D7=1
Vo_7= V_REF*2**7/2**8 #in volt
# For setting D6=1
Vo_6= V_REF*2**6/2**8 #in volt
# For setting D7=1 and D6=1
Vo_76= Vo_7+Vo_6 #in volt
# For setting D5=1 D6=1 and D7=1
Vo_5= float(V_REF*2**5)/2**8+Vo_7+Vo_6 #in volt
print "For setting D7=1 output voltage = %0.f volt" %Vo_7
print "For setting D6=1 output voltage = %0.f volt" %Vo_6
print "For setting D7=1 and D6=1 output voltage = %0.f volt" %Vo_76
print "For setting D5=1, D6=1 and D7=1 output voltage = %0.1f volt" %Vo_5
T=float(1.0/f) # in sec
print "Conversion time = %0.1f ns" %(T*10**9)
# Given data
f=1 # in MHz
f=f*10**6 # in Hz
f= float(f) # converting into float
T=1/f # conversion time in sec
N=8 # number of bits
tc= N*T # in sec
print "Time of Conversion = %0.f micro sec : " %(tc*10**6)
# Given data
Vin= 2 #in volt
Vout= 10 #in volt
R=100 # in kohm
R=R*10**3 #in ohm
C=0.1 # in micro F
C=C*10**-6 #in F
# Formula Vout = -1/(R*C)*integrate('Vin','t',0,t) = -Vin*t/(R*C)
t= Vout*R*C/Vin # in sec
print "Maximum time upto which the reference voltage can be integrated,"
print "t =",round(t,2),"second =",int(round(t*10**3)),"ms"
# Given data
C=0.1 # in nF
C=C*10**-9 #in F
V=5 #in V
t=1 # in micro S
t=t*10**-6 # in sec
# v= V*(1-%e**(-t/(R*C)))
# Since hold value does not drop by more than 0.5% or by 0.005 V, hold value is 0.995 V, Thus
# 0.995*V= V*(1-%e**(-t/(R*C)))
# or %e**(-t/(R*C))= 1-0.995 = 0.005
R= t/(C*math.log(1/0.005)) # in ohm
I= V/R*(1-exp(-t/(R*C))) # Maximum currnet through R in amphere
print "Maximum permissible leakage current through the hold capacitor = %0.3f mA" %(I*10**3)