{ "cells": [ { "cell_type": "markdown", "metadata": { "nbpages": { "level": 0, "link": "[](https://jckantor.github.io/CBE32338/04.03-PID_Control.html)", "section": "" } }, "source": [ "\n", "*This notebook contains material from [CBE32338](https://jckantor.github.io/CBE32338);\n", "content is available [on Github](https://github.com/jckantor/CBE32338.git).*\n" ] }, { "cell_type": "markdown", "metadata": { "nbpages": { "level": 0, "link": "[](https://jckantor.github.io/CBE32338/04.03-PID_Control.html)", "section": "" } }, "source": [ "\n", "< [4.1 Relay Control](https://jckantor.github.io/CBE32338/04.01-Relay-Control.html) | [Contents](toc.html) | [4.10 Lab Assignment: PID Control](https://jckantor.github.io/CBE32338/04.10-Lab-Assignment-PID-Control.html) >
"
]
},
{
"cell_type": "markdown",
"metadata": {
"nbpages": {
"level": 1,
"link": "[4.3 PID Control](https://jckantor.github.io/CBE32338/04.03-PID_Control.html#4.3-PID-Control)",
"section": "4.3 PID Control"
}
},
"source": [
"# 4.3 PID Control\n",
"\n",
"## References\n",
"\n",
"Karl J. Astrom and Richard Murray (2016). _Feedback Systems: An Introduction for Scientists and Engineers, 2nd Edition_. [Web version available]( http://www.cds.caltech.edu/~murray/amwiki/index.php/Second_Edition)."
]
},
{
"cell_type": "markdown",
"metadata": {
"nbpages": {
"level": 2,
"link": "[4.3.1 PID Simulation](https://jckantor.github.io/CBE32338/04.03-PID_Control.html#4.3.1-PID-Simulation)",
"section": "4.3.1 PID Simulation"
}
},
"source": [
"## 4.3.1 PID Simulation"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"nbpages": {
"level": 2,
"link": "[4.3.1 PID Simulation](https://jckantor.github.io/CBE32338/04.03-PID_Control.html#4.3.1-PID-Simulation)",
"section": "4.3.1 PID Simulation"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting slycot\n",
"Installing collected packages: slycot\n",
"Successfully installed slycot-0.2.0\n",
"Collecting control\n",
" Using cached control-0.7.0-py2.py3-none-any.whl\n",
"Requirement already satisfied: numpy in /Users/jeff/anaconda3/lib/python3.6/site-packages (from control)\n",
"Requirement already satisfied: scipy in /Users/jeff/anaconda3/lib/python3.6/site-packages (from control)\n",
"Requirement already satisfied: matplotlib in /Users/jeff/anaconda3/lib/python3.6/site-packages (from control)\n",
"Requirement already satisfied: six>=1.10 in /Users/jeff/anaconda3/lib/python3.6/site-packages (from matplotlib->control)\n",
"Requirement already satisfied: python-dateutil>=2.0 in /Users/jeff/anaconda3/lib/python3.6/site-packages (from matplotlib->control)\n",
"Requirement already satisfied: pytz in /Users/jeff/anaconda3/lib/python3.6/site-packages (from matplotlib->control)\n",
"Requirement already satisfied: cycler>=0.10 in /Users/jeff/anaconda3/lib/python3.6/site-packages (from matplotlib->control)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/jeff/anaconda3/lib/python3.6/site-packages (from matplotlib->control)\n",
"Installing collected packages: control\n",
"Successfully installed control-0.7.0\n"
]
}
],
"source": [
"!pip install slycot\n",
"!pip install control"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"nbpages": {
"level": 2,
"link": "[4.3.1 PID Simulation](https://jckantor.github.io/CBE32338/04.03-PID_Control.html#4.3.1-PID-Simulation)",
"section": "4.3.1 PID Simulation"
}
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import control.matlab as control\n",
"\n",
"# control constants\n",
"Kc = 0.85\n",
"tauI = 10000\n",
"\n",
"# control transfer function\n",
"Gc = Kc*control.tf([tauI,1],[tauI,0])\n",
"\n",
"# model transfer functions\n",
"Gp = control.tf([0.31],[16,1])*control.tf([1],[135,1])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"nbpages": {
"level": 2,
"link": "[4.3.1 PID Simulation](https://jckantor.github.io/CBE32338/04.03-PID_Control.html#4.3.1-PID-Simulation)",
"section": "4.3.1 PID Simulation"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[
"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}