# What is wrong with my residue partial expansion method? (Transfer Function into State-Space Modal/Diagonal Form)

I'm using reference from here and here. This is Laplace transfer function of DC Control Speed System:

$$\frac{\omega(s)}{V(s)}=\frac{K}{(Js+b)(Ls+R)+K^2}$$

Where,
$$\omega$$ is the motor angular speed $$(rad/s)$$
$$V$$ is the voltage applied to the motor $$(Volt)$$
$$J$$ is the moment of inertia of the rotor $$(kg.m^2)$$
$$b$$ is the motor viscous friction constant $$(N.m.s)$$
$$K_e$$ is the electromotive force constant $$(V/rad/sec)$$
$$K_t$$ is the motor torque constant $$(N.m/Amp)$$
$$R$$ is the internal electric resistance $$(Ohm)$$
$$L$$ is the internal electric inductance $$(H)$$

In SI units, the motor torque and back emf constants are equal, that is, $$K_t = K_e$$; therefore, $$K$$ will be used to represent both the motor torque constant and the back emf constant.

I want to convert this transfer function into state-space canonical modal/diagonal form by using partial expansion residue method.

First, find the poles.

$$\frac{\omega(s)}{V(s)}=\frac{K}{(JL)s^2+(bL+JR)s+(bR+K^2)}$$

by using quadratic formula, the poles are:

$$s_1 = \frac{-(bL+JR)+\sqrt{(bL+JR)^2-4JL(bR+K^2)}}{2JL}$$

$$s_2 = \frac{-(bL+JR)-\sqrt{(bL+JR)^2-4JL(bR+K^2)}}{2JL}$$

Then, find the residues.

$$\frac{\omega(s)}{V(s)}=\frac{r_1}{(s-s_1)}+\frac{r_2}{(s-s_2)}$$

$$\frac{\omega(s)}{V(s)}=\frac{r_1(s-s_2)+r_2(s-s_1)}{(s-s_1)(s-s_2)}$$

$$\frac{\omega(s)}{V(s)}=\frac{(r_1+r_2)s-r_1s_2-r_2s_1}{(s-s_1)(s-s_2)}$$

$$\frac{K}{(Js+b)(Ls+R)+K^2}=\frac{(r_1+r_2)s-r_1s_2-r_2s_1}{(s-s_1)(s-s_2)}$$

$$K = (r_1+r_2)s-r_1s_2-r_2s_1$$

Thus, by eliminating both of the denumerator, there'll be two equations.

$$r_1+r_2=0 ...(1)$$

$$-r_1s_2-r_2s_1=K ...(2)$$

From equation $$(1)$$, there'll be one more equation.

$$r_2=-r_1 ...(3)$$

By substituting $$r_2$$ from equation $$(3)$$ into $$(2)$$, $$r_1$$ is known.

$$-r_1s_2+r_1s_1=K$$

$$r_1=\frac{K}{s_1-s_2} ...(4)$$

By substituting $$r_1$$ from equation $$(4)$$ into $$(3)$$, $$r_2$$ is known.

$$r_2=-\frac{K}{s_1-s_2}$$

Thus, here is my state-space model equations $$\dot{x}(t) = \left[\begin{matrix}s_1 & 0 \\ 0 & s_2\end{matrix}\right] x(t)+ \left[\begin{matrix}r_1 \\ r_2\end{matrix}\right] V(t)$$

$$y(t) = \left[\begin{matrix}1 & 1\end{matrix}\right] \left[\begin{matrix}\omega(t) \\ i(t)\end{matrix}\right]$$

Now, lets assume the constants value and plugging it in.

$$J = 0.01\, kg.m^2$$
$$b = 0.1\, N.m.s$$
$$K = 0.01\, N.m/A$$
$$R = 1\, Ω$$
$$L = 0.5\, H$$

The transfer function,

$$\frac{\omega(s)}{V(s)}=\frac{2}{s^2+12s+20.02}$$

The state-space,

$$\dot{x}(t) = \left[\begin{matrix}-2.0025 & 0 \\ 0 & -9.9975\end{matrix}\right] x(t)+ \left[\begin{matrix}0.00125 \\ -0.00125\end{matrix}\right] V(t)$$

$$y(t) = \left[\begin{matrix}1 & 1\end{matrix}\right] \left[\begin{matrix}\omega(t) \\ i(t)\end{matrix}\right]$$

Now here comes the problem,

J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;

s = tf('s');
laplace_motor = K/((J*s+b)*(L*s+R)+K^2); % transfer function model
[num,den] = tfdata(laplace_motor,'v'); % get the numerator and denumerator of it
[residues,poles,directs] = residue(num,den); % find its residues


By running the code above in MATLAB, I've just known that the correct residues value are $$r_1 = 0.2502$$ and $$r_2 = -0.2502$$.
It indicates that there is something wrong with my derivation above.
Where is my mistake?

If I convert my diagonal/model form above into transfer function using this code.

J = 0.01; b = 0.1; K = 0.01; R = 1; L = 0.5;
determinant_squared = sqrt( (b*L + J*R)^2 - 4*J*L*(b*R+K^2) );

s1 = ( -(b*L+J*R) + determinant_squared ) / (2*J*L);
s2 = ( -(b*L+J*R) - determinant_squared ) / (2*J*L);

r1 = K / (s1 - s2)  ;
r2 = - r1;

modal_A = [ s1 0 ; 0 s2];
modal_B = [ r1 ; r2 ];
modal_C = [1 1];
modal_D = 0;

G = ss(modal_A,modal_B,modal_C,modal_D);

[modal_num,modal_den] = ss2tf(modal_A,modal_B,modal_C,modal_D);
laplace_modal_motor = tf(modal_num,modal_den);


I got this, $$\frac{\omega(s)}{V(s)}=\frac{0.01}{s^2+12s+20.02}$$

Which is different from direct laplace model above by a factor of 200.

If I model it normally without using modal form by choosing the rotational speed and electric current as the state variables. $$\dot{x}(t) = \left[\begin{matrix}-\frac{b}{J} & -\frac{K}{J} \\ \frac{K}{J} & -\frac{R}{L}\end{matrix}\right] x(t)+ \left[\begin{matrix}0 \\ \frac{1}{L}\end{matrix}\right] V(t)$$

$$y(t) = \left[\begin{matrix}1 & 0\end{matrix}\right] \left[\begin{matrix}\omega(t) \\ i(t)\end{matrix}\right]$$

$$\dot{x}(t) = \left[\begin{matrix}-10 & -0.02 \\ 1 & -2\end{matrix}\right] x(t)+ \left[\begin{matrix}0 \\ 2\end{matrix}\right] V(t)$$

$$y(t) = \left[\begin{matrix}1 & 0\end{matrix}\right] \left[\begin{matrix}\omega(t) \\ i(t)\end{matrix}\right]$$

by running this code in MATLAB

J = 0.01; b = 0.1; K = 0.01; R = 1; L = 0.5;

ss_A = [-b/J   K/J ; -K/L   -R/L];
ss_B = [0 ; 1/L];
ss_C = [1 0];
ss_D = 0;
ss_motor = ss(ss_A,ss_B,ss_C,ss_D);

[ss_num,ss_den] = ss2tf(ss_A,ss_B,ss_C,ss_D);
laplace_ss_motor = tf(ss_num,ss_den);

[num,den] = tfdata(laplace_ss_motor,'v');
[residues,poles,directs] = residue(num,den);


The residues value are still $$r_1 = 0.2502$$ and $$r_2 = -0.2502$$

So where is my mistake?

• Hi! Very nice question setup. So in summary what you ask is that your partial fraction expansion didin't work (?) – Fat32 Oct 8 '18 at 20:14
• @Fat32 Thank you. Yes, I believe that my residue derivation was wrong – Unknown123 Oct 8 '18 at 20:18
• it's about denominator normalization... – Fat32 Oct 8 '18 at 20:47

The discrepancy between your derivation and matlab's computation results because of a convention mismatch you used during the partial fraction expansion:

Given that the function to be expanded is $$H(s)$$

$$H(s) = \frac{K}{As^2 + Bs + C}$$ then you should first convert it into the form

$$H(s) = \frac{K/A}{s^2 + (B/A)s + C/A}$$ and then apply the expansion as

$$H(s) = \frac{K/A}{s^2 + (B/A)s + C/A} = \frac{K/A}{(s-s_1)(s-s_2)} = \frac{r_1}{s-s_1} + \frac{r_1}{s-s_2}$$

then the residues can be found as : $$r_1 = \frac{K/A}{s_1 - s_2}$$ and $$r_2 = -r_1$$. Then you will get the same result that's returned from Matlab.

Note that the roots of $$As^2 + Bs+ C$$ and that of $$s^2 + (B/A)s + C/A$$ are the same.

• Aw, come on, just a tiny mistake, but ruins everything. I've tried to solve it for many hours, really, thank you very much – Unknown123 Oct 8 '18 at 21:05
• your welcome! I remember once having spent 2 days for if ( p = NULL) error in a while...:-)) – Fat32 Oct 8 '18 at 21:08