summaryrefslogtreecommitdiff
path: root/Linear_Integrated_Circuit_by_M._S._Sivakumar/Ch12.ipynb
blob: c39c8ba5bba1335863df1b2d4c11fbb5a9f775f6 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 12 Analog To Digital Converter(A/D Converter)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.2 Pg 350"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Normalized step size of A/D converter is = 0.00390625\n",
      "Actual step size of A/D converter is = 0.046875\n",
      "Normalized maximum quantization level of A/D converter is = 0.9961\n",
      "Actual maximum quantization level of A/D converter is = 11.9531\n",
      "Normalized peak quantization error of A/D converter is = 0.001953\n",
      "Actual peak quantization error of A/D converter is = 0.023438  V \n",
      "Percentage of quantization error of A/D converter is = 0.1953\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# Determine the following parameter of 8-bit A/D converter a) Normalized step size b) Actual step size  c) Normalized maximum quantization level  d) Actual maximum quantization  e) Normalized peak quantization error  f) Actual peak quantization error  g) Percentage of quantization error\n",
    "N = 8 #\n",
    "Vin = 12 #\n",
    "\n",
    "#a) Normalized step size of A/D converter\n",
    "Ns = 2**-N #\n",
    "print 'Normalized step size of A/D converter is = %0.8f'%Ns\n",
    "\n",
    "# b) Actual step size of A/D converter\n",
    "As = Vin*Ns #\n",
    "print 'Actual step size of A/D converter is = %0.6f'%As\n",
    "\n",
    "# c) Normalized maximum quantization level of A/D converter\n",
    "Qmax = 1-2**-N #\n",
    "print 'Normalized maximum quantization level of A/D converter is = %0.4f'%Qmax\n",
    "\n",
    "# d) Actual maximum quantization level of A/D converter\n",
    "QAmax = Qmax*Vin #\n",
    "print 'Actual maximum quantization level of A/D converter is = %0.4f'%QAmax\n",
    "\n",
    "# e) Normalized peak quantization error of A/D converter\n",
    "Qp = 2**-(N+1)#\n",
    "print 'Normalized peak quantization error of A/D converter is = %0.6f'%Qp\n",
    "\n",
    "# f) Actual peak quantization error of A/D converter\n",
    "Qe = Qp*Vin #\n",
    "print 'Actual peak quantization error of A/D converter is = %0.6f'%Qe,' V '#\n",
    "\n",
    "# g) Percentage of quantization error of A/D converter\n",
    "per_Qp = 2**-(N+1)*100 #\n",
    "print 'Percentage of quantization error of A/D converter is = %0.4f'%per_Qp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.3 Pg 351"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "charging time of capacitor  is = 128.00  u sec\n",
      "the integrator output is = -5.44  V\n",
      "the decimal output of a dual slope A/D converter is = 217.60    = 218\n",
      "The binary output of a dual slope A/D converter is = 11011010\n"
     ]
    }
   ],
   "source": [
    "# to determine the binary output of the 8-bit dual slope A/D converter\n",
    "Vin = 8.5 #\n",
    "VR = 10 #\n",
    "f = 2 #  #MHz\n",
    "N = 8 #\n",
    "C = 0.1*10**-6 #\n",
    "R = 2*10**3 #\n",
    "\n",
    "# the output of integrator is defined as \n",
    "# Viao(T1) = -(Vin/R*C)*T1 #\n",
    "\n",
    "# charging time of capacitor \n",
    "T1 = 2**N/f #\n",
    "print 'charging time of capacitor  is = %0.2f'%T1,' u sec'\n",
    "\n",
    "# the integrator output\n",
    "T1 = T1*10**-6 #\n",
    "Viao =-(Vin/(R*C))*T1#\n",
    "print 'the integrator output is = %0.2f'%Viao,' V'\n",
    "\n",
    "# the binary output of a dual slope A/D converter\n",
    "Bn = (2**N*Vin)/VR#\n",
    "print 'the decimal output of a dual slope A/D converter is = %0.2f'%Bn,'   = 218'#\n",
    "\n",
    "Bn=218#\n",
    "Bn = bin(Bn) #\n",
    "print 'The binary output of a dual slope A/D converter is =',Bn[2:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.4 Pg 352"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Resolution of an A/D converter is = 0.0037  V \n"
     ]
    }
   ],
   "source": [
    " # to determine the resolution of 12-bit A/D converter\n",
    "N =12 #\n",
    "Vin = 15 #\n",
    "\n",
    "# Resolution of an A/D converter\n",
    "Resolution = Vin/(2**N-1)#\n",
    "print 'Resolution of an A/D converter is = %0.4f'%Resolution,' V '\n",
    "#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.5 Pg 352"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The output time of a V/T converter is = 0.15  msec\n",
      "The duty cycle of V?T converter is = 2.00\n",
      "The output voltage of an integrator is is = -0.75  V\n"
     ]
    }
   ],
   "source": [
    "# to determine the output time and duty cycle of V/T converter\n",
    "Vin = 5 #\n",
    "C = 0.1*10**-6 # \n",
    "R = 10*10**3 #\n",
    "C1 = 100*10**-6 #\n",
    "\n",
    "# The output time of a V/T converter is given as\n",
    "T = (7.5*C1)/(Vin) #\n",
    "print 'The output time of a V/T converter is =',T*1000,' msec'\n",
    "\n",
    "TH = 0.075 #\n",
    "TL=TH # # we consider\n",
    "# The duty cycle of V?T converter\n",
    "D = (TL+TH)/(TH) #\n",
    "print 'The duty cycle of V?T converter is = %0.2f'%D\n",
    "\n",
    "# The output voltage of an integrator is define as\n",
    "Vio = -(Vin)/(R*C)*T #\n",
    "print 'The output voltage of an integrator is is = %0.2f'%Vio,' V'"
   ]
  }
 ],
 "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
}