Borrar filtros
Borrar filtros

Rate Limiter with variable slew rate

5 visualizaciones (últimos 30 días)
Zdenek
Zdenek el 23 de Ag. de 2012
Hello, I need a Rate Limiter with variable slew rate in my Simulink model. Simulink library contains block Rate Limiter Dynamic but it runs only with fixed step solver. I use ode15s solver in my simulations. But I can't use fixed step solver because simulation then dramatically slows down.
So I tried to use Rate Limiter block from library and set Risign Slew Rate and Falling Slew Rate parameters of this block during simulation. I do it through a Matlab function block which executes this code:
ChangeSlewRate(u)
%#codegen
eml.extrinsic('get_param');
eml.extrinsic('set_param');
eml.extrinsic('num2str');
subsystemFullPath = 'MUV74_model/DesiredPowerRate;
blockName = [subsystemFullPath '/Rate Limiter'];
if (u > 0) % do not limit slew rate
set_param(blockName,'risingSlewLimit',num2str(inf));
set_param(blockName,'fallingSlewLimit',num2str(-inf));
else % set preddefined slew rate limits
risingSlewRate = get_param(subsystemFullPath,'RS');
fallingSlewRate = get_param(subsystemFullPath,'FS');
set_param(blockName,'risingSlewLimit',risingSlewRate);
set_param(blockName,'fallingSlewLimit',fallingSlewRate);
end
Where RS and FS are dialog parameters of DesiredPowerRate subsystem that contains Rate Limiter block and u is inputof DesiredPowerRate subsystem which depends rate change on. It runs very well but speed of simulation drops dramatically down. After reading some articles I realized that implementation of code in C MEX S-function will be probably faster.
My question is: How to set parameters of Rate Limiter block from C MEX S-function ? Will the simulation be faster ? Any other ideas how to do it better ?
Thank you

Respuestas (1)

Sachin Ganjare
Sachin Ganjare el 12 de Sept. de 2012
You can use the 'Acceleration' mode for simulation, which will generate code & mex file automatically, along with improvement in execution speed drastically.
Hope this helps!!!!!!!!

Categorías

Más información sobre Block and Blockset Authoring en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by