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
|
||||||||||||
| > |
Examples of transition conditions:
|
||||||||||||
| > |
Use of condition and transition actions:
|
||||||||||||
| > | 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.