Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Derivative block analysis and filter design

  1. Jul 28, 2017 #1
    Hi, May someone helps me regarding this!?

    i have a controller which will control AC motor as attached. in this controller, a stage comes where I need to use a Derivative Block before point 'B' as shown in the attached picture " controller block diagram" [ https://drive.google.com/open?id=0B9NQhKDld_D4T0xwZTdZY1V6NHM ]. now this derivative block adds some noise and fluctuation to the output of the system and I got the reason that why it happens. the reason is below:

    "The Derivative block output might be very sensitive to the dynamics of the entire model. The accuracy of the output signal depends on the size of the time steps taken in the simulation. Smaller steps allow a smoother and more accurate output curve from this block. However, unlike with blocks that have continuous states, the solver does not take smaller steps when the input to this block changes rapidly. Depending on the dynamics of the driving signal and model, the output signal of this block might contain unexpected fluctuations. These fluctuations are primarily due to the driving signal output and solver step size.
    The exact linearization of the Derivative block is difficult because the dynamic equation for the block is y=˙u, which you cannot represent as a state-space system.
    The Laplace domain transfer function for the operation of differentiation is:


    This equation is not a proper transfer function, nor does it have a state-space representation.
    However, you can approximate the linearization by adding a pole to the Derivative to create a transfer function s/(c∗s+1). The addition of a pole filters the signal before differentiating it, which removes the effect of noise.
    A best practice is to change the value of c to1/fb, where fb is the break frequency for the filter
    " [ https://www.mathworks.com/help/simulink/slref/derivative.html#br3m9zv-1 ].

    The reference above is from official Matlab Website which is 100% verified by Matlab, so we can totally rely on it.

    Now my question here is if i follow the above reference and i replace my derivative block with filter s/(c∗s+1) where c=1/fc. HOW SHOULD I CHOOSE OR DESIGN THE VALUE OF fc?
    i also have the expected output signal characteristics and the bode plot as attached in the following link [ https://drive.google.com/open?id=0B9NQhKDld_D4T0xwZTdZY1V6NHM ].
    Last edited by a moderator: Jul 28, 2017
  2. jcsd
  3. Jul 28, 2017 #2

    jim hardy

    User Avatar
    Science Advisor
    Gold Member

    Isn't this same question as your "design high pass filter..." thread yesterday ?
  4. Jul 28, 2017 #3
    Dear @jim hardy No this is a different problem. the problem that posted yesterday was confusing and different, so please help with the solution of this problem if you can. the video that you sent me yesterday, i watched that and i don't think that can help me to solve this problem.
  5. Jul 29, 2017 #4


    User Avatar
    Gold Member

    This post looks identical to the one you were working yesterday.... The fluctuations the article talks about are only caused when you're working with discrete systems that have separate timestamps as seen below. Is your problem in the continuous domain or discrete domain? Have you tried decreasing your stepsize?

    that being said, didnt you already solve this particular problem and you were asking for why it happens. the solution is right in the matlab explanation you posted.

    A best practice is to change the value of c to1fb, where fb is the break frequency for the filter.

  6. Jul 29, 2017 #5
    yeah, the problem is in the continuous domain but the place where I am stocked since some days and my main question is that how to choose the value of fb for the filter?? @donpacino and i think i explained the problem very clear in post #1.
  7. Jul 29, 2017 #6

    jim hardy

    User Avatar
    Science Advisor
    Gold Member

    I see no clear evidence of a lead element in the Bode plot he said he wants to achieve ?
    It starts at 90 degrees and ends at 180 degrees

    The two responses he presented differ only in damping and neither is very far from 1.

    Since it's only a computer program
    I'd trial-and-error to get a feel for how fc affects response.
    Start at frequency where phase shift is 135 degrees and work out both directions.

    Here's a couple of math-rich tutorials..

    I need to take that course again. Obviously the methods of teaching it have improved over last five decades.
    I found Dorf , well, is obtuse a fair adjective ?

    old jim
    Last edited: Jul 29, 2017
  8. Jul 31, 2017 #7


    User Avatar
    Gold Member

    per the instructions on the page you link you just set fb to wherever frequency you want to linearize the derivative block, this will be determined by the frequencies you want to simulate which are dependent on your system. look at a bode plot to determine what frequencies you will need to capture. Its not a standard method of control, it is a workaround for using an ideal derivative function with conflicting timesteps.

    A reminder that all computers are descrete, so your continuous simulation is actually discrete, based on the timestep. Simply decrease the timestep and ensure all sample times are inherited (-1) to prevent the problems the article is talking about. If you are insistent on putting a low pass filter after the derivative block, simply follow the directions on the website, and set fb to your desired linearization frequency (whichever frequency you want your simulations to work at). double clicking on the derivative block will allow you to set this value as seen in the link below without having to add filter blocks in your system.

    I really want to stress that the filter is not a typical way of controlling systems like this, its only recommend for edge cases where you cannot avoid using an ideal derivative function in situations where you need to use less than ideal timesteps. please don't think its standard practice to put a high pass filter into a control system like this, just for your engineering development. What you're talking about is a simulation problem only. I also want to point out that from the sharp points on your output time domain plots you most likely need more resolution (smaller timesteps) anyways.
  9. Jul 31, 2017 #8


    User Avatar
    Gold Member

    I tried replicating your error. Unfortunately I can't the drift that you see in your model. I am however able to show you what happens to the models as you change the max allowable timestep.

    with a max timestep of 0.1 second, you can see that the peak amplitude is slightly less than 360 in response to a step of 300

    when I change that to a timestep of 1 second, you can see the peak amplitude increase to slightly less than 380

    I would guess that changing your simulation parameters will fix your problem. From your simulation it looks like you have very very large timesteps in comparison to the resolution you need, which means you'll be creating a 'discrete system' which could be causing your problems
    Last edited: Jul 31, 2017
  10. Jul 31, 2017 #9


    User Avatar
    Gold Member

    I also want add that if you look at your actually system results there is a significant delay between the step input and the system output rise. This delay is likely caused by a sampling issue. Check the sampling times of all your blocks as well as the timesteps. without you giving me more info I cant help further.
  11. Aug 4, 2017 #10
    @donpacino thanks for your help. BTW the filter that we are talking about this is a high pass filter, right? and is it an analogue filter or digital filter? there are many types of filter active, passive etc. i want to know that this is actually what type of filter?
  12. Aug 4, 2017 #11


    User Avatar
    Gold Member

    Something to think about. When you look at the derivative function in the frequency domain its gain is 's', which is a zero at the orgin. Like I already talked about a derivative function can impart noise at high frequencies if not properly handled. So we add a single pole (a low pass filter) to remove that noise. So even though it looks like a high pass filter and acts a high pass filter, it might be better to think of it as a derivative function followed by a low pass filter. Because that is how it is intended to function. When you implement the system you might create a high pass filter, but one needs to remember the goal is to take the derivative. Many many engineers have been burned by following the implementation of a system and not the intention of a system.

    So heres the deal, simulink is a mathematical modeling tool. This system can be implemented using many methods. It can be implemented using passive filters, active filters. The system can represent the mechanical nature of a horse drawn carriage (unlikely but my point is the math doesn't need to model a circuit). Whether it is passive or active depends on your intended implementation.

    analog or digital is a different story. technically this is an analog filter, because it is implemented in the continuous domain. But if one was building this in real life, you could implement it with a digital system using a high frequency the analog and digital filter would be essentially the same.
  13. Aug 4, 2017 #12
    @donpacino i got it. Just for general knowledge, in case if i want to select the fc for this filter so which of the following two concepts is correct?
    1) check the value of the lowest decade cutoff frequency and then increase or move the corner frequency out until the noise is removed
    2) check at the value of the highest cutoff frequency and reduce the frequency until the noise is removed

    By these two questions, i actually want to know that is the first priority given to the smaller cutoff frequency of the filter or highest? in other words generally is it better to have smaller cutoff frequency or higher cutoff frequency??

    what i understand from the following equation is that its always better to have higher cutoff frequency because the higher fc is the lower RC value will be (fc=1/2(pi)RC)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted