1

I have a Model with 2 charts created with code. My first chart is a test simulation which go to a TIMER EXPIRED state when TimerStatus = 1;. The error occurs with my timer chart :

When I try to simulate I get the error :

'ES_TestDS/Timer_principal' updates persistent or state variables while computing outputs, therefore it cannot be used in an algebraic loop. However, it is in a loop with the following blocks. For more information, see Algebraic Loops with MATLAB Function and Stateflow Blocks.

How can i fix this ? I read about Moore chart but i don't know how to convert mine into Moore chart.

Edit 1 : I have this warning in addition to the error :

If the inport 'ES_TestDS/Timer_principal/Start_Timer' of subsystem 'ES_TestDS/Timer_principal' involves direct feedback, then an algebraic loop exists, which Simulink cannot remove. Consider clearing the 'Minimize algebraic loop occurrences' parameter to avoid this warning.

Same for Stop_Timer

Edit : Maybe it can help if i show the connection between my timer and my chart

Lucas
  • 187
  • 10
  • 1
    Sounds like there's an [algebraic loop](https://www.mathworks.com/help/simulink/ug/algebraic-loops.html) in the model that contains your state chart that Simulink can't solve because it contains a persistent or state variable. You'll need to break the algebraic loop some how. – Phil Goddard Jul 26 '19 at 04:30

1 Answers1

0

I found a manual solution :

  • Go to Model Explorer and set the State Machine Type to Moore for the Chart which cause the error

enter image description here

  • Delete all entry, during, exit ... statements in your Chart

The problem is i still don't know how to set the State Machine Type with Matlab code if someone know

Edit : cht.StateMachineType = 'Moore';

Lucas
  • 187
  • 10