Stateflow logical Issues using after(x,msec) statement

Hello Members,
PFA my model.
The intention of this model to delay the input signal with a configurable timer by the hardcoded delay count. My logic works fine when the input goes from 0 ->1.(able to see the out signal delayed by 2000ms), but on 1 -> 0, I am unable to see the delay between In and Out.
Anybody can point the logical error here? or help me to optimise the model using Stateflow.
Kind regards,
Joseph

 Respuesta aceptada

Mohammed Shaheen
Mohammed Shaheen el 25 de Sept. de 2026 a las 6:15
Hi Joseph,
The key requirement is that while waiting, output y must remember its last accepted. Currently, the chart runs every 1 ms and InitializeOutput is enabled. Therefore:
  1. Stateflow initializes y to 0.
  2. After the delay, ACTION_St assigns y=u.
  3. ACTION_St remains active for 100 ms.
  4. When it exits, no state assigns y.
  5. Stateflow initializes y back to 0.
As a workaround, Please do the following:
  1. Open the DELAY Stateflow chart.
  2. Click the chart background and open Property Inspector.
  3. Disable Initialize outputs every time chart wakes up (InitializeOutput).
  4. Initialize the output explicitly:
INIT_St/
y = 0;
Cur_St = 0;
I hope this helps.
Thanks,
Shaheen.

Más respuestas (0)

Productos

Versión

R2023b

Etiquetas

Preguntada:

el 22 de Sept. de 2026 a las 19:13

Comentada:

el 26 de Sept. de 2026 a las 21:12

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by