Example showing the syntax of functions, function blocks and programs as well as type definitions in Structured Text (ST) sources (units) in SIMOTION
When inserting an ST program from the project browser, the ST editor only generates a basic program comprising an interface and an implementation section. The individual source segments and program organizational units (POE) such as function block (FB), function (FC) and program and the related syntax are not provided.
Two ST sources, major POEs and the related syntax as well as the definition of structures and arrays and their declaration are explained in the following. The available sources can be imported, compiled and used immediately.
The first source comprises all major source segments (FB, FC, program and expression), the definition of types (arrays and structures) and the declaration of variables. All source segments are provided with comments regarding their function and use.
sttemp_l_en.st ( 17 KB )
The second source basically corresponds to the first one. Only the comments have been removed. Both sources can be compiled directly following the import.
sttemp_s_en.st ( 4 KB )
To import the source in SCOUT, proceed as follows:
- Click with the right mouse button on the file name
- Select "Save target as ..." to store the ST source in an arbitrary directory.
- Click with the right mouse button on the directory Programs in the project browser to import an external ST source.
- Browse to the directory selected under 2.) and select the file.
- Assign a unit name to the ST source file
You can integrate your own program sections in the FB, FC and program folders directly following the import. The source template, however, can also be compiled immediately without using a separate code.