#Given data
n = 8
Resolution = 2**n
print "Part (ii) : The resolution = %0.f" %Resolution
print "That is, the output voltage can have",int(Resolution),"different values including zero"
V_OFS = 2.55 # in V
Resolution= V_OFS/(2**n - 1)*10**3
print "\nPart (i) : The resolution =",int(round(Resolution))," mV/1LSB"
print "That is, an input change of 1 LSB causes the output to change by ",round(Resolution)," mV"
#Given data
n = 4
V_OFS = 15 # in V
digital_input = '0110' # in binary
D= int(digital_input , 2)
Resolution = V_OFS/((2**n)-1) # in V/LSB
V_out = Resolution*D # in V
print "Final output voltage = %0.f V" %V_out
#Given data
n = 8
Resolution = 20 # in mV/LSB
digital_input= '10000000' # in binary
D= int(digital_input , 2) # in decimal
Resolution=Resolution*10**-3 # in V/LSB
V_OFS = Resolution * ((2**n)-1) # in V
print "The value of V_OFS = %0.1f V" %V_OFS
V_out = Resolution*D # in V
print "The value of V_out = %0.2f V" %V_out
from __future__ import division
#Given data
n = 4
V_OFS = 5 # in V
digital_input= '1000' # in binary
D= int(digital_input , 2) # in decimal
Resolution = V_OFS/((2**n)-1)
V_out = Resolution * D # in V
print "When input is 1000 then, the output = %0.4f V" %V_out
# When
digital_input= '1111' # in binary
D= int(digital_input , 2) # in decimal
V_out= Resolution * D # in V
print "When input is 1111 then , the output =%0.f V" %V_out
#Given data
n=12
digital_input= '010101101101' # in binary
D= int(digital_input , 2) # in decimal
step_size= 8 # in mV
step_size=step_size*10**-3 # in V
VoFS= step_size*(2**n-1) # in V
print "The full scale output voltage = %0.2f V" %VoFS
Per_resolution= step_size/VoFS*100 # in %
print "Percentage resolution is = %0.5f" %Per_resolution
Vout= step_size*D # in V
print "The output voltage in V %0.3f" %Vout
#Given data
V_R = 10 # in V
n = 4
Resolution = 0.5 # in V
R_F = 10 # in k ohm
R = (1/2**n)*(V_R/Resolution)*R_F # in k ohm
print "The value of resistor = %0.1f kΩ" %R
#Given data
V_i = 5.1 # in V
n = 8
Re = 2**n
Resolution = V_i/(2**n-1) # in V/LSB
print "The Resolution = %0.f mV/LSB" %(Resolution*10**3)
# When
V_i = 1.28 # in V
D = int(round(V_i/Resolution) )
D_in_binary= bin(D) # in binary
print "The digital output = ",D_in_binary
#Given data
V_i = 4.095 #input voltage in V
n = 12
Q_E = V_i/( ((2**n)-1)*2 ) # in V
Q_E = Q_E * 10**3 # in mV
print "The quantizing error = %0.1f mV" %Q_E
#Given data
print "Part (i)"
V_i = 100 # in mV
V_R = 100 # in mV
t1 = 83.33 # in ms
t2 = (V_i/V_R)*t1 # in ms
print "The value of t2 = %0.2f ms" %t2
print "Part (ii)"
Vi = 200 # in mV
t_2 = (Vi/V_R)*t1 # in ms
print "The value of t_2 = %0.1f ms" %t_2
#Given data
C_F = 12 #clock frequency in kHz
C_F = C_F * 10**3 # in Hz
V_i = 100 # in mV
V_R = 100 # in mV
t1 = 83.33*10**-3 # in sec
D = C_F * t1*(V_i/V_R) # in counts
print "The Digital output is : ",int(round(D,1))," counts"
from numpy import pi
#Given data
n = 8
T_C = 9 #in µsec
T_C = T_C * 10**-6 # in sec
f_max = 1/(2*pi*T_C*(2**n)) # in Hz
print "Maximum frequency = %0.2f Hz" %f_max