MATLAB: Having Trouble with enable/delay etc in Simulink

delayenableenabled subsystemssimulink

Hi Everyone,
I'll try to explain my problem as clear as I can: when you use an enabled subsystem that contains only a ramp function, the ramp will continue to develop with time even though the output signal of the subsystem will be held at a constant value while the subsystem is disabled. So the next time it is enabled, for instance if your initial value is 0 and you started disabled for 2 seconds leading to an enable situation at t=2, the output of the subsystem will be = 2 instead of 0 that I need. I imagined that changing the states when enabling in enable block to reset would solve my problem but I didn't see any difference. I thought I would need to use delays but the problem is that the enabled and disabled periods are variable and I can't wrap my head around this delay stuff and how to register time for it anyways.
My question is, is there any easier way to do this? any simple block that I don't know about and does the thing I want?
Thanks for your time,
Mike

Best Answer

As I understood, you want to synchronise the ramp generation with the condition output so that every time condition is enabled (0 to 1), ramp geneartion should re-start from 0.
Enabled subsystem always passes current status of output when it is enabled.
AFAIK, there is no block available directly which can generate resettable/re-startable ramp single depending upon condition.
But you can easily inplement your requirement using Matlab (previously Embedded Matlab) function block or using s-function. See a related Fex submission which can help you in implementing your own block.