# Chapter 3 - Analog to Digital Converters & Digital Voltmeters¶

## Example 1 - pg 3_5¶

In [1]:
#Chapter-3,Example3_1,pg 3_5
#calculate the Resolution and digital output voltage
#given
n=8
Vifs=5.1
Vi=1.28
#calculations
Res1=2**n
Res2=Vifs/((2**n)-1)
Res=Res2*1000#in mv/LSB
D=Vi/Res2
strin=bin(64)
#results
print"Resolution (mV/LSB) = ",Res
print"digital output voltage (LSBs) = ",D
print"Binary equivalent of 64 is",strin

Resolution (mV/LSB) =  20.0
digital output voltage (LSBs) =  64.0
Binary equivalent of 64 is 0b1000000


## Example 2 - pg 3_6¶

In [2]:
#Chapter-3,Example3_2,pg 3_6
#calculate the quantisation error
#given
Vifs=4.095
n=12.
#calculations
Qe=Vifs/(((2**n)-1)*2)
#results
print"quantisation error (mV) = ",round(Qe*1000.,1)

quantisation error (mV) =  0.5


## Example 3 - pg 3_10¶

In [3]:
#Chapter-3,Example3_3,pg 3_10
#calculate the value of t2 in both cases
#given
V1=100.*10**-3
Vr=100.*10**-3
t1=83.33
Vi=200.*10**-3#input voltage
#calculations
t2=(V1/Vr)*t1
t22=(Vi/Vr)*t1
#results
print"In case 1, t2 (ms) = ",t2
print"In case 2, t2 (ms) = ",t22

In case 1, t2 (ms) =  83.33
In case 2, t2 (ms) =  166.66


## Example 4 - pg 3_10¶

In [4]:
#Chapter-3,Example3_4,pg 3_10
#calculate the digital output
#given
fclk=12.*10**3#clock frequency
t1=83.33*10**-3
V1=100.*10**-3
Vr=100.*10**-3
#calculations
D=fclk*t1*(V1/Vr)
#results
print"digital output (counts) = ",round(D,0)

digital output (counts) =  1000.0


## Example 5 - pg 3_13¶

In [5]:
#Chapter-3,Example3_5,pg 3_13
#calculate the conversion time
#given
F=1*10**6
n=8
#calculations
T=1./F
Tc=T*(n+1)
#results
print"conversion time (musec) = ",Tc*10**6

conversion time (musec) =  9.0


## Example 6 - pg 3_15¶

In [6]:
#Chapter-3,Example3_6,pg 3_15
#calculate the maximum input frequency
import math
#given
Tc=9*10**-6
n=8
#calculations
fmax=1./(2*math.pi*Tc*(2**n))
#results
print"maximum input frequency (Hz) = ",round(fmax,2)

maximum input frequency (Hz) =  69.08


## Example 7 - pg 3_37¶

In [8]:
#Chapter-3,Example3_7,pg 3_37
#calculate the least difference in readings
#given
n=3.#3 full digits
#calculations
R=1./(10**n)
#for 1V range
Res1=1*R
#for 50V range
Res2=50*R
#results
print"least diffrence in readings for 50V range (V) = ",Res2

least diffrence in readings for 50V range (V) =  0.05


## Example 8 - pg 3_38¶

In [10]:
#Chapter-3,Example3_8,pg 3_38
#calculate the percent error
#given
n=3.
#calculations and results
R=1./(10**n)
#for 10V range
R=R*10.
err1=R#1-digit error
errt=err1+err#total error
print"error when reading is 5V (V) = ",errt

errt=err+err1#total error
errp=(errt/0.1)*100
print"percent error when reading is 0.1V (percent) = ",errp

error when reading is 5V (V) =  0.035
percent error when reading is 0.1V (percent) =  10.5


## Example 9 - pg 3_38¶

In [11]:
#Chapter-3,Example3_9,pg 3_38
#calculate the senstivity of meter
#given
n=4.
fsmin=10*10**-3#full scale value on min. range
#calculations
R=1/(10**n)
S=fsmin*R
#results
print"senstivity of meter (V) = ",S

senstivity of meter (V) =  1e-06


## Example 10 - pg 3_39¶

In [12]:
#Chapter-3,Example3_10,pg 3_39
#calculate the resolution
#given
n=4.
#calculations
R1=1./(10**n)
#for 10V range
R=10*R1
#results
print "resolution = ",R1
print"12.98 would be displayed as 12.980 for 10V range\n"
#for 1V range
R=1*R
print"0.6973 would be displayed as 0.6973 for 1V range\n"
#for 10V range
print"0.6973 would be displayed as 0.697 for 10V range\n"

resolution =  0.0001
12.98 would be displayed as 12.980 for 10V range

0.6973 would be displayed as 0.6973 for 1V range

0.6973 would be displayed as 0.697 for 10V range