In [3]:
# Import the needed Packages
import control as cn
import slycot as sc
import numpy as np
import Algorithms as alg
#Plotting
import bokeh.plotting as bk
import bokeh.io as bi
#__version__
from bokeh.io import export_svgs
bi.output_notebook()
In [42]:
# Create the system
num = [[[1], [2]],[[1], [1]]]
den = [[[1., 1.], [1.,3.]],[[1.,1.], [1.,1.]]]
G = cn.tf(num,den)
# Create the FOTD Model
# Store Parameter
K = np.zeros((2,2))
T = np.zeros((2,2))
L = np.zeros((2,2))
for outputs in range(0,2):
for inputs in range(0,2):
y,t = cn.step(G,None,0.0,inputs,outputs)
u = np.ones_like(y)
# Create the Parameter
K[outputs][inputs],T[outputs][inputs],L[outputs][inputs] = alg.Integral_Identification(y,u,t)
In [40]:
# Create a decentralised Controller
KY,KR = alg.Control_Decentral(K,T,L)
# Create a MIMO PID Controller
num_p = np.ones((2,2,1)).tolist()
num_i = np.ones((2,2,1)).tolist()
num_d = np.ones((2,2,2)).tolist()
den_p = np.ones((2,2,1)).tolist()
den_i = np.ones((2,2,2)).tolist()
den_p = np.ones((2,2,2)).tolist()
for outputs in range(0,2):
for inputs in range(0,2):
num_p[outputs][inputs][-1] =
den[outputs]
In [99]:
# PI Controller
pi = cn.tf([5],[1])+cn.tf([10],[1,0])
# Convert
pi = cn.tf2ss(pi)
# Append -> MIMO Controller
pi_mimo = cn.bdalg.append(pi,pi)
pi_mimo
Out[99]:
In [100]:
# Make a feedback sys
A = np.zeros((2,2))
B = A
C = A
D = np.eye(2)
fb = cn.ss(A,B,C,D)
# Connect for 2DOF controller
cn.feedback(cn.tf2ss(G),pi_mimo)*pi_mimo
# Connect for 1 DOF controller
cn.ss2tf(cn.feedback(cn.tf2ss(G)*pi_mimo,fb))
Out[100]:
In [ ]:
# Ablauf
# System erstellen
# Sprungantwort messen
# K,T,L
# Controller Design
# Controller Erstellen
# SS Transformation
# Feedback
# Performance
# SVD
# min max