# Given Data
n = 9
s = 10.3*10**-3
a = '0b101101111'
# Solution
# Converting the given value into its equivalent decimal value
x = int(a,2)
#multiplying with the resolution to get the output
V = round(x*s,2)
print "The output value will be =",V,"V"
from fractions import Fraction
# Given data
n = 8
v = 10.0
# Solution
LSB = 1.0/2**n
Vlsb =v/2**n
MSB = v/2
Vo = v - Vlsb
# Dispalying the output
print "The value of LSB = ",Fraction(LSB).limit_denominator(256)
print "The voltage of LSB = ",int(Vlsb*10**3),"mV"
print "The MSB = ",int(MSB)
print "The value of full scale output is = ",round(Vo,3),"V"
import numpy as np
V = 10.0 # Range of the DAC is 0 -10 voltage
# define a function for performing the DAC action
def DAC(Vo):
j = 1
sum = 0.0
x = len(Vo)
for i in range(x):
sum = sum + ((Vo[i])*(0.5**j))
j += 1
return (V*sum)
# part 1
Vo1 = np.array([1, 0])
# part 2
Vo2 = np.array([0, 1, 1, 0])
#part 3
Vo3 = np.array([1, 0, 1, 1, 1, 1, 0, 0])
# Finding the solution for all 3 parts and printing the outputs
print " The output for part 1",int(DAC(Vo1)),"V"
print " The output for part 2",(DAC(Vo2)),"V"
print " The output for part 3",round(DAC(Vo3),2),"V"
#Given data
n = 16
Clockrate = 4*10**6
V = 10.0
c = 0.1*10**-6
va = -8.0
# Solution
t21 = (2.0**n)/(Clockrate)
R = ((-V/va)*t21)/c
print "The value of (t2-t1) =",round(t21*10**3,2),"ms"
print "The value of Resistor R =",int(round(R*10**-3)),"kilo Ohms"
# Given data
Va = 4.129
n = 16
Vr = 8
# Solution
N = int(round((2**n)*(Va/Vr)))
out = bin(N) # Converting the voltage value into its binary equivalent
print "The binary equivalent is = ",out
# Given data
d = 3.5
print "The last 3 digit can be",000,"To",(10**int(d))-1
print "Hense the 3 1/2 digit DVM reading varies from",0000,"to","1"+str((10**int(d))-1)
# Reference voltage is 2V
Vref = 2.0
# Resolution R
R = Vref/2000
print "The resolution of a 3 1/2 digit DVM is =",int(R*10**3),"mV"
# Similarly for 4 1/2 digit DVM
R1 = Vref/20000
print "Thus resolution of a 4 1/2 digit DVM is =",R1*10**3,"mV"
print "So the resolution of 4 1/2 digit DVM is better than 3 1/2 digit DVM"