# Calculating PID gains analytically on a first order plant (RL Load) - is this possible?

Edit: Just for a bit of context. I have another higher order plant model that has a derivative branch in its control. I thought I'd just implement PID control on the current in an RL load I have just to get started with writing the derivative control branch in software (as a preliminary step).

I wanted to design a PID controller for an RL load (or any other first order system) through the pole placement method. Having wrote out the equations, I realise that you end up with a system of 3 equations and 2 unknowns.

Hence, it seems like can't get an analytical solution for the P, I and D gains for a controller on a first order plant.

I was wondering if anyone had encountered a situation like this before? Can I get a finite analytical solution for my PID gains?

Below is my working out:

Here are my plant and controller equations: $$G_{P} = \frac{1}{sL + R} \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;G_{C} =\frac{s^2K_{D}+sK_{P}+K_{I}}{s}$$ Below are my open loop and closed loop equations: $$G_{OL} = \frac{s^2K_{D}+sK_{P}+K_{I}}{s(sL + R)}$$ Below is my closed loop equation: $$G_{CL} = \frac{G_{OL}}{1+G_{OL}}$$ Expanding terms, this gives: $$G_{CL} =\frac{K_{D}s^2+K_{P}s+K_{I}}{s^2(L+K_{D})+s(R+K_{P})+K_{I}}$$ Rearranging the characteristic equation in the standard form, I get:

$$C.E = s^2 + s(\frac{R+K_{P}}{L+K_{D}}) + \frac{K_{I}}{L+K_{D}}$$ Now equating the characteristic equation to the standard form of a second order equation, I obtain the following equations:

$$(\frac{R+K_{P}}{L+K_{D}}) = 2\zeta\omega_{n}\;\;\;\;\;\;\;\;\;\;\;\frac{K_{I}}{L+K_{D}} = \omega_n^2$$ Assuming I select my $$\\omega_{n}\$$ and $$\\zeta\$$ and I know my R and L, then I have 3 equations with 2 unknowns.

Given that's the case, there are infinitely many solutions. How would I then go about selecting my gains analytically?

• Why don't you use a (free) simulator to solve this and adjust the three variables to get the step characteristic that is most desirable to you. Commented Oct 27, 2022 at 10:51
• I was more curious to how you'd approach this analytically - so as to get a better understanding Commented Oct 27, 2022 at 11:50
• When doing state space controls one can directly assign the poles with a technique called "pole placement". I can throw together an answer on the weekend relating to this if no one gets to it first. en.wikipedia.org/wiki/Full_state_feedback Commented Oct 27, 2022 at 16:27

The problem with using the usual form of the block diagram of the PID controller is that when you derive the closed loop transfer function you are left with zeros (values of s in the numerator). This very much complicates the issue.

If you use the form of block diagram below, known as an I-PD controller, when you derive the closed loop transfer function you will find that there are no zeros in the numerator. This makes life much simpler. The I-PD form of block diagram will perform the control process just like the more usually seen PID system block diagram.

To derive the overall closed loop transfer function find the closed loop transfer function of the smaller loop which then becomes a block in the forward loop of the larger closed loop. You then find the closed loop transfer function of the larger loop.

Once you have derived the overall closed loop transfer function you will find that it has no zeros which is good.

Next you need to derive a closed loop transfer function of the desired system with the desired behaviour which has poles in positions on the s-plane for the required values of zeta and wn. (zeta and wn are calculated from the usual equations for the desired rise time and overshoot in the step response). This is basically just a matter of writing out the denominator in standard form with the values of zeta and wn included in the coefficients.

So, now you should have two closed loop transfer functions, one for the I-PD controller and one for the system which has your desired behaviour in terms of rise-time, overshoot etc.

It is now just a matter of equating coefficients between the denominators of the two transfer functions to find the values of Kp, Ki and Kd.

1 = the s^2 coefficient, 2 * zeta * wn = the s coefficient and wn^2 = the last term.

Using those values for the three gains in the I-PD controller will ensure that the I-PD controller performs like the system with your desired transfer function which you generated.

Just a note. You will find that a three term controller has more control than needed for a first order system. If you go through the whole process again but replacing the Kp+Kds block by one with just Kp (a two term controller) you should find that you have complete control over the pole positions with just Kp and Ki in your final system (PI controller). The third term (Kd) would be required for complete control over the pole positions for higher order systems.

In response to your edit mentioning a higher order system....

For a higher order system it is more complicated to derive the desired closed loop system transfer function ready for coefficient equating.

The technique for a higher order system is to approximate the higher order closed loop system by a second order closed loop system if the closed loop system is higher than second order. You would do this by drawing (on a sketch of the s-plane) a pair of complex conjugate poles in the positions which give the required zeta and wn (values for zeta and wn would be derived using the standard equations for rise time and overshoot).

In order to approximate a higher order system by a second order system you would then place the remaining poles way out to the left (on the s-plane) so that they have little effect on system behaviour and you can then treat the system as dominant second order and use values for zeta and wn to place the two dominant poles.

zeta is equal to the cosine of the angle which the real axis makes with the vector from the origin to the pole and wn is the length of that vector. You can now, using simple trigonometry calculate the values of the poles (pole positions) For a third order systems you would have 3 pole positions, S1 = -a+jb, S2 = -a-jb and S3 = -c+j0 where c is much larger than a.

With the 3 pole positions set you should be able to generate the denominator of your desired system's 3rd order transfer function using the reverse process to finding the pole positions from the characteristic equation.

Lastly its a matter of equating coefficients as before to find the values of Kp, Ki, and Kd.

This analytical method can work well, the main problem with it can be that you need to know (or can obtain experimentally - frequency response) the transfer function of the plant. If the plant's transfer function is unavailable then it's necessary to resort to empirical methods of tuning the PID controller such as, for example, the Ultimate Cycle tuning method (Ziegler & Nichols).

• Hi there James, Thank you for your reply. Aren't the denominators for the I-PD controlled system and the PID controlled system transfer functions the same though? Which leads you on to the same problem again. I just got the transfer function for the I-PD case, and it's: $$G_{CL} = \frac{K_{i}}{s^2(K_{D}+L) + s(K_{P} + R ) + K_{i}}$$ Which leads you on to the same problem when you equate the coefficients with the standard form equation. Commented Oct 27, 2022 at 13:18
• @your_best_friend Assuming that transfer function is correct (I haven't checked it) I would now say KD+L = 1, KP+R = 2 * zeta * wn and Ki = wn^2
– user173271
Commented Oct 27, 2022 at 13:33
• Hi there James, you can't equate those two though because you haven't rearranged the characteristic equation in the standard form. To equate the two, you'd have to divide the whole denominator by KD + L, so that it matches the standard form. Commented Oct 27, 2022 at 13:45
• @your_best_friend The standard form is how you want the system to behave, your form above is what you actually have. If you equate the coefficients directly, as I have done above, you are forcing what you have to behave like what you want.
– user173271
Commented Oct 27, 2022 at 14:09
• Hi there James, thank you for your reply. I disagree with you as you need to rearrange the coefficients so that the characteristic equation has its leading term (s^2) without any coefficients. Commented Oct 27, 2022 at 19:17