0
|
1 |
#!/usr/bin/env python
|
|
2 |
# 9.17
|
|
3 |
import os, sys
|
|
4 |
sys.path += [os.getcwdu() + os.sep + ".." + os.sep + "python"]
|
|
5 |
|
|
6 |
import scipy as sp
|
|
7 |
from pp_pid import pp_pid
|
|
8 |
from pp_im import pp_im
|
|
9 |
from zpowk import zpowk
|
|
10 |
|
|
11 |
# test problem to demonstrate benefits of 2_dof
|
|
12 |
|
|
13 |
Ts = 1
|
|
14 |
k = 1
|
|
15 |
B = sp.convolve([1, 0.9], [1, -0.8])
|
|
16 |
A = sp.convolve([1, -1], [1, -0.5])
|
|
17 |
|
|
18 |
# closed loop characteristic polynomial
|
|
19 |
phi = [1, -1, 0.5]
|
|
20 |
|
|
21 |
Delta = 1 # Choice of internal model of step
|
|
22 |
control = 1
|
|
23 |
if control == 1: #/ 1-DOF with no cancellation
|
|
24 |
Rc, Sc = pp_pid(B, A, k, phi, Delta)
|
|
25 |
Tc = Sc
|
|
26 |
gamm = 1
|
|
27 |
else: #2-DOF
|
|
28 |
Rc, Sc, Tc, gamm = pp_im(B, A, k, phi, Delta)
|
|
29 |
|
|
30 |
# simulation parameters for stb_disc
|
|
31 |
zk, dzk = zpowk(k)
|
|
32 |
st = 1 # desired step change
|
|
33 |
t_init = 0 # simulation start time
|
|
34 |
t_final = 20 # simulation end time
|
|
35 |
xInitial = [0, 0]
|
|
36 |
C = 0
|
|
37 |
D = 1
|
|
38 |
N_var = 0
|