필터 지우기
필터 지우기

Rate Limiter with variable slew rate

조회 수: 5 (최근 30일)
Zdenek
Zdenek 2012년 8월 23일
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

답변 (1개)

Sachin Ganjare
Sachin Ganjare 2012년 9월 12일
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!!!!!!!!

카테고리

Help CenterFile Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by