Chapter 4 : Digital Instruments¶

Example - 4.1 : Page No - 4.5¶

In [8]:
from __future__ import division
#Given data
Vi = 5.1 #input voltage in V
n = 8 # number of bit
Resolution = 2**n
Resolution = Vi/(Resolution-1) # in V/LSB
Resolution= Resolution*10**3 # in mV/LSB
print "The Resolution = %0.f mV/LSB " %Resolution
Resolution= Resolution*10**-3 # in V/LSB
Vi = 1.28 # in V
D = Vi/Resolution #digital output in LSBs
DigitalOutput= bin(int(D)) # digital output in binary
print "The binary equivalent digital output = " ,DigitalOutput

The Resolution = 20 mV/LSB
The binary equivalent digital output =  0b1000000


Example - 4.2 : Page No - 4.5¶

In [4]:
#Given data
n = 12 #number of bit
Vi = 4.095 #input voltage in V
Q_E = Vi/(((2**n)-1)*2) #quantizing error in V
Q_E = Q_E * 10**3 # in mV
print "The quantizing error = %0.1f mV " %Q_E

The quantizing error = 0.5 mV


Example - 4.3 : Page No - 4.10¶

In [5]:
#Given data
# When Vi=100 mV
Vi = 100 # in mV
V_R = 100 # in mV
t1 = 83.33 # in ms
t2 = (Vi/V_R)*t1 # in ms
print "When Vi=100 mV, the value of t2 = %0.2f ms " %t2
# When Vi=200 mV
Vi = 200 # in mV
t2 = (Vi/V_R)*t1 # in ms
print "When Vi=200 mV, the value of t2 = %0.1f ms " %t2

When Vi=100 mV, the value of t2 = 83.33 ms
When Vi=200 mV, the value of t2 = 166.7 ms


Example - 4.4 : Page No - 4.10¶

In [6]:
#Given data
t1 = 83.33 # in ms
V_R = 100 # in mV
Vi = 100 # in mV
fc = 12 #clock frequency in kHz
fc = fc* 10**3 # in Hz
Digitaloutput = round(fc*t1*(Vi/V_R)*10**-3) #digital output in counts
print "The Digital output = %0.f counts " %Digitaloutput

The Digital output = 1000 counts


Example - 4.5 : Page No - 4.13¶

In [7]:
#Given data
f = 1 # in MHz
f = f * 10**6 # in Hz
T = 1/f # in sec
T = T * 10**6 # in µsec
n = 8
# Conversion time
T_C = T*(n+1) # in µsec
print "The conversion time = %0.f µsec " %T_C

The conversion time = 9 µsec


Example - 4.6 : Page No - 4.15¶

In [9]:
from numpy import pi
#Given data
n = 8 # number of bit
T_C = 9 #conversion time in µs
T_C = T_C * 10**-6 # in s
# The maximum frequency
f_max = 1/(2*pi*T_C*(2**n)) # in Hz
print "The maximum frequency = %0.2f Hz " %f_max

The maximum frequency = 69.08 Hz


Example - 4.7 : Page No - 4.39¶

In [10]:
#Given data
n = 3 # number of bit
R = 1/(10**n)
V = 1 # in V
# For 1V range,
Resolution = V*R # in V
print "For 1 V range, the resolution = %0.3f V " %Resolution
# For 50 V range,
V = 50 # in V
Resolution = V*R # in V
print "For 50 V range, the resolution = %0.2f V " %Resolution

For 1 V range, the resolution = 0.001 V
For 50 V range, the resolution = 0.05 V


Example - 4.8 : Page No - 4.39¶

In [14]:
#Given data
n = 4 # number of bit
R = 1/(10**n)
print "Part (i) : The resolution = %0.4f " %R
# There are 5 digit places in 4 1/2 digits, so
print "Part (ii) : 11.87 would be displayed as 11.870"

Part (i) : The resolution = 0.0001