Electronic – Build a PID controller

analoghomeworkpid controller

I am trying to implement values for the resistors and capacitors values for a PID controller with the following transfer function:

\$ H(s)=2.9 + \large {3.5\over s} \normalsize + 0.64s\$

PID

I do know that the formula for \$2.9 = \large {R _{f}\over R_{i}} + {C_{i} \over C_{f}}\$ and \$ 3.5 = \large{1 \over R_{i}C_{f}}\$ and \$ 0.64 = R_{f}C_{i}\$.

I've tried many values for the resistors and capacitors but with no success. Any help would be welcomed.

Best Answer

All you have to do is make a system of equations from which you can extract the values for the elements:

$$\left\{ \begin{aligned} K_p&=\frac{R_f}{R_i}+\frac{C_i}{C_f} \\ K_i&=\frac{1}{R_iC_f} \\ K_d&=R_fC_i \end{aligned} \right.$$

I used the generic terms to solve symbolically. Since you have 4 unknowns and only 3 equations, you can impose one of the values, say \$C_i\$, and then solve for the elements as a function of \$C_i\$:

$$\begin{align} R_i&=\frac{K_p\pm\sqrt{K_p^2-4K_dK_i}}{2K_iC_i} \\ R_f&=\frac{K_d}{C_i} \\ C_f&=C_i\frac{K_p\mp\sqrt{K_p^2-4K_dK_i}}{2K_dK_i} \end{align}$$

This means that in order to have real-valued results, the condition \$K_p^2\ge4K_dK_i\$ must be satisfied. In your case, \$K_p^2=2.9^2=8.41\$ and \$4K_dK_i=4\cdot 3.5\cdot 0.64=8.96\$, so \$K_p^2-4K_dK_i=-0.55\$. That means you'll be getting imaginary numbers, so you need to recalculate your PID terms. How did you end up with those values? Don't forget that the transfer function of the opamp is with a negative sign.


Just to make it clear why you'll never get exactly the response in your transfer function, here are the values for an imposed value of Ci = 1, for a range of values for Kp = [2.5 : 0.1 : 3.5] (I've omitted the conjugates):

[ 2.5 ]:  Ri= 0.3571-0.2352i , Rf= 0.64 , Cf= 0.3675i+0.558 
[ 2.6 ]:  Ri= 0.3714-0.2119i , Rf= 0.64 , Cf= 0.3311i+0.5804 
[ 2.7 ]:  Ri= 0.3857-0.1846i , Rf= 0.64 , Cf= 0.2885i+0.6027 
[ 2.8 ]:  Ri= 0.4-0.1512i , Rf= 0.64 , Cf= 0.2362i+0.625 
[ 2.9 ]:  Ri= 0.4143-0.1059i , Rf= 0.64 , Cf= 0.1655i+0.6473 
[ 3.0 ]:  Ri= 0.4571 , Rf= 0.64 , Cf= 0.625 
[ 3.1 ]:  Ri= 0.3277 , Rf= 0.64 , Cf= 0.8719 
[ 3.2 ]:  Ri= 0.2955 , Rf= 0.64 , Cf= 0.9668 
[ 3.3 ]:  Ri= 0.273 , Rf= 0.64 , Cf= 1.047 
[ 3.4 ]:  Ri= 0.2554 , Rf= 0.64 , Cf= 1.119 
[ 3.5 ]:  Ri= 0.2409 , Rf= 0.64 , Cf= 1.186 

and magnitudes:

[ 2.5 ]:  Ri= 0.4276 , Rf= 0.64 , Cf= 0.6682 
[ 2.6 ]:  Ri= 0.4276 , Rf= 0.64 , Cf= 0.6682 
[ 2.7 ]:  Ri= 0.4276 , Rf= 0.64 , Cf= 0.6682 
[ 2.8 ]:  Ri= 0.4276 , Rf= 0.64 , Cf= 0.6682 
[ 2.9 ]:  Ri= 0.4276 , Rf= 0.64 , Cf= 0.6682 
[ 3.0 ]:  Ri= 0.4571 , Rf= 0.64 , Cf= 0.625 
[ 3.1 ]:  Ri= 0.3277 , Rf= 0.64 , Cf= 0.8719 
[ 3.2 ]:  Ri= 0.2955 , Rf= 0.64 , Cf= 0.9668 
[ 3.3 ]:  Ri= 0.273 , Rf= 0.64 , Cf= 1.047 
[ 3.4 ]:  Ri= 0.2554 , Rf= 0.64 , Cf= 1.119 
[ 3.5 ]:  Ri= 0.2409 , Rf= 0.64 , Cf= 1.186 

Notice how the complex numbers stop when \$K_p\ge 3\$, and how the magnitudes are unchanged until then. That's where the conditions has passed \$K_p=\sqrt{4K_dK_i}=\sqrt{4\cdot 3.5\cdot 0.64}=2.993\$. To verify, here's a plot of the difference between a proper transfer function (V(a)) and the magnitudes of the values for your PID (V(c)) implemented with the topology from your picture:

test

There is a small differene in the magnitude, and that's because the difference between your value, 2.9, and the critical point, 2.993, is small. If \$K_p=1.9\$, the values for the elements would be unchanged (their magnitudes, even though it's not proper to think this way), and the difference will be larger:

test2

This is why I said that if you are forced to choose this topology, in particular, then you will be limited to a certain ratio between \$K_p\$ and the other two. But, for example, if you use a parallel topology, it would work for any values. Or if you use an inductor in series with \$C_f\$ and give up \$C_i\$ (or emulated inductor).