Add Reset Function to Simscape Integrator Block
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Mathew Thorne
el 7 de Dic. de 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
Respuestas (3)
Nicolas Schmit
el 24 de En. de 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.
0 comentarios
David John
el 19 de Abr. de 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.
0 comentarios
Martin
el 9 de En. de 2023
The PS Integrator was updated in R2021a to provide this functionality. The source code is available for that block as well.
0 comentarios
Ver también
Categorías
Más información sobre Nonlinear Operators 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!