Modeling Microwave in Stateflow-Simulink - How to give cooking time as an input from the simulink?

614 Views Asked by At

I am trying to model a microwave in MATLAB's stateflow module. I have modeled states like on-off (microwave can be turned on/off). In 'on' state, I have sub-states like 'door open', 'door close' and 'cooking'. I have set conditions on transitions correctly. I was just wondering whether is it possible to provide cooking time as an input (from simulink) to this stateflow microwave model; exactly like we press the keypad on real microwave. This time will be taken as input and the stateflow chart will remain in 'cooking' until that time and the input time will decrement to zero

2

There are 2 best solutions below

0
On BEST ANSWER

you can use a variable as cook_time in the states/transitions and while building the stateflow, it will detect it automatically, then you can specify it as Input from Simulink in the GUI.

0
On

You can find an example on how to pass an input from Simulink to state machines in Stateflow in the getting started videos here:

http://www.mathworks.com/products/stateflow/examples.html