Chapter2 - Digital to Analog Converters¶

Example 1 - pg 2_9¶

In [1]:
#Chapter-2,Example2_1,pg 2_9
#calculate the input resistance and feedback resistance
#given
Vr=10.
n=4.
Res=0.5#resolution
Rf=10*10**3
#calculations
Rt=Vr/((2**n)*Res)
R=Rt*Rf
#results
print "input resistance (kohm) = ",R/1000.
print "feedback resistance (kohm) = ",Rf/1000.

input resistance (kohm) =  12.5
feedback resistance (kohm) =  10.0


Example 2 - pg 2_11¶

In [8]:
#Chapter-2,Example2_2,pg 2_11
#calculate the resolution through both methods
#given
n=8
Vofs=2.55#full scale output voltage
#calculations
Res1=2**n
Res2=Vofs/(Res1-1)
#results
print "resolution through method-1 = ",Res1
print "resolution through method-2 (mV) = ",Res2*1000

resolution through method-1 =  256
resolution through method-2 (mV) =  10.0


Example 3 - pg 2_12¶

In [9]:
#Chapter-2,Example2_3,pg 2_12
#calculate the output voltage
#given
n=4.
Vofs=15.
#calculations
Res=Vofs/((2**n)-1)
D=int('0110',base=2)#decimal equivalent
Vo=Res*D
#results
print"output voltage (V) = ",Vo

output voltage (V) =  6.0


Example 4 - pg 2_12¶

In [5]:
#Chapter-2,Example2_4,pg 2_12
#calculate the output voltage
#given
Res=20*10**-3
n=8
#calculations
Vofs=Res*((2**n)-1)
D=int('10000000',base=2)
Vo=Res*D
print"output voltage (V) = ",Vo
print"full scale output voltage (V) = ",Vofs

output voltage (V) =  2.56
full scale output voltage (V) =  5.1


Example 5 - pg 2_12¶

In [6]:
#Chapter-2,Example2_5,pg 2_12
#calculate the output voltage
#given
n=4.
Vofs=5.
#calculations
Res=Vofs/((2**n)-1)
D1=int('1000',base=2)
Vo1=Res*D1
D2=int('1111',base=2)
Vo2=Res*D2
#results
print"output voltage1 (V) = ",round(Vo1,4)
print"output voltage2 (V) = ",Vo2

output voltage1 (V) =  2.6667
output voltage2 (V) =  5.0


Example 6 - pg 2_13¶

In [10]:
#Chapter-2,Example2_6,pg 2_13
#calculate the full scale output voltage, percentage resolution
#given
n=12.
Res=8.*10**-3
#calculations
Vofs=Res*((2**n) -1)
perR=Res/Vofs*100.
Vo=Res*int('010101101101',base=2)
#results
print "Full scale output voltage (V) = ",Vofs
print"percentage resolution = ",round(perR,5)
print"output voltage (V) = ",Vo

Full scale output voltage (V) =  32.76
percentage resolution =  0.02442
output voltage (V) =  11.112