#Given
n=8 #8 bit ADC
V1=0 #V, input unipolar voltage
V2=10 #V
Vi=5.2 #V, applied input voltage
#calculation
LSB=V2*1000/(2**n)
Vifs=V2-LSB*10**-3
D=Vi/LSB*10**3
binary=10000101
#Result
print"(a)The minimum input voltage is",LSB,"mV"
print"(b)Input voltage that will cause all 1s at ADC's output",Vifs,"V"
print"(c)The No of LSB's are ",round(D,0),"So The digital output code is",binary
#Given (from example 15.1)
n=8 #8 bit ADC
FSR=10 #V
LSB=39.1 #mA, from ex. 15.1
#Calculation
Vifs=FSR*10**3-LSB+LSB/2.0
#Result
print"The voltahe is",Vifs/1000,"V"
#Given
error=0.5 #percent
FSR=10 #V
Vifs=9.961 #From ex 15.1 (c)
#Calculation
V=FSR*error/100.0
Vin=Vifs-V*10**-3
#result
print"The required voltage is",round(Vin,2),"V"
#Given
Vin1=100 #mV, input voltage
Vin2=200 #mV, input voltage
#Calculation
T2=0.833*Vin1 #From eq 15.6(b)
T2_=0.833*Vin2
#Result
print"(a)The required tome is",T2,"ms"
print"(b)The required tome is",T2_,"ms"
#Given
Vin=100 #mV
#Calculation
Vo=10*Vin #From eq 15.7(c)
#Result
print"The digital output is",Vo,"counts "
#given
n=8 #Bit
t=1 #micros, time for 1 clock pulse
#Calcultion
Tc=t*(n+1)
#Result
print"The required time is",Tc,"microsecond"
#Given
n=8 #8 bit ADC
t=10 #micros, conversion time
#Calculation
import math
fmax=1/(2*math.pi*2**n*t*10**-6)
#Result
print"The maximum frequency is",round(fmax,0),"Hz"
#Given
t=50 #ns, aperture time
n=8
error=1 #LSB
#Calculation
import math
fmax=1/(2*math.pi*2**n*t*10**-9)
#Result
print"The maximum frequency is",round(fmax/1000,1),"Hz"