3
$\begingroup$

I have a question about Limiting the output of a transfer function in my system model. (Im fairly new to control theory and control systems)

I have a model where a PID controller is directly controlling the acceleration of a quadcopter. The quadcopter is "trying" to fly at a set hight.

Currently, I have the following: Copter PID

My question is: how can I limit the acceleration (the PID output) in the system?

I've tried the solution from question 133541. But that didn't work out for me. Mathematica tells me the transfer function of the PID controller cant be converted into a nonlinearStateSpaceModel? I don't really know why or how as I'm new to the field.

enter image description here

Thank you in advance!

$\endgroup$
1
$\begingroup$

The core problem is that NonlinearStateSpaceModel does not support descriptor systems.

When there are pure derivative terms, the state-space representation will need a singular descriptor matrix. This is supported by StateSpaceModel but not by NonlinearStateSpaceModel.

Through@{StateSpaceModel, NonlinearStateSpaceModel}@TransferFunctionModel[s, s]

enter image description here

A workaround is to do away with the derivative term or use a filter on the derivative terms. (These are done in applications where there is large sensor noise or abrupt reference changes.)

SystemsModelSeriesConnect[TransferFunctionModel[kp + ki/s + kd s/(s + α), s], 
 NonlinearStateSpaceModel[{{}, Clip[u]}, {}, u]]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Is there a mathematical reason NonlinearStateSpaceModels don't support pure derivative terms? Or is that just a Mathematica thing? Anyways the filter is working like a charm so thanks! :D $\endgroup$ – Levy Ehrstein Jul 24 at 15:07
  • $\begingroup$ It's not a mathematical reason. We did not get to it yet. $\endgroup$ – Suba Thomas Jul 24 at 15:12
0
$\begingroup$

Due to the double pole representing the copter, a simple PD will suffice. Follows a layman procedure to find an acceptable solution. The procedure consists in searching through a minimization procedure, the nearest response regarding a reference response to a step. Here the reference response is given by

stepref = InverseLaplaceTransform[(a^2 + b^2)/((s + a)^2 + b^2)/s, s, t]

the actual step response is obtained as follows:

PID = kp + ki/s + s kd;
COPTER = 1/s^2;
model = COPTER PID/(1 + COPTER PID)
stepresponse = InverseLaplaceTransform[model/s, s, t];

then follows the minimization procedure

parms = {a -> 2, b -> 2};
tmax = 4;
n = 20;
stepref0 = stepref /. parms;
tab = Sum[Abs[stepresponse - stepref0], {t, 0, tmax, tmax/n}];
sol = NMinimize[{tab, kp > 0, ki > 0, kd > 0}, {kp, ki, kd}]
stepresponse0 = stepresponse /. sol[[2]]

Follows a plot showing in blue the reference response and in red the response found.

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Is there some place where you are clipping the signal between PID and COPTER to be within 2 units? $\endgroup$ – Suba Thomas Jul 24 at 14:18
  • $\begingroup$ The acceleration limit at the PID can be obtained by conveniently choosing it's parameters. No need for Clip[] $\endgroup$ – Cesareo Jul 24 at 16:18
  • $\begingroup$ were a, b -> 2 arbitrarily choosen? Or where did that come from...being matching a $e^{-a*t}$ sin($\omega$ t) for the system $\endgroup$ – morbo Jul 26 at 11:49
  • $\begingroup$ Choosing $a, b$ we are choosing the needed unit step response for our COPTER + PID. $\endgroup$ – Cesareo Jul 26 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.