summaryrefslogtreecommitdiff
path: root/Linear_Integrated_Circuits/Chapter10.ipynb
blob: db7e9c1b69a042d40db59cbf42bf26b15b299afb (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10 : D-A and A-D Converters"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.1 Page No.357"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given Data \n",
      "\n",
      "n = 9\n",
      "s = 10.3*10**-3\n",
      "a = '0b101101111'\n",
      "\n",
      "# Solution \n",
      "# Converting the given value into its equivalent decimal value\n",
      "x = int(a,2)\n",
      "#multiplying with the resolution to get the output\n",
      "\n",
      "V = round(x*s,2)\n",
      "\n",
      "print \"The output value will be =\",V,\"V\" \n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output value will be = 3.78 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.2 Page No.357"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from fractions import Fraction \n",
      "# Given data \n",
      "\n",
      "n = 8\n",
      "v = 10.0\n",
      "\n",
      "# Solution \n",
      "LSB = 1.0/2**n\n",
      "Vlsb =v/2**n\n",
      "MSB = v/2\n",
      "Vo = v - Vlsb\n",
      "\n",
      "# Dispalying the output\n",
      "\n",
      "print \"The value of LSB                  = \",Fraction(LSB).limit_denominator(256)\n",
      "print \"The voltage of LSB                = \",int(Vlsb*10**3),\"mV\"\n",
      "print \"The MSB                           = \",int(MSB)\n",
      "print \"The value of full scale output is = \",round(Vo,3),\"V\"\n",
      "     \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of LSB                  =  1/256\n",
        "The voltage of LSB                =  39 mV\n",
        "The MSB                           =  5\n",
        "The value of full scale output is =  9.961 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.3 Page No.357"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "V = 10.0                 # Range of the DAC is 0 -10 voltage \n",
      "\n",
      "# define a function for performing the DAC action\n",
      "\n",
      "def DAC(Vo):\n",
      "    j = 1\n",
      "    sum = 0.0\n",
      "    x = len(Vo)\n",
      "    for i in range(x):\n",
      "        sum = sum + ((Vo[i])*(0.5**j))\n",
      "        j += 1\n",
      "    \n",
      "    return (V*sum)\n",
      "# part 1 \n",
      "Vo1 = np.array([1, 0])\n",
      "# part 2\n",
      "Vo2 = np.array([0, 1, 1, 0])\n",
      "#part 3\n",
      "Vo3 = np.array([1, 0, 1, 1, 1, 1, 0, 0])\n",
      "\n",
      "# Finding the solution for all 3 parts and printing the outputs \n",
      "\n",
      "print \" The output for part 1\",int(DAC(Vo1)),\"V\"\n",
      "print \" The output for part 2\",(DAC(Vo2)),\"V\"\n",
      "print \" The output for part 3\",round(DAC(Vo3),2),\"V\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The output for part 1 5 V\n",
        " The output for part 2 3.75 V\n",
        " The output for part 3 7.34 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.4 Page No.365"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given data \n",
      "n = 16 \n",
      "Clockrate = 4*10**6\n",
      "V = 10.0\n",
      "c = 0.1*10**-6\n",
      "va = -8.0\n",
      "\n",
      "# Solution \n",
      "\n",
      "t21 = (2.0**n)/(Clockrate)\n",
      "R = ((-V/va)*t21)/c\n",
      "\n",
      "print \"The value of (t2-t1)    =\",round(t21*10**3,2),\"ms\"\n",
      "print \"The value of Resistor R =\",int(round(R*10**-3)),\"kilo Ohms\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of (t2-t1)    = 16.38 ms\n",
        "The value of Resistor R = 205 kilo Ohms\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.5 Page No.365"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "Va = 4.129\n",
      "n = 16\n",
      "Vr = 8\n",
      "\n",
      "# Solution \n",
      "\n",
      "N = int(round((2**n)*(Va/Vr)))\n",
      "out = bin(N)    # Converting the voltage value into its binary equivalent\n",
      "\n",
      "print \"The binary equivalent is = \",out\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary equivalent is =  0b1000010000100001\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.6 Page No.368"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data \n",
      "\n",
      "d = 3.5 \n",
      "print \"The last 3 digit can be\",000,\"To\",(10**int(d))-1\n",
      "print \"Hense the 3 1/2 digit DVM reading varies from\",0000,\"to\",\"1\"+str((10**int(d))-1)\n",
      "# Reference voltage is 2V\n",
      "Vref = 2.0\n",
      "# Resolution R \n",
      "\n",
      "R = Vref/2000\n",
      "print \"The resolution of a 3 1/2 digit DVM is =\",int(R*10**3),\"mV\"\n",
      "\n",
      "# Similarly for 4 1/2 digit DVM\n",
      "\n",
      "R1 = Vref/20000\n",
      "\n",
      "print \"Thus resolution of a 4 1/2 digit DVM is =\",R1*10**3,\"mV\"\n",
      "\n",
      "print \"So the resolution of 4 1/2 digit DVM is better than 3 1/2 digit DVM\"\n",
      " \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The last 3 digit can be 0 To 999\n",
        "Hense the 3 1/2 digit DVM reading varies from 0 to 1999\n",
        "The resolution of a 3 1/2 digit DVM is = 1 mV\n",
        "Thus resolution of a 4 1/2 digit DVM is = 0.1 mV\n",
        "So the resolution of 4 1/2 digit DVM is better than 3 1/2 digit DVM\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}