Effacer les filtres
Effacer les filtres

Simulink Coder - Customizing stateflow generated code

1 vue (au cours des 30 derniers jours)
Joseph Stalin
Joseph Stalin le 27 Fév 2013
Dear Techies, I am intended to generate code from my Stateflow models. I am using Unit delay blocks to represent variables of static type outside the stateflow chart.Because of this generated code is not optimized.
So Is there any way I can represent static type variables within the stateflow? That is implementing the unit delay functionlity inside the stateflow chart. (Using DSM blocks is not allowed as per our guidelines.)
regards, Joseph

Réponses (1)

TAB
TAB le 27 Fév 2013
Modifié(e) : TAB le 27 Fév 2013
Unit delay block just have a state variables which stores the previous value of input.
Similarly in Stateflow, you can use a local variable to store the previous value of data. You can use one parallel state with priority-1 which handles all your normal operation and another parallel state with priority-2 which saves the data to previous local variable.
See the Pseudocode below (unfortunately I don't have access to any image hosting website. Thats why I am unable to post any image to explain implementation in stateflow)
/* Parallel state-1 for Operation using previous value */
Out = data + data_prev;
/* Parallel state-2 for saving previous value */
data_prev = data;
But, I can not understand how a unit delay block is affecting your code optimization.
  2 commentaires
Joseph Stalin
Joseph Stalin le 27 Fév 2013
I couldn't understand the parallel state concept. or what is the scope (local or In or out) of data_prev? How it is able to store the previous cyle data? Is it possible to send a example model to my gmail ID? (<mailto:jspjose.tl@gmail.com jspjose.tl@gmail.com>)
I am using flow graph in my stateflow as lot of IF/ELSE is used in my algorithm.
How it is affecting code optimization? Actually I am using delay blocks outside the stateflow chart substystem. so structure is updated both in subsystem.c ,model.c file. The dependancy of model.c is created because of using unit delay blocks outside the chart subsystem.
regards, joseph

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by