How to initialise Goto variables used in enabled subsystems
16 次查看(过去 30 天)
显示 更早的评论
How can I initialise Goto variables in an enabled or switch case action subsystem?
I use the Goto blocks to reinitialize the integration variable when one subsystem is enabled, as described here: Building a Clutch Lock-Up Model
Now I can't find a clean way to initialize the goto variables when the model is started. As there is no previously active subsystem, no value can be passed to initialize the variable.
0 个评论
采纳的回答
Jim Riggs
2022-11-29
You should not need to "initialize" the Goto variables. The "Goto / from" blocks are simply a way to connect a signal without showing the connecting line. The Goto block gets its value from the signal line that is the input to the block.
3 个评论
Jim Riggs
2022-11-30
编辑:Jim Riggs
2022-11-30
I am still not sure if I understand your question, but it sounds like you want to initialize an integrator block which is inside an enabled subsystem. The subsystem may be called for a period of time, and then not. You want to perform this initialization upon the first of a series of calls to the enabled subsystem.
To initialize the integrator, you will need to create a logical signal outside of the enabled subsystem which indiates that the call to the subsystem is an initilizing one. This logic signal is passed into the enabled subsystem and is connected to the "reset" port of the integrator. The initial vaue for the integrator is connected to the "initial condition" port of the integrator. This is where you need to get creative.
Here is an example using two enabled subsystems.
The "Trigger Signal" (in blue) is a logical signal which is used to select Subsystem 1. the "NOT" operator insures that Subsystem 2 is not selected when subsystem 1 is active, and it also insures that one of the subsystems will always be active. (i.e. If subsystem 1 is not on, subsystem 2 is on)
Each Subsystem outputs a unique ID number (1 or 2) to identify which subsystem is active. The switch block selects only the active output from the two subsystems, i.e. the output of the switch block (signal "ID") has the value of the current active subsystem. Each subsystem compares the output of the switch ("ID") block to it's own ID. When they are the same, then the "reset" signal is "false", and the integrator continues operating. Only when they are different (i.e. the last pass throu the loop, a different subsystem was active) then the "reset" signal is "true" which is used to reset the integrator inside the subsystem. The initial condition for the integrator reset is also passed in from outside the subsystem. This can be an output from the other subsystem. (Note that, in this diagram, I am only showing the signals required for the integrator reset logic. Each subsystem will obviously have other inputs and outputs).
Note that the integrator blocks inside both subsystems have their parameters set as follows: "External reset = rising" and "Initial Condition source = external".
I hope that this helps.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subsystems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!