I've been wrestling with this problem for about a week now, as a part of a year-long project. We're designing a controller for a specific reactor based on a model. After looking at this for a while, I still can't get this to work - so I would really appreciate it if I can get some help.

One of the published literature reviews that we've based heavily upon lists a PID controller into each separate components instead of a combined equation, like so:

$$ \begin{cases} P(n)=K_p[G(n)-target] \\I(n)=I(n-1)+\frac{K_p}{T_I}[G(n)-target]\\D(n)=K_pT_D\frac{dG}{dt}(n)\end{cases} $$

Simply combining the three components into the PID controller output: $$ PID(n)=P(n)+I(n)+D(n) $$

And from here, the author adds an additional layer of state feedback on top of the PID signal to get the final controller output applied on the system.

$$ \begin{cases} Q(n)=K_0R(n-1)+K_1Q(n-1)-K_2Q(n-2)\\R(n)=(1+\gamma)PID(n)-\gamma Q(n-1)\end{cases} $$

And R is the final "controller output." Here, the \$K_p\$ is the process gain, \$T_I\$ and \$T_D\$ are the integral and derivative gains, \$K_0, K_1\$ and \$K_2\$ are "gains" tuned for the state-feedback (immutable), and \$\gamma\$ is a constant, 0.5. \$G(n)\$ is the system state, \$Q(n)\$ is an estimated state that affects the model dynamics, and \$R(n)\$ is the actual final output that is sent to the plant.

I was trying to first convert the whole thing to a single controller transfer function, but I was told that simply adding them together won't work.

I was also tasked with finding a discrete state space representation of this controller. For this, I tried to change the \$\frac{dG}{dt}(n)\$ into \$G(n)-G(n-1)\$ to get rid of that issue.

Next, I tried to define a new state variable for the \$Q(n)\$ so that the \$Q(n-1)\$ and \$Q(n-2)\$ could be converted into first order.

I then tried to substitute the values into the PID controller, to get the \$G(n)\$ as the state variable. These efforts were all based on recommendations by my professor.

However, I'm still very much stuck, as I've been blindly following his directions without an overall vision to works on it. I thought it would be a simple matter of Tustin transformation - oh, how I was very wrong...

I'm quite frustrated, as after a week-long effort, I'm still stumped by what appears to be a simple problem.

If possible, may I humbly ask for your help on these two specific questions?

  1. Convert this controller into a single controller transfer function (as typically seen in any transfer function representation, i.e. \$G(s)=\frac{1}{s+1}\$)
  2. Convert this controller into a discrete state space representation, leaving the sampling rate as a variable?
  • \$\begingroup\$ MATLAB and Maple can do work these problems. I have both programs. I printed out your post and will try to work them. I did some of this in college. \$\endgroup\$ Aug 21, 2012 at 22:59
  • \$\begingroup\$ Can you give the title of the publication? \$\endgroup\$
    – Hazem
    Sep 12, 2017 at 13:27

1 Answer 1


It's not a complete answer but I hope that it could be of some help.

You could rewrite the first system as

$$ \begin{cases} P(n) = K_P E(n) \\ I(n) = I(n-1) + \frac{K_P}{T_I} E(n) \Delta t \\ D(n) = K_P T_D \frac{E(n) - E(n-1)}{\Delta t} \end{cases} $$

Where \$E(n) = G(n) - target(n)\$ and \$\Delta t\$ is your sampling interval. Note that \$T_D\$ and \$T_I\$ are not defined as gains. \$K_I = \frac{K_P}{T_I}\$ and \$K_D = K_P T_I\$ are respectively the integral gain and the derivative gain.

Now you can rewrite the system as a single function of the error.

$$ PID(n) = P(n) + I(n) + D(n) $$

$$ I(n-1) = PID(n-1) - P(n-1) - D(n-1) \\ = PID(n-1) - K_P E(n-1) - K_P T_D \frac{E(n-1) - E(n-2)}{\Delta t} $$

$$ PID(n) = K_P E(n) + PID(n-1) - K_P E(n-1) - K_P T_D \frac{E(n-1) - E(n-2)}{\Delta t} + \frac{K_P}{T_I} E(n) \Delta t + K_P T_D \frac{E(n) - E(n-1)}{\Delta t} \\ = PID(n-1) + K_P \left(\left(1 + \frac{\Delta t}{T_I} + \frac{T_D}{\Delta t} \right)E(n) - \left(1 + 2\frac{T_D}{\Delta t} \right)E(n-1) + \frac{T_D}{\Delta t} E(n-2) \right) $$

The second one is a bit more complex to rewrite as a single equation but you can do it in a similar way. The result should be

$$ R(n) = K_1 R(n-1) - (\gamma K_0 + K_2) R(n-2) + (1+\gamma) (PID(n) - K_1 PID(n-1) + K_2 PID(n-2)) $$

Now you only need to substitute the equation of the PID in order to obtain the equation of the regulator as function of the error.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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