How to Filter a Commanded Position to have Velocity and Acceleration Limits in Simulink
Mostrar comentarios más antiguos
I want to filter a commanded position signal to limit (saturate) its velocity and acceleration. I made the following model, but it has issue with the initial conditions and drift. If the signal is not saturated, I want it to equal the commanded position signal. Any suggestions on how to best model this?

Respuesta aceptada
Más respuestas (1)
Captain Karnage
el 19 de Mayo de 2023
Editada: Captain Karnage
el 19 de Mayo de 2023
1 voto
I believe I have a much simpler solution if you'd like to see it.
First of all, for your velocity limit, use the built-in rate limiter block instead of derivative + saturation. That will take care of your velocity without the issue of initial conditions when you re-integrate it, and it's only one block.
Since you also want acceleration, you will need to do a derivate (to get velocity after the rate limit) + rate limiter (to limit the acceleration) then integral (to get position back).
Then what you can do for the integral step for your initial conditions is as follows: go to the "block parameters" and for "Initial condition source" select "external". This will add a port to your integrator to feed your initial conditions to so you don't lose them. See my example here:

Here is the integrator block setting:

Like Paul's answer, it's still a little off on the final position, but it's really close.
3 comentarios
Paul
el 19 de Mayo de 2023
Hi Captain,
I tried this approach compared to mine with the following parameters:
Input: sine wave, amplitude = 8, freuqency 2*pi/0.4.
Gains: w = 3*150*3; K1 = w^3; K2 = 3*w/K1; K3 = 3*w^2/K1;
Limits: Acceleration: -+1.5e4, velocity: -+100.
Initally I was running with the default solver settings. The auto selected solver for my approach was ode45. When I added your approach into the model, the auto selected solver was ode23t and the simulation ran incredibly, unbearably slow. Our results were pretty close to each other, just comparing scopes by eye. Then I forced the solver to be ode45 and the simulation ran as fast as it should and the results for positiion and velocity were very close to each other, though my approach tended to come off the rate limit a bit later, presumably due to the lag in the filter.
I try to avoid using Derivative blocks whenever possible.
Captain Karnage
el 19 de Mayo de 2023
Thank you for the analysis, Paul, I appreciate the comparison that I didn't have time for myself. I should have mentioned my default is ode45. I do find the auto selected solver is often not the best and I often use ode45 as the baseline to compare. Of course, I occaisionally run into a model that doesn't run well on it and have to pick something else.
Sonoma Rich
el 22 de Mayo de 2023
Categorías
Más información sobre Signal Generation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




