Guy on Simulink

Simulink & Model-Based Design

What about a Resettable Subsystem?

UPDATE: Since R2015a, a resettable block is now shipping with Simulink... yeah!

https://www.mathworks.com/help/simulink/ug/reset-block-states-in-a-subsystem.html

------------------- original post --------------------

I often write about new features in Simulink. Today I take a different route and write about a feature that I would like to see in Simulink.

Please leave a comment below if you have similar needs and use cases.

My Need

In various applications I work on, I often end up needing to reset the states of multiple blocks at the same time. Some blocks like Integrator and Delay have reset ports which I can use for this purpose. However other blocks like State-Space, Transfer Function or Unit Delay do not.

Blocks with Reset Ports

If blocks have reset ports, I can arrange my diagram to reset all those blocks at the same time:

Resetting Blocks

This gives me the behavior I need, but if I have many blocks that need to be reset, this is a lot of routing. Also, there are multiple blocks that have states, but do not have an optional reset port.

Enabled Subsystem

What I am really dreaming of is a subsystem with a control port like the Enabled Subsystem, without the need to disable for one step to reset the states. With an Enabled Subsystem the control signal resets the states when it is re-enabled.

Enabled Subsystem

When simulating the model, we can see that this is not ideal because the system is disabled during one step:

Enabled Subsystem Results

Function-Call subsystem and Stateflow

Using Stateflow it is possible to reset the states in a subsystem without disabling it for one step.

To make that happen, we need to place the blocks inside a Function-Call Subsystem. We can then drive the subsystem with a Stateflow Chart. In the chart, bind an output event to a state and exit this state to trigger the reset of the states in the Function-Call Subsystem:

Function-Call Subsystem and Stateflow

Note, this solution will not work for blocks with continuous states like Transfer Function, State-Space, etc.

Now it's your turn

Do you see the need in your applications for a subsystem where the states of all the blocks inside would reset from a rising edge on a control port? Let us know by leaving a comment here.

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.