increasing value in stateflow

hi all
i want to make condition STATEFLOW, like:
*V=10 X=1 Z=20
if S>=5 && S<=10
then Value V repeatly increase by the value of X until its reach value Z.
so, the value V later could be= 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 then go to next state after reach value Z=20.*
how we did it in stateflow??
thanks

 Respuesta aceptada

Gerd
Gerd el 11 de Jul. de 2011

1 voto

Hi Luhur,
assume you have 2 states. One is called increment the other is called nothing. With your S variable checked in a transition you can choose where to go.
Assume S satisfies the criteria and you are right now in state increment. In this state you can write EN:V = V + X; So everytime you enter this state V is incremented by X. From the state increment you can check in a transition if V>=Z and go to the next step.
If you are in state nothing you don't have to do anything just go back and check S again.
Gerd

4 comentarios

Luhur
Luhur el 11 de Jul. de 2011
didnt work gerd. it was only added once. after that the state just turning around. the value in simulink stay still.
Gerd
Gerd el 11 de Jul. de 2011
with the ev: statment you perform execution everytime you enter the state. Therefor you entered the state just once. Can you upload somewhere a screenshot to support you better.
Luhur
Luhur el 12 de Jul. de 2011
the key is make a function in local stateflow to save data for a while. THANKS GERD!!!
Antony Smith
Antony Smith el 12 de Oct. de 2022
I thought it would be this simple but I am getting a very irritating error:
The data signal was read before being written to.
This error will stop the simulation. State 'variable_1' in Chart 'sens_mtr/Motor Controller/Chart':
signal = signal + 20;
The variable was already given an initial value in a previous block before reacing this block? Any ideas of what causes this?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Stateflow en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 11 de Jul. de 2011

Comentada:

el 12 de Oct. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by