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

 采纳的回答

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.

更多回答(0 个)

产品

版本

R2023b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by