MIMO-Rosenbrock



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()


Loading BokehJS ...

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]


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-40-d6a5dc8e0fc4> in <module>()
      2 KY,KR = alg.Control_Decentral(K,T,L)
      3 
----> 4 PIY, PIR = cn.tf(np.zeros_like(NUM).tolist(),np.ones_like(DEN).tolist())
      5 # Create State space model for the controller
      6 # Make a Controller

TypeError: 'TransferFunction' object is not iterable

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]:
A = [[-0.  0.]
 [ 0. -0.]]

B = [[ 10.   0.]
 [  0.  10.]]

C = [[ 1.  0.]
 [ 0.  1.]]

D = [[ 5.  0.]
 [ 0.  5.]]

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]:
Input 1 to output 1:
      5 s^3 + 3 s^2 - 29 s - 30
--------------------------------------
s^4 + 3.7 s^3 - 0.14 s^2 - 29.3 s - 30

Input 1 to output 2:
1.776e-15 s^3 - 2.665e-16 s^2
-----------------------------
    s^4 - 1.4 s^3 - 3 s^2

Input 2 to output 1:
25 s^4 + 55 s^3 + 10.25 s^2 + 0.5 s - 1.137e-13
-----------------------------------------------
    s^4 + 3.7 s^3 - 0.14 s^2 - 29.3 s - 30

Input 2 to output 2:
  -1.5 s^3 - 3 s^2
---------------------
s^4 - 1.4 s^3 - 3 s^2

In [ ]:
# Ablauf 
# System erstellen
# Sprungantwort messen
# K,T,L
# Controller Design
# Controller Erstellen
# SS Transformation
# Feedback
# Performance
# SVD
# min max