I'm designing a PD controller so that the response due to unit step should exhibit an overshoot of 20% and steady-state error less 0.01. I've computed the parameters Kp and Kd and double-checked the result based on root locus design approach. This is the Simulink for a PD controller where kp=7130 and kd=59.388.

enter image description here

and the result is

enter image description here

I've computed the closed-loop pole $-38.694+75.5266j$ at the gain kd via another Matlab's script I've written. Matlab shows same closed-loop pole shown below

enter image description here

which agrees with my calculation for kd. The block diagram for the preceding system is

enter image description here

Now, I would like to use stepinfo() to obtain the performance of the system, hence:

clear all
num=[kd kp];
den=[1 (kd+18) (kp+72)];

which yields this information (i.e. obviously wrong)

    RiseTime: 0.0133
SettlingTime: 0.0910
 SettlingMin: 0.9182
 SettlingMax: 1.2584
   Overshoot: 27.1141
  Undershoot: 0
        Peak: 1.2584
    PeakTime: 0.0321

Why tf yields different results in comparison with Simulink.

enter image description here

Matlab's documentation shows no benefits info regarding this issue.

  • 1
    $\begingroup$ Can you clarify how you transformed the first block diagram into the second? Since you seem to somehow pull $K_p$ from the numerator into the denominator. $\endgroup$
    – fibonatic
    Oct 21 '18 at 3:25
  • $\begingroup$ @fibonatic, sorry it seems there is an error in the reduction, I will fix it in my post. however, with the correct block reduction, I'm still not getting the correct result. $\endgroup$
    – CroCo
    Oct 24 '18 at 17:48
  • $\begingroup$ @fibonatic updated the question. $\endgroup$
    – CroCo
    Nov 6 '18 at 23:17

After some investigation, there is a problem with the derivative block in Simulink. tf yields the correct response in my case. While the values of Kd has been designed to yields 20%, the system is not a second-order system because there is no zero-pole cancellation. The zero comes from the PD controller. The new system yields 27%.

The derivative block as shown in my post must be used with caution. The discussion can be found in What are the implications of using the Derivative block in Simulink?. The answer is provided by MathWorks Support Team staff which is

Here is a list of recommendations on the usage of the Derivative block:

1) Signals connected to the Derivative block should be continuous in time and amplitude

Derivative blocks amplify discontinuities when connected to a non-continuous signal. In example 'Example1_Discont.mdl', the slope of the input signal changes instantly. After being passed through a Derivative block, it becomes a peak.

2) Signals connected to the Derivative block should have a small derivative at t=0

‘Example2_Spike.mdl’ shows how a spike can occur in the second derivative after the first time step. This occurs because the Derivative block yields 0 by default at the initial time step, instead of 2*pi in this case. If this model is simulated again with a smaller time step, the spike amplitude increases.

3) Signals connected to the derivative should contain a low level of noise

In general, taking the derivative of a noisy signal tends to exacerbate the influence of that noise. Therefore, Derivative blocks in Simulink exhibit this behavior as well. In ‘Example3_Noise.mdl’, the noise gets amplified in the output, to the point where the derivative of the sine wave is not recognizable. By using a filtered derivative transfer function which filters out higher frequencies, a much better result can be obtained in the example.

If your model cannot respect the above guidelines, you might want to consider the following alternatives:

a) Rearranging the equations

Typically, a system's best-form mathematical model exclusively involves integrators (i.e., no derivatives). It is usually possible to design the model in such a way that Derivative blocks are never needed. In 'Example4_BestForm.mdl', the "naive" first approach involves a Derivative block; however, the second approach avoids having to compute the derivative.

b) Including the derivative into a transfer function

If a Derivative block and another Transfer Function block are in series, it may be possible to remove the Derivative block and multiply the numerator of the transfer function by ‘s’ (see ‘Example5_InSeries.mdl’, where the magnitude of the error is very small compared to the magnitude of the output signal).

c) Filtered derivative

The Derivative block can be replaced with a transfer function of the form G(s) = s/(tau*s+1), where ‘tau’ is a time constant which should be small compared to the dominant time constant of the system, to avoid filtering out important system dynamics. ‘Example6_Filtered.mdl’ contrasts this transfer function with the Derivative block.

  • Additional note:

How is the derivative part of the PID controller implemented in Simulink? It does not use a Derivative block, but instead implements a filtered derivative similar to the one described above. In a model including a PID Controller block, right-click on the block and select ‘Look Under Mask’ to see the exact implementation of the controller, and in particular its derivative part.

The credit goes to @Matteo Ragni. The actual implementation for the derivative block is provided by Matteo.


I think you're having trouble in your block diagram reduction. I (ironically) don't actually have the control system toolbox, but consider the following maths:

Your starting equation:

$$ \boxed{K_p + K_ds}\rightarrow \boxed{\frac{1}{\left(s+6\right)\left(s+12\right)}} $$

You can "rephrase" your $K_p$ as $\left(K_p\left(\frac{\frac{1}{K_p}}{\frac{1}{K_p}}\right)\right)$, which reduces to $\frac{1}{\frac{1}{K_p}}$.

It looks almost like instead of multiplying the denominator by $\frac{1}{K_p}$ that you're instead just adding $K_p$ to the denominator. Then I think that things are further complicated by not distributing; it looks like you're applying the $K_p$ term to your plant, then taking that result and multiplying that by the $K_d$ term.

To put it a little clearer, it looks like you're doing something like:

$$ \boxed{A + B}\rightarrow\boxed{C}\\ \boxed{B}\rightarrow\boxed{AC}\\ \boxed{BAC}\\ $$

when the right answer should actually be the distributed: $$ \boxed{A+B}\rightarrow\boxed{C}\\ \boxed{\left(A+B\right)\left(C\right)} \\ \boxed{AC + BC}\\ $$

So, starting out with rephrasing the proportional gain: $$ \boxed{\frac{1}{\frac{1}{K_p}} + K_ds}\rightarrow \boxed{\frac{1}{\left(s+6\right)\left(s+12\right)}} \\ $$

Then distribute the terms:

$$ \boxed{\left(\frac{1}{\frac{1}{K_p}} + K_d s\right) \left(\frac{1}{\left(s+6\right)\left(s+12\right)} \right)} \\ $$

(I'll drop the boxes from here)

$$ \frac{1}{\frac{1}{K_p}}\left(\frac{1}{\left(s+6\right)\left(s+12\right)} \right) + K_d s \left(\frac{1}{\left(s+6\right)\left(s+12\right)}\right) \\ $$

Notice here that the left term is modifying the denominator, but the right term isn't. You need common denominators to add numerators, so you'll have to modify the right term by the same $\frac{\frac{1}{K_p}}{\frac{1}{K_p}}$:

$$ \frac{1}{\frac{1}{K_p}}\left(\frac{1}{\left(s+6\right)\left(s+12\right)} \right) + K_d s\left(\frac{\frac{1}{K_p}}{\frac{1}{K_p}}\right) \left(\frac{1}{\left(s+6\right)\left(s+12\right)}\right) \\ $$

Distribute the $K_d s$:

$$ \frac{1}{\frac{1}{K_p}}\left(\frac{1}{\left(s+6\right)\left(s+12\right)} \right) + \left(\frac{K_d s\frac{1}{K_p}}{\frac{1}{K_p}}\right) \left(\frac{1}{\left(s+6\right)\left(s+12\right)}\right) \\ $$

A crude cleanup now to combine terms:

$$ \frac{1}{\frac{1}{K_p}}\left(\frac{1}{\left(s+6\right)\left(s+12\right)} \right) + \left(\frac{\frac{K_d}{K_p}s}{\frac{1}{K_p}}\right) \left(\frac{1}{\left(s+6\right)\left(s+12\right)}\right) \\ $$ $$ \frac{1}{\frac{1}{K_p}\left(s+6\right)\left(s+12\right)} + \frac{\frac{K_d}{K_p}s}{\frac{1}{K_p}\left(s+6\right)\left(s+12\right)} \\ $$

$$ \frac{1+\frac{K_d}{K_p}s}{\frac{1}{K_p}\left(s+6\right)\left(s+12\right)} \\ $$

Now you have it in a non-standard form because the $s$ in the numerator has a coefficient that's not $1$, so get it to one by:

$$ \left(\frac{\frac{K_p}{K_d}}{\frac{K_p}{K_d}}\right)\left(\frac{1+\frac{K_d}{K_p}s}{\frac{1}{K_p}\left(s+6\right)\left(s+12\right)}\right) \\ $$

Then that reduces to:

$$ \frac{s+\frac{K_p}{K_d}}{\frac{1}{K_d}\left(s+6\right)\left(s+12\right)} \\ $$

I compared step results from your original and the above and they're similar, but not quite exactly the same. As I mentioned, I can't use the tf functions, etc. in Matlab, but hopefully this helps you out!

  • $\begingroup$ You're right I've made a mistake but still tf is not getting providing the correct result. It seems I need to put it a specific form. $\endgroup$
    – CroCo
    Oct 20 '18 at 13:59
  • $\begingroup$ @CroCo - what are your step results with the new equation? $\endgroup$
    – Chuck
    Oct 20 '18 at 22:33
  • $\begingroup$ It has incorrect response. $\endgroup$
    – CroCo
    Oct 20 '18 at 22:36
  • $\begingroup$ which software did you use for computing the response? $\endgroup$
    – CroCo
    Oct 28 '18 at 22:06
  • $\begingroup$ @CroCo - I used Simulink to do the before/after step test with the transfer function blocks. I combined/reduced the diagram by hand. $\endgroup$
    – Chuck
    Oct 29 '18 at 12:36

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.