-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
382 lines (341 loc) · 15.1 KB
/
index.html
File metadata and controls
382 lines (341 loc) · 15.1 KB
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>PID Controller Introduction</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/white.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/xcode.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>PID Controller Introduction</h1>
<p>
© 2018 Anton Lebedevich
</p>
</section>
<section>
<h2>Anton Lebedevich</h2>
<ul>
<li>data science engineer</li>
<li>loves time series and anomalies</li>
<li>switched to NLP and marketing campaign optimization</li>
<li>blogs at <a href="http://mabrek.github.io">mabrek.github.io</a>
</ul>
</section>
<section>
<h2>Motivation</h2>
<img class="stretch" src="img-static/request-rate-restart.png"/>
</section>
<section>
<h2>It Could Happen to You</h2>
<p><a href="https://en.wikipedia.org/wiki/Self-oscillation">wikipedia.org/wiki/Self-oscillation</a></p>
<ul>
<li>load balancers</li>
<li>autoscaling</li>
<li>flow control (e.g. Spark Streaming)</li>
<li>load testing</li>
<li>…</li>
</ul>
</section>
<section>
<h2>Mash Tun</h2>
<img class="stretch" src="img-static/mash-tun.jpg"/>
<p><a href="https://www.beermachines.ru/catalog/electric-brewing-systems/ibrew/ibrew-50-auto/">Ibrew-50-Auto</a></p>
</section>
<section>
<h2>Mash Tun Specs</h2>
<ul>
<li>50l</li>
<li>3000W</li>
<li>100W step regulation</li>
<li>digital thermometer</li>
</ul>
</section>
<section>
<h2>Simplified Physical Model</h2>
<pre><code class="Python" data-trim>
temperature_derivative = (
power
- heat_transfer_coefficient * surface
* (temperature - external_temperature)
) / heat_capacity
</code></pre>
<p><a href="https://en.wikipedia.org/wiki/Newton%27s_law_of_cooling">wikipedia.org/wiki/Newton's_law_of_cooling</a></p>
</section>
<section>
<img class="stretch" src="img-generated/Heat Cool.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/Heat Cool.png"/>
</section>
<section>
<h2>Relay Controller</h2>
<pre><code class="Python" data-trim>
if temperature[i] < setpoint[i]:
next_power = max_power
else:
next_power = 0
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/Relay Controller.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/Relay Controller.png"/>
</section>
<section>
<img class="stretch" src="img-generated/Relay Controller with Delay.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/Relay Controller with Delay.png"/>
</section>
<section>
<img class="stretch" src="img-generated/High Power Slow Relay.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/High Power Slow Relay.png"/>
</section>
<section>
<h2>Meet P from PID</h2>
<pre><code class="Python" data-trim>
error[i] = temperature[i] - setpoint[i]
next_power = - proportional * error[i]
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/low P from PID.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/low P from PID.png"/>
</section>
<section>
<img class="stretch" src="img-generated/medium P from PID.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/medium P from PID.png"/>
</section>
<section>
<img class="stretch" src="img-generated/high P from PID.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/high P from PID.png"/>
</section>
<section>
<h2>Clip Power Range</h2>
<pre><code class="Python" data-trim data-noescape>
error[i] = temperature[i] - setpoint[i]
next_power = - proportional * error[i]
<mark>if next_power > max_power:
next_power = max_power
elif next_power < 0:
next_power = 0</mark>
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/medium P with limits.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/medium P with limits.png"/>
</section>
<section>
<img class="stretch" src="img-generated/high P with limits.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/high P with limits.png"/>
</section>
<section>
<h2>Add Integral Part (I from PID)</h2>
<pre><code class="Python" data-trim data-noescape>
error[i] = temperature[i] - setpoint[i]
<mark>time_diff = time[i + 1] - time[i]
integral_error[i] = integral_error[i-1] + error[i] * time_diff</mark>
next_power = - proportional * error[i]
<mark>- integral * integral_error[i]</mark>
if next_power > max_power:
next_power = max_power
elif next_power < 0:
next_power = 0
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/PI from PID.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/PI from PID.png"/>
</section>
<section>
<img class="stretch" src="img-generated/PI cooling.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/PI cooling.png"/>
</section>
<section>
<h2>Integral Windup Protection</h2>
<pre><code class="Python" data-trim data-noescape>
error[i] = temperature[i] - setpoint[i]
time_diff = time[i + 1] - time[i]
integral_error[i] = integral_error[i-1] + error[i] * time_diff
next_power = - proportional * error[i]
- integral * integral_error[i]
if next_power > max_power:
next_power = max_power
<mark>integral_error[i] = integral_error[i-1]</mark>
elif next_power < 0:
next_power = 0
<mark>integral_error[i] = integral_error[i-1]</mark>
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/PI Anti Windup.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/PI Anti Windup.png"/>
</section>
<section>
<img class="stretch" src="img-generated/PI External Change.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/PI External Change.png"/>
</section>
<section>
<h2>Derivative (D from PID)</h2>
<pre><code class="Python" data-trim data-noescape>
error[i] = temperature[i] - setpoint[i]
time_diff = time[i + 1] - time[i]
integral_error[i] = integral_error[i-1] + error[i] * time_diff
<mark>derivative_error[i] = (error[i] - error[i - 1]) / time_diff</mark>
next_power = - proportional * error[i] \
- integral * integral_error[i] \
<mark>- derivative * derivative_error[i]</mark>
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/Derivative Kick.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/Derivative Kick.png"/>
</section>
<section>
<h2>Process Variable Derivative</h2>
<pre><code class="Python" data-trim data-noescape>
error[i] = temperature[i] - setpoint[i]
time_diff = time[i + 1] - time[i]
integral_error[i] = integral_error[i-1] + error[i] * time_diff
<mark>derivative_error[i] = (
temperature[i] - temperature[i - 1]
) / time_diff</mark>
next_power = - proportional * error[i] \
- integral * integral_error[i] \
- derivative * derivative_error[i]
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/Derivative Process.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/Derivative Process.png"/>
</section>
<section>
<h2>Complete PID</h2>
<pre><code class="Python" data-trim>
error[i] = temperature[i] - setpoint[i]
time_diff = time[i + 1] - time[i]
integral_error[i] = integral_error[i-1] + error[i] * time_diff
derivative_error[i] = (
temperature[i] - temperature[i - 1]
) / time_diff
next_power = - proportional * error[i] \
- integral * integral_error[i] \
- derivative * derivative_error[i]
if next_power > max_power:
next_power = max_power
integral_error[i] = integral_error[i-1]
elif next_power < 0:
next_power = 0
integral_error[i] = integral_error[i-1]
</code></pre>
</section>
<section>
<img class="stretch" src="img-generated/Complete PID.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/Complete PID.png"/>
</section>
<section>
<h2><a href="https://en.wikipedia.org/wiki/PID_controller"> wikipedia.org/wiki/PID_controller</a></h2>
<img class="stretch" src="img-static/PID_en.svg"/>
</section>
<section>
<img class="stretch" src="img-generated/PID Tuning.gif"/>
</section>
<section>
<img class="stretch" src="img-generated/PID Tuning.png"/>
</section>
<section>
<h2>Books to read</h2>
<ul>
<li>intro:
<ul>
<li><a href="http://greenteapress.com/wp/modsimpy">"Modeling and Simulation in Python"</a> Allen B. Downey</li>
<li>"Feedback Control for Computer Systems" Philipp K. Janert</li>
</ul>
</li>
<li>medium:
<ul>
<li>"The Control Handbook: Control System Fundamentals, Second Edition" William S. Levine</li>
<li><a href="http://www.cds.caltech.edu/~murray/amwiki/index.php?title=Main_Page">"Feedback Systems: An Introduction for Scientists and Engineers"</a> Karl J. Åström and Richard M. Murray</li>
</ul>
</li>
<li>advanced:
<ul><li>
"Asynchronous Control for Networked Systems" María Guinaldo Losada et. al.
</li></ul>
</li>
</ul>
</section>
<section>
<h2>Q&A</h2>
<p>
<p>Anton Lebedevich</p>
<p>mabrek@gmail.com</p>
<p><img src="img-static/Twitter_Logo_Blue.svg" height="25" width="25" style="margin: 0px 0px;"/><a href="https://twitter.com/widdoc">@widdoc</a></p>
<p><a href="https://mabrek.github.io/controllers-2018/">mabrek.github.io/controllers-2018/</a></p>
<p><a href="https://github.com/mabrek/controllers-2018/blob/master/controllers.ipynb">github.com/mabrek/controllers-2018/blob/master/controllers.ipynb</a></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
controls: false,
progress: false,
history: true,
center: true,
slideNumber: 'c/t',
transition: 'none',
width: 1900,
height: 980,
dependencies: [
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>