Matlab Derivative block analysis and filter design

In summary, the author is asking how to choose the value of fb for a filter. The author has a controller which will control an AC motor. In the controller, a stage comes where he needs to use a derivative block before point 'B'. The derivative block adds some noise and fluctuation to the output of the system, and the author got the reason why it happens. The reason is that 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
  • #1
Abdul Wali
33
0
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:

Y(s)/X(s)=s

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:
Physics news on Phys.org
  • #2
Isn't this same question as your "design high pass filter..." thread yesterday ?
 
  • Like
Likes Abdul Wali
  • #3
jim hardy said:
Isn't this same question as your "design high pass filter..." thread yesterday ?
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.
 
  • #4
Abdul Wali said:
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.
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.

Abdul Wali said:
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.
 
  • Like
Likes Abdul Wali
  • #5
donpacino said:
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.
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.
 
  • #6
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..
http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&section=SystemAnalysis
http://lpsa.swarthmore.edu/Bode/PhaseApprox.html

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:
  • Like
Likes Abdul Wali
  • #7
Abdul Wali said:
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.

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.
https://gyazo.com/55a0d002dcb832bee4b7afdc0c9e66a3

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.
 
  • Like
Likes Abdul Wali
  • #8
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
https://gyazo.com/ae10024783cfed770cc3122ca5bc4583

when I change that to a timestep of 1 second, you can see the peak amplitude increase to slightly less than 380
https://gyazo.com/6cf33f021b99b7fe27116d9d308a1ea2

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:
  • Like
Likes Abdul Wali
  • #9
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 can't help further.
 
  • Like
Likes Abdul Wali
  • #10
donpacino said:
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.
https://gyazo.com/55a0d002dcb832bee4b7afdc0c9e66a3

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.
@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?
 
  • #11
Abdul Wali said:
@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?

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 here's 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.
 
  • Like
Likes Abdul Wali
  • #12
donpacino said:
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 here's 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 analogue and digital filter would be essentially the same.
@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)
 

1. What is a Matlab Derivative block analysis?

A Matlab Derivative block analysis is a tool used for analyzing and designing filters in Matlab. It allows for the calculation of derivatives of signals and can be used for tasks such as differentiation, smoothing, and noise reduction.

2. How do I use the Matlab Derivative block analysis?

To use the Matlab Derivative block analysis, you need to first define the input signal and the desired parameters for the filter. Then, you can apply the derivative block to the signal and adjust the parameters to achieve the desired results. The output signal will be the filtered signal.

3. What types of filters can be designed with the Matlab Derivative block analysis?

The Matlab Derivative block analysis can be used to design a variety of filters, including low-pass, high-pass, band-pass, and band-stop filters. It can also be used for designing different types of digital filters, such as IIR and FIR filters.

4. Can the Matlab Derivative block analysis be used for real-time analysis?

Yes, the Matlab Derivative block analysis can be used for real-time analysis. By using the "Real-Time" option in the block parameters, the filter can be designed and applied to a live input signal in real-time.

5. Are there any limitations to the Matlab Derivative block analysis?

One limitation of the Matlab Derivative block analysis is that it can only be used for signals with a finite length. It also may not be suitable for analyzing highly complex signals or signals with a lot of noise, as it may not provide accurate results in these cases.

Similar threads

Replies
14
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
11
Views
2K
  • Electrical Engineering
Replies
1
Views
2K
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
Replies
13
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top