summaryrefslogtreecommitdiff
path: root/Electronics_Circuits_and_Systems_by_Y._N._Bapat/Ch14.ipynb
blob: e210fc04ead48a2d01794b1268a3705878ec0f19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 14 - Digital-Analog Systems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14_1 Page No. 420"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n= 3.00\n",
      "L=2**(n)= 8.00\n",
      "VFS= 10.00  volts\n",
      "Q.E=VFS/L= 1.25\n",
      "Q.E= +0.625,-0.625\n",
      "Resolution=(100/2**(n))= 12.50  percent\n",
      "Resolution= 12.50  percent,-12.50  percent\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "n=3\n",
    "print \"n= %0.2f\"%(n) # Number of bits \n",
    "L=2**(n)\n",
    "print \"L=2**(n)= %0.2f\"%(L)# Number of quantization levels\n",
    "VFS=10\n",
    "print \"VFS= %0.2f\"%(VFS),\" volts\" # Maximum value of analog input voltage\n",
    "QE=VFS/L\n",
    "print \"Q.E=VFS/L= %0.2f\"%(QE)# Quantization error\n",
    "print \"Q.E= +0.625,-0.625\"# To make Quantization error symmetrical ittaken as (-Q.E/2) negative and positive value(+Q.E/2)\n",
    "Resolution=(100/2**(n))#Formulae\n",
    "print \"Resolution=(100/2**(n))= %0.2f\"%(Resolution),\" percent\"#Resolution\n",
    "print \"Resolution= %0.2f\"%(+Resolution),\" percent,%0.2f\"%(-Resolution),\" percent\"# Since Resolution is (+)as well as (-)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14_2  Page No. 420"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n= 3.00\n",
      "L=2**(n)= 8.00\n",
      "VFS= 1.02  volts\n",
      "part(i)\n",
      "LSB=VFS/(2**n)= 0.13  volts\n",
      "part(ii)\n",
      "vh= 64 to 192 mV with offset\n",
      "part(iii)\n",
      "Inherent error,I.E= (LSB)/2= -0.06  V,+0.06  V\n",
      "part(iv)\n",
      "Resolution= 0.00  V\n",
      "VFS= 1.00  V\n",
      "k=VFS/(Resolution)= 1.00e+03\n",
      "number of bits=10\n",
      "so 10-bit ADC required\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "n=3\n",
    "print \"n= %0.2f\"%(n) # Number of bits \n",
    "L=2**(n)\n",
    "print \"L=2**(n)= %0.2f\"%(L) # Number of quantization levels\n",
    "VFS=1024*10**(-3)\n",
    "print \"VFS= %0.2f\"%(VFS),\" volts\" # Maximum value of analog input voltage\n",
    "\n",
    "print \"part(i)\"# Part(i)\n",
    "LSB=VFS/(2**n)\n",
    "print \"LSB=VFS/(2**n)= %0.2f\"%(LSB),\" volts\" # Lowest significant bit of 3-bit ADC\n",
    "\n",
    "print \"part(ii)\"# Part(ii)\n",
    "print \"vh= 64 to 192 mV with offset\" # Analog voltage corresponding to binary word 001\n",
    "\n",
    "print \"part(iii)\"# Part(iii)\n",
    "IE=(LSB)/2\n",
    "print \"Inherent error,I.E= (LSB)/2= -%0.2f\"%(IE),\" V,+%0.2f\"%(IE),\" V\"# Inherent error in each binary word\n",
    "\n",
    "print \"part(iv)\"# Part(iv)\n",
    "Resolution=(1*10**(-3))\n",
    "print \"Resolution= %0.2f\"%(Resolution),\" V\"#Resolution\n",
    "VFS=1\n",
    "print \"VFS= %0.2f\"%(VFS),\" V\" # Maximum value of analog input voltage2\n",
    "k=VFS/(Resolution)\n",
    "print \"k=VFS/(Resolution)= %0.2e\"%(k) # 'k' taken only for calculation purpose\n",
    "print \"number of bits=10\"# since k =[VFS/(Resolution)]is approximately equal to 2**10,\n",
    "print \"so 10-bit ADC required\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14_3 Page No. 421"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VREF= -10.00  V\n",
      "RF= 5000.00 ohm\n",
      "R= 10000.00 ohm\n",
      "vLSB=(-RF*VREF)/(8*R)=0.62  V\n",
      "vo = -2*vLSB =-1.25  V\n",
      "vo= -15*vLSB =-9.38  V\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VREF=-10\n",
    "print \"VREF= %0.2f\"%(VREF),\" V\" # Reference voltage\n",
    "RF=5*10**(3)\n",
    "print \"RF= %0.2f\"%(RF)+ \" ohm\"  #Feedback resistance\n",
    "R=10*10**(3)\n",
    "print \"R= %0.2f\"%(R)+ \" ohm\"  # resistance\n",
    "vLSB=(-RF*VREF)/(8*R)# Since IF=I/8,so vLSB=(-RF*IF)=(-RF*I/8)=(-RF*VREF/8*R)\n",
    "print \"vLSB=(-RF*VREF)/(8*R)=%0.2f\"%(vLSB),\" V\" # Equivalent voltage for binary word 0001\n",
    "vo=-2*vLSB# Since current IF=I/4\n",
    "print \"vo = -2*vLSB =%0.2f\"%(vo),\" V\" # Equivalent voltage for binary word 0010=2 (in decimal)\n",
    "vo=-15*vLSB# Since current IF=I+(I/2)+(I/4)+(I/8)=(15*I/8),so vo=15*VLSB\n",
    "print \"vo= -15*vLSB =%0.2f\"%(vo),\" V\" # Equivalent voltage for binary word 0010=2 (in decimal)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14_4 Page No. 422"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "VREF= -10.00  V\n",
      "RF= 5000.00 ohm\n",
      "R= 10000.00 ohm\n",
      "vMSB=-(RF*VREF)/(2*R)=2.50  V\n",
      "vo2 = vMSB/2 =1.25  V\n",
      "vo3= (15/8)*vMSB =4.69  V\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "VREF=-10\n",
    "print \"VREF= %0.2f\"%(VREF),\" V\" # Reference voltage\n",
    "RF=5*10**(3)\n",
    "print \"RF= %0.2f\"%(RF)+ \" ohm\"  #Feedback resistance\n",
    "R=10*10**(3)\n",
    "print \"R= %0.2f\"%(R)+ \" ohm\"  # resistance\n",
    "vMSB=-(RF*VREF)/(2*R)# Since IF=I/2,so vMSB=(-RF*IF)=(-RF*I/2)=(-RF*VREF/2*R)\n",
    "print \"vMSB=-(RF*VREF)/(2*R)=%0.2f\"%(vMSB),\" V\" # Equivalent voltage for binary word 1000=8(in decimal)\n",
    "vo2=vMSB/2# Since current IF=I/4\n",
    "print \"vo2 = vMSB/2 =%0.2f\"%(vo2),\" V\" # Equivalent voltage for binary word 0100=4 (in decimal)\n",
    "vo3=(15/8)*vMSB# Since current IF=I+(I/2)+(I/4)+(I/8)+(I/16)=(15*I/6),so vo=(15/8)*VMSB\n",
    "print \"vo3= (15/8)*vMSB =%0.2f\"%(vo3),\" V\" # Equivalent voltage for binary word 1111=15 (in decimal)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14_5 Page No. 422"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n= 12.00\n",
      "VFS= 50.00  volts\n",
      "S=VFS/(2**n)= 0.01  volts\n",
      "Resolution=(100/2**(n))= -0.02  percent, +0.02  percent\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division  \n",
    "n=12\n",
    "print \"n= %0.2f\"%(n) # Number of bits\n",
    "VFS=50\n",
    "print \"VFS= %0.2f\"%(VFS),\" volts\" # Maximum value of analog input voltage\n",
    "S=VFS/(2**n)\n",
    "print \"S=VFS/(2**n)= %0.2f\"%(S),\" volts\" # Maximum quantization error\n",
    "Resolution=(100/2**(n))#Formulae\n",
    "print \"Resolution=(100/2**(n))= -%0.2f\"%(Resolution),\" percent, +%0.2f\"%(Resolution),\" percent\"# Since Resolution is (+)as well as (-)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14_7 Page No. 423"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n= 12.00\n",
      "t= 5.00e-06  A\n",
      "Vsp= 10.00  volts\n",
      "LSB=Vsp/(2**n)= 0.0024  volts\n",
      "LSB/2= -0.0012  V, -0.00  V\n",
      "SR=(LSB/2)/t= 244.14  V/s\n",
      "f = SR/(2*pi*Vsp)=3.89  Hz\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "from __future__ import division  \n",
    "n=12\n",
    "print \"n= %0.2f\"%(n) # Number of bits\n",
    "t=5*10**(-6)\n",
    "print \"t= %0.2e\"%(t),\" A\"\n",
    "Vsp=10\n",
    "print \"Vsp= %0.2f\"%(Vsp),\" volts\" # value of analog input voltage\n",
    "LSB=Vsp/(2**n)\n",
    "print \"LSB=Vsp/(2**n)= %0.4f\"%(LSB),\" volts\" # Lowest significant bit of 12-bit ADC\n",
    "print \"LSB/2= -%0.4f\"%(LSB/2),\" V, -%0.2f\"%(LSB/2),\" V\" \n",
    "SR=(LSB/2)/t\n",
    "print \"SR=(LSB/2)/t= %0.2f\"%(SR),\" V/s\"\n",
    "fmax=SR/(2*pi*Vsp)\n",
    "print \"f = SR/(2*pi*Vsp)=%0.2f\"%(fmax),\" Hz\"# Highest frequency allowed at the input"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}