1

I implemented a class to identify ARX models in Python. The next step is the calculation of optimal PID parameters based on LQR. Apparently a continuous time model is required and I have the following possibilites:

  • transform the discrete time model to a continuous time model,
  • identify a continuous time model,
  • adapt the LQR approach to determine optimal PID parameters to the discrete time domain.

In Matlab the first two approaches are easily done, but I need them in Python. Does anybody know how Matlab implemented d2c and has a reference?

Yannick
  • 177
  • 1
  • 10

1 Answers1

2

There are a few options you can use python-control package or scipy.signal module or use harold (shameless plug: I'm the author).

Here is an example

import harold

G = harold.Transfer(1, [1, 2, 1])

H_zoh = harold.discretize(G, dt=0.1, method='zoh')

H_tus = harold.discretize(G, dt=0.1, method='tustin')

H_zoh.polynomials
Out[5]: 
(array([[0.00467884, 0.00437708]]),
 array([[ 1.        , -1.80967484,  0.81873075]]))

H_tus.polynomials
Out[6]: 
(array([[0.00226757, 0.00453515, 0.00226757]]),
 array([[ 1.        , -1.80952381,  0.8185941 ]]))

Currently zoh, foh, tustin, forward euler, backward euler is supported including undiscretizations. The documentation is found at http://harold.readthedocs.io/en/latest/index.html

percusse
  • 3,006
  • 1
  • 14
  • 28
  • Thank you for this answer. Right now, I turned to a different topic, but I will definitely look into `harold`. The undiscretization functionality sounds very interesting. I don't see this is possible using `python-control` or `scipy.signal`. – Yannick Jul 16 '18 at 07:12