MATLAB: How to have a Pulse Generator block that will start from 0 phase whenever the enabled subsystem it resides in is enabled in Simulink 7.8 (R2011b)

enabledgeneratorphasepulseresetsimulinkstatesubsystem

I have a Simulink model which uses a Pulse Generator as one signal. I also have another signal which interrupts this pulse sometimes. After this interruption, I would like the pulse to restart from its zero point rather than continue running with the digital clock.
Is there any way to do this?

Best Answer

The ability to reset the state of a signal such as a Pulse Generator is currently not available in Simulink 7.8 (R2011b). This is because the Pulse Generator signal works under the following calculation, which is based on simulation time:
if (t >= PhaseDelay) && Pulse is on
Y(t) = Amplitude
else
Y(t) = 0
end
As a workaround, the pulse generator can be connected to an external time signal which is fed by a Counter Free-Running block. Whenever the subsystem is re-enabled, the counter is reset to zero to denote zero time and therefore zero phase.
One thing to note with this is that the counter is incremented by 1 at every time step, so the period of the pulse generator signal will need to be "normalized" to account for the simulation time step size.
Please see the attached model for more information on this workaround. The pulse generator signal is interrupted with a negative pulse. When the enabled subsystem is re-enabled after this interruption, the pulse begins from its zero-phase point no matter what time the simulation is in.
Related Question