question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert simple LTI state-space feedback system from Simulink

See original GitHub issue

First of all, great work on this toolbox. We in the gravitational wave instrumentation community are trying to ditch MATLAB and use tools like this in Python to model control systems and dynamics. I’ve got what I think is a pretty basic question but I hope someone has some time to help. I hope this is the right place to post this sort of question.

I’m trying to convert a Simulink model for a triple-stage pendulum that looks like this…

Screenshot_20200325_095434

…into a python-control system. It’s a relatively simple model implemented as a state-space system (the red SSM100g block) with a few feedback loops and some input/output combining. I’ve got as far as implementing the ABCD matrices from the SSM100g model:

import numpy as np
from control import ss

A = [...] # 36x36 matrix
B = [...] # 36x24 matrix
C = [...] # 24x36 matrix
D = np.zeros((24, 24))

SUS_TRIPLE = ss(A, B, C, D)

This seems to work ok, I can plot transfer functions etc. with SUS_TRIPLE.freqresp(...) but now I’d like to combine some of the inputs and outputs into “higher level” inputs and outputs (act_1_x etc.) and add some feedback (turqoise gain and sum blocks) as per the screenshot above. I see there is a “Feedback interconnection” command but I don’t know whether it’s appropriate here. I also wonder if there is some way to abstract some of the low-level inputs/outputs of this state-space model into higher level ones, akin to Simulink’s “subsystem” blocks. In the end I’d like to have another system that I can again call .freqresp(...) on.

Is this possible to do? Are there perhaps some examples showing how to do this? I guess this is or will be a common task in the future, converting Simulink models to python-control. Any help would be appreciated!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bnavigatorcommented, Mar 27, 2020

Because linearize() numerically simulates the dynamics of the connected model and catches the feedback.

https://github.com/python-control/python-control/blob/6b24bb42a8da5b15cb79699e74fb33b30ba7935a/control/iosys.py#L549-L561

https://github.com/python-control/python-control/blob/6b24bb42a8da5b15cb79699e74fb33b30ba7935a/control/iosys.py#L1021-L1048

Depending on your system you still lose precision by converting to non-linear and performing these numerical calculations. Extending InterconnectedSystem to directly connect linear systems would be a good enhancement IMHO.

0reactions
SeanDScommented, Jan 15, 2021

@murrayrm Thanks for the feature implementations! I haven’t forgotten about this, hopefully I can make a PR for you soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement linear state-space system - Simulink - MathWorks
The State-Space block implements a system whose behavior you define as... ... Simulink® software converts a matrix containing zeros to a sparse matrix...
Read more >
Introduction: State-Space Methods for Controller Design
Key MATLAB commands used in this tutorial are: eig , ss , lsim , place , acker ... For a SISO LTI system,...
Read more >
State-Space Control Systems: The MATLAB®/Simulink ...
One motivation for the state-space formulation is to convert a coupled system of higher- order ordinary differential equations, for example, those representing ...
Read more >
Linear Feedback Control - Analysis and Design with MATLAB
i = 1,...,q,. (2.17) where fi(·) and gi(·) can be any nonlinear functions. For LTI systems, the state space expression of the system...
Read more >
State feedback and Observer Feedback
Theorem For the single input LTI system, ˙x = Ax + Bu, there is an invertible transformation. T that converts the system into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found