Add Reset Function to Simscape Integrator Block

조회 수: 4 (최근 30일)
William Hunt
William Hunt 2015년 7월 20일
답변: Martin 2023년 1월 9일
I am trying to add a reset input to a custom integrator block using simscape. If the reset input is 1, the integrator will function normally and if the reset input is 0 it will reset to the initial condition. To achieve this I was attempting to set variable x to the initial condition (x0) when "reset == 0" but do not know how to populate the else condition to keep x the same if "reset == 1" ("if" must be accompanied by "else" in simscape language according to documentation). I tried setting x == x but this did not work. The code I have is written below. Any help would be greatly appreciated.
inputs
I = { 0, '1' }; % A:left
r = { 0, '1' }; % r:left
end
outputs
O = { 0, '1' }; % B:right
end
parameters
x0 = { 0, '1' }; % Initial condition
end
variables(Access = public)
x = { 0, '1' };
end
function setup
x = x0;
end
equations
if r <= 0
x == x0; % Reset x
else
%Do nothing
end
x.der == I * { 1, '1/s' };
O == x; % Set output
end
  댓글 수: 1
Mathew Thorne
Mathew Thorne 2017년 12월 7일
Hey,
Did you ever find a solution for this problem?
Using 2014b. Only solution I could think of was having an if statement, and setting the else to integrating a large positive or negative constant till i get close to zero.
But this defiantly not a good solution.
Mat

댓글을 달려면 로그인하십시오.

답변 (3개)

Nicolas Schmit
Nicolas Schmit 2018년 1월 24일
I am not a Simscape developer, but from what I know Simscape will not let you manually reset integrators. A work around is to use a Simulink integrator and Simulink-PS Converter blocks.

David John
David John 2022년 4월 19일
In 2018 it was true that Simscape did not let you reset integrators. In a more recent release, however, you can do it using the attached code at least since R2021a.

Martin
Martin 2023년 1월 9일
The PS Integrator was updated in R2021a to provide this functionality. The source code is available for that block as well.

카테고리

Help CenterFile Exchange에서 Nonlinear Operators에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by