• 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

Simulink model code generation explained
 


PLC Link is translating arbitrarily composed simulink models (including simple blocks as well as subsystems) into IEC 61131-3 compatible POUs (PROGRAMs, FUNCTIONs and FUNCTION_BLOCKs). 

 

1. The relations between the inner structure of the subsystem and the variables in the resulting function block.
The figure on above link shows how the variable settings of the function block is generated from a subsystem. The red arrows leading from the red dot marked areas of the subsystem til the function block variables show how different parts of the subsystem is becoming inputs, outputs and local variables. Inports and Outports become var inputs and var outputs. Other blocks become local vars. All parameters used are accessible throug the global parameter struct, and is thus not set up in the local function block. The names used in Simulink is used where possible in the resulting code along with the Simulink path.
 
2. The relationship between Simulink blocks and their connections in the Simulink model and the resulting algorithm when compiled with PLC link.
The figure on above link shows examples on how some block connections in a subsystem (Gain and Sum) is translated to Structured Text. The call to fbGain(...) in the STEP area causes the execution of the Gain block and makes the output ready for the following blocks (in this case the Out2 Ouport block). At UPDATE_PARAMETERS the gain block is initialized with the gain value, which in this case is the parameter B. The parameters is found in the M initialization file. UPDATE_PARAMETERS is called every time parameters are updated, but also at the beginning to initialize. For the Sum block the proceeding is a little different. Since the input to the block is an array, the inputs are setup prior to calling the block as seen in the figure. In the INIT part the Sum block is set to have 2 inputs (port 0 to 1) which allows PLC Link to reuse the generated Sum function block for every Sum blocks in the model (no matter the number of inputs). How each block type is setup in subsystems differ much depending on the specific block. For example is the Constant block not really translated to a function block but rather a simple variable in the subsystem where it is used.

3. The complete code generated for the shown Simulink model
The figure shows in many ways the IEC function block dependencies of the parts of a subsystem. Inports and Outport become in- and output variables in the function block and represents the interface to the function block, as it does in the Simulink subsystem. The remaining blocks become local variable instances of their own respective function blocks. Other local variable types does occur, depending on the need for temporaries etc. The algorithm design, as shown in the lower part of the figure, is the result of the signal connections between blocks in the Simulink model. To be able to decide the correct way to order the execution, PLC Link uses the MATLAB execution order to ensure same behavior as expected. The execution order can be seen in the model with small red numbers on each block. The blocks are executed in rising order, so in this example the order will be "Gain B", "Unit Delay", "Gain A" and finally "Sum". When "Gain B" is executed it is assumed that its inputs are ready. Next block in the order is "Unit Delay" which takes its input from "Sum", which is the values from last execution. As it can be seen, the execution of each block differs. This is due to the many differencies that exist between block types. For example does the Sum block need its input as array type which is set up prior to executing the block. Also Unit Delay needs different handling in means of an UPDATE call after the normal execution. Gain blocks need their multiplication values updates in the UPDATE_PARAMETERS call etc. PLC Link knows exactly how to handle all the supported blocks in both the generation of its own function block and in terms of the algorithm part of the subsystem in which it is contained.



 

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