• About DEIF Wind Power Technology
  • Business concept
  • Products
  • Solutions
  • Software
  • News & media
  • Fairs
  • Jobs & careers
  • Contact
  • Group homepage

Products

  • Wind turbine components
  • Wind turbine controllers
  • PLC Link
    • Get PLC Link
    • Supported targets
    • Tutorial videos
    • License activation
    • Documentation
      • Release notes
      • Supported Simulink blocks
      • Simulink model code
      • Stateflow code

Stateflow code generation explained


PLC Link can generate IEC61131-3 compliant code from Stateflow charts as Structured Text or SFC.


The generated IEC 61131-3 ST code executes identically to the way Stateflow simulates in MATLAB/Simulink, for models designed with attention to the below listed features. Due to the limited nature of SFC, compared to Stateflow, it is recommended only to choose SFC code generation with simple Stateflow charts.

 

Features of PLC Link with Stateflow support choosing ST:
 

> For "exclusive OR" and "parallel AND" systems, arbitrary composed Stateflow charts with arbitrarily deep nesting of states are supported.
> An arbitrary number of default, inner and outer transitions can be used.
> An arbitrary length and composition of conditions, condition actions and transition actions can be used.
> In states, during, entry and exit code is supported with respect to using m code that can be parsed by the PLC Link M parser.
> Variables can be declared in the Simulink Model Explorer using the scopes “Input”, “Output”, “Parameter” and “Local”. The considered fields are “Name”, “Scope”, “Data type” and "Initial value" where needed.
>

Example of actions on a state

  Example 1:
  en: y = 0;
  du: y=25+u*2.1;
  ex: y=25;
  where y is an output variable and u is an input variable

 

>

Examples of transition conditions:

  Example 1:
  [u<100+floor(a*0.7)]
  where "u" is an input var and "a" is a parameter specified in the ini M file.
  Example 2:
  [b || 25>=u]
  where "b" is a boolean variable.

 

>

Use of condition and transition actions:

  Transition label: event [conditions] {condition actions} /transition actions
 

Conditions, condition actions and transition actions are all parsed by the PLC Link M parser which supports simple M code and some often used functions. For instance, floor(), fix(), sin(), log() etc. Events are ignored if present.

> Currently not supported: Events, Junctions, Truth tables, Functions or boxes, advanced use of M code, transitions in and out of parallel charts/states except for default transitions, special Stateflow functions and event handlers like after(), before(), in() and "on:".



How PLC Link translates Stateflow Charts


To summarize the supported Stateflow features in PLC Link, the below Stateflow Chart is an example of what PLC Link is capable to translate into Structured Text. The Chart shows use of most parts of the supported features.


The following figures show the translation to SFC of a simpler Fill and Flush tank simulation Chart:


1. Translation of the Fill and Flush tank simulation Chart.

 

2. Translation of the substates of state Fill.

 

3. The tree structure layout of chart and substates in a target IDE.

 

 

The following figures show the translation of the same Stateflow model into Structured Text:

 

1. The layout of the resulting function block with examples.

 

2. The full explained function block of the Fill and Flush system.

 

 

DEIF A/S, DEIF Wind Power Technology - Frisenborgvej 33 - DK-7800 Skive - Denmark - +45 96 14 96 14 - info@deif.com
  • Terms of use