Add Reset Function to Simscape Integrator Block

4 Ansichten (letzte 30 Tage)
William Hunt
William Hunt am 20 Jul. 2015
Beantwortet: Martin am 9 Jan. 2023
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 Kommentar
Mathew Thorne
Mathew Thorne am 7 Dez. 2017
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

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Nicolas Schmit
Nicolas Schmit am 24 Jan. 2018
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 am 19 Apr. 2022
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 am 9 Jan. 2023
The PS Integrator was updated in R2021a to provide this functionality. The source code is available for that block as well.

Kategorien

Mehr zu Nonlinear Operators finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by