# Chapter 14 - Digital-Analog Systems¶

## Example 14_1 Page No. 420¶

In [2]:
from __future__ import division
n=3
print "n= %0.2f"%(n) # Number of bits
L=2**(n)
print "L=2**(n)= %0.2f"%(L)# Number of quantization levels
VFS=10
QE=VFS/L
print "Q.E=VFS/L= %0.2f"%(QE)# Quantization error
print "Q.E= +0.625,-0.625"# To make Quantization error symmetrical ittaken as (-Q.E/2) negative and positive value(+Q.E/2)
Resolution=(100/2**(n))#Formulae
print "Resolution=(100/2**(n))= %0.2f"%(Resolution)," percent"#Resolution
print "Resolution= %0.2f"%(+Resolution)," percent,%0.2f"%(-Resolution)," percent"# Since Resolution is (+)as well as (-)

n= 3.00
L=2**(n)= 8.00
VFS= 10.00  volts
Q.E=VFS/L= 1.25
Q.E= +0.625,-0.625
Resolution=(100/2**(n))= 12.50  percent
Resolution= 12.50  percent,-12.50  percent


## Example 14_2 Page No. 420¶

In [1]:
from __future__ import division
n=3
print "n= %0.2f"%(n) # Number of bits
L=2**(n)
print "L=2**(n)= %0.2f"%(L) # Number of quantization levels
VFS=1024*10**(-3)

print "part(i)"# Part(i)
LSB=VFS/(2**n)
print "LSB=VFS/(2**n)= %0.2f"%(LSB)," volts" # Lowest significant bit of 3-bit ADC

print "part(ii)"# Part(ii)
print "vh= 64 to 192 mV with offset" # Analog voltage corresponding to binary word 001

print "part(iii)"# Part(iii)
IE=(LSB)/2
print "Inherent error,I.E= (LSB)/2= -%0.2f"%(IE)," V,+%0.2f"%(IE)," V"# Inherent error in each binary word

print "part(iv)"# Part(iv)
Resolution=(1*10**(-3))
print "Resolution= %0.2f"%(Resolution)," V"#Resolution
VFS=1
k=VFS/(Resolution)
print "k=VFS/(Resolution)= %0.2e"%(k) # 'k' taken only for calculation purpose
print "number of bits=10"# since k =[VFS/(Resolution)]is approximately equal to 2**10,

n= 3.00
L=2**(n)= 8.00
VFS= 1.02  volts
part(i)
LSB=VFS/(2**n)= 0.13  volts
part(ii)
vh= 64 to 192 mV with offset
part(iii)
Inherent error,I.E= (LSB)/2= -0.06  V,+0.06  V
part(iv)
Resolution= 0.00  V
VFS= 1.00  V
k=VFS/(Resolution)= 1.00e+03
number of bits=10


## Example 14_3 Page No. 421¶

In [6]:
from __future__ import division
VREF=-10
print "VREF= %0.2f"%(VREF)," V" # Reference voltage
RF=5*10**(3)
print "RF= %0.2f"%(RF)+ " ohm"  #Feedback resistance
R=10*10**(3)
print "R= %0.2f"%(R)+ " ohm"  # resistance
vLSB=(-RF*VREF)/(8*R)# Since IF=I/8,so vLSB=(-RF*IF)=(-RF*I/8)=(-RF*VREF/8*R)
print "vLSB=(-RF*VREF)/(8*R)=%0.2f"%(vLSB)," V" # Equivalent voltage for binary word 0001
vo=-2*vLSB# Since current IF=I/4
print "vo = -2*vLSB =%0.2f"%(vo)," V" # Equivalent voltage for binary word 0010=2 (in decimal)
vo=-15*vLSB# Since current IF=I+(I/2)+(I/4)+(I/8)=(15*I/8),so vo=15*VLSB
print "vo= -15*vLSB =%0.2f"%(vo)," V" # Equivalent voltage for binary word 0010=2 (in decimal)

VREF= -10.00  V
RF= 5000.00 ohm
R= 10000.00 ohm
vLSB=(-RF*VREF)/(8*R)=0.62  V
vo = -2*vLSB =-1.25  V
vo= -15*vLSB =-9.38  V


## Example 14_4 Page No. 422¶

In [7]:
from __future__ import division
VREF=-10
print "VREF= %0.2f"%(VREF)," V" # Reference voltage
RF=5*10**(3)
print "RF= %0.2f"%(RF)+ " ohm"  #Feedback resistance
R=10*10**(3)
print "R= %0.2f"%(R)+ " ohm"  # resistance
vMSB=-(RF*VREF)/(2*R)# Since IF=I/2,so vMSB=(-RF*IF)=(-RF*I/2)=(-RF*VREF/2*R)
print "vMSB=-(RF*VREF)/(2*R)=%0.2f"%(vMSB)," V" # Equivalent voltage for binary word 1000=8(in decimal)
vo2=vMSB/2# Since current IF=I/4
print "vo2 = vMSB/2 =%0.2f"%(vo2)," V" # Equivalent voltage for binary word 0100=4 (in decimal)
vo3=(15/8)*vMSB# Since current IF=I+(I/2)+(I/4)+(I/8)+(I/16)=(15*I/6),so vo=(15/8)*VMSB
print "vo3= (15/8)*vMSB =%0.2f"%(vo3)," V" # Equivalent voltage for binary word 1111=15 (in decimal)

VREF= -10.00  V
RF= 5000.00 ohm
R= 10000.00 ohm
vMSB=-(RF*VREF)/(2*R)=2.50  V
vo2 = vMSB/2 =1.25  V
vo3= (15/8)*vMSB =4.69  V


## Example 14_5 Page No. 422¶

In [8]:
from __future__ import division
n=12
print "n= %0.2f"%(n) # Number of bits
VFS=50
S=VFS/(2**n)
print "S=VFS/(2**n)= %0.2f"%(S)," volts" # Maximum quantization error
Resolution=(100/2**(n))#Formulae
print "Resolution=(100/2**(n))= -%0.2f"%(Resolution)," percent, +%0.2f"%(Resolution)," percent"# Since Resolution is (+)as well as (-)

n= 12.00
VFS= 50.00  volts
S=VFS/(2**n)= 0.01  volts
Resolution=(100/2**(n))= -0.02  percent, +0.02  percent


## Example 14_7 Page No. 423¶

In [6]:
from math import pi
from __future__ import division
n=12
print "n= %0.2f"%(n) # Number of bits
t=5*10**(-6)
print "t= %0.2e"%(t)," A"
Vsp=10
LSB=Vsp/(2**n)
print "LSB=Vsp/(2**n)= %0.4f"%(LSB)," volts" # Lowest significant bit of 12-bit ADC
print "LSB/2= -%0.4f"%(LSB/2)," V, -%0.2f"%(LSB/2)," V"
SR=(LSB/2)/t
print "SR=(LSB/2)/t= %0.2f"%(SR)," V/s"
fmax=SR/(2*pi*Vsp)
print "f = SR/(2*pi*Vsp)=%0.2f"%(fmax)," Hz"# Highest frequency allowed at the input

n= 12.00
t= 5.00e-06  A
Vsp= 10.00  volts
LSB=Vsp/(2**n)= 0.0024  volts
LSB/2= -0.0012  V, -0.00  V
SR=(LSB/2)/t= 244.14  V/s
f = SR/(2*pi*Vsp)=3.89  Hz