Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Initial State#753

Unanswered
Yangsjunqi asked this question inQ&A
Jul 31, 2022· 3 comments· 1 reply
Discussion options

Hi,
I was trying to test a simple feedback system with PID controller . Simulation can be easily done with the code below. However, I cant figure out how to specify the initial value (e.g. 10...) of response instead of 0 by default. Would you please tell the solution?
Thanks,
Junqi

def sys1(Kp,Ki,Kd):    G = control.tf([1],[1,1])    K = control.tf([Kd, Kp,Ki], [1,0])    S = control.feedback(G*K, 1)    d = np.linspace(0, 10, 100)    t, rec = control.initial_response(S, d)    return rec
You must be logged in to vote

Replies: 3 comments 1 reply

Comment options

If you would like the initial condition response, you need to provide the initial state from which you would like to simulate the system as an argument tocontrol.initial_response. You can do this by providing a third argument toinitial response:

t, y = control.initial_response(sys, T, X0)

Note, however, that since you are dealing with transfer functions, the "states" of your system are not well-defined. The state space representation of your system has three states (1 from the PID controllerK and two from the systemG), but the state space realization ofS is not well-defined.

A more common response for a transfer function is the step response, which you can obtain usingcontrol.step_response.

If you really want the initial condition response, change the next to last line of your function to be something like

t, rec = control.initial_response(S, d, [10, 10, 10])
You must be logged in to vote
1 reply
@Yangsjunqi
Comment options

Thanks for the quick response!
Actually I tried control.step_response and initial_response before as you advised, but didnt get the results I want. The observation is, when it is a open-loop system, the X0 argument works, but when it involves controller as a close-loop, things changed.

Comment options

Hi,
I have the exact same issue, simulating closed loop system. The X0 parameters changes nothing if not in the order of 10**8.
I found that the initial value of my system is X0 * 1.4/(2*10^8) (and it is not exactly that ?).
Also my system is non-linear (I reused the example"Simulating interconnections of systems" to connect a discrete controller to a continuous system), and I need to setX0 = [initVal * 2*10**8 / 1.14, initVal * 2*10**8 / 1.14], both states to the same value.

I have very little knowledge about simulation, and I really don't get why this behavior. If someone with more experience than me could explain how to set this X0 value.

Thanks !

You must be logged in to vote
0 replies
Comment options

@Dimethylebutane glad to hear that the simulation example for discrete-continuous systems was useful!

you usually don't want to use nonzero initial conditions. usually you are interested in driving your system, starting from zero, to a new desired position. or simulating what happens when a disturbance enters right before the plant. both of those involve zero initial conditions.

that said, if all of your systems are state space, then their states are ordered in the order you passed them intointerconnect. I'm not sure why your states need to be so big - they should match the states of the original system, if it was originally specified in state-space format. if any of your systems were transfer functions, then this will not work (see richard's comment above). maybe try a simpler system to get a feel for how your states work when specifying initial conditions.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
4 participants
@Yangsjunqi@murrayrm@Dimethylebutane@sawyerbfuller

[8]ページ先頭

©2009-2025 Movatter.jp