"Coupling DBs" for Motion Control use cases - Manual - TIA2ST - A CLI tool to import TIA Portal project data into a SIMATIC AX project. - TIA2ST - Convert parts of TIA Portal projects to ST code,tool

TIA2ST CLI Tool (tia2st)

Portfolio
SIMATIC AX
Product
TIA2ST
Software version
2.0.24
Edition
01/2025
Language
English (original)
Package Name
@ax/tia2st

Technology objects in TIA Portal have an optional and open hardware interface via additional DBs for reading and writing PROFIdrive data without having to connect a real drive/encoder object.

  1. Define a data block in the TIA Portal project (e.g. ./tia/tia-project/tia-project.ap19).
    Following description is based on the application example Connecting ext. encoder of Startdrive to the TO_ExternalEncoder. Other Motion Control use cases are also applicable and follow the same rules, e.g. connecting non PROFIdrive drives/encoders with technology objects.

    Note

    When using pre-defined Motion Control system data types like PD_TEL* provided by Siemens.Simatic.S71500.MotionControl.Native (e.g. PD_TEL81 and PD_TEL81_opt), it is necessary to include a Motion Control library in the apax.yml file before running the import-db command! This ensures that the generated library refers to the same version of the telegrams like defined in the apax.yml file. "Coupling DBs" must to be optimized. Therefore, on AX side the optimized data types will be used (e.g. PD_TEL81_opt).

    dependencies:
    "@ax/simatic-1500-motioncontrol-v8": x.y
    

    The Motion Control version in SIMATIC AX (e.g. V8) must match the Motion Control version of TIA Portal!

  2. Download the TIA project to the PLC.

  3. Generate the SIMATIC AX library for "coupling DBs" in a terminal:

    apax tia2st import-db -i ./tia/tia-project --lib MyMotionProject -n MyProfiDriveAccess
    

    Based on this example it will generate a SIMATIC AX library MyMotionProject.lib with following types and access function are located in the namespace MyProfiDriveAccess: - Two types Encoder and PD_TEL81_opt with the same structure as in the TIA Portal project and - the access function GetRefToEncoder with the signature:

    FUNCTION GetRefToEncoder : REF_TO Encoder
    
  4. Add the option --lib below the variable APAX_BUILD_ARGS in the apax.yml file:

    variables:
       APAX_BUILD_ARGS:
          - "--lib ./lib/1500/MyTiaProjectDB.lib"
    

    IMPORTANT

    • Regardless of the output folder you select for your library, the 1500 folder will always be created in addition.
    • At present, there is no support for the llvm target. As a result, unit tests via AxUnit-ST can only be executed on S7-PLCSIM (Advanced) or a real S7-1500 PLC. For both the target is "1500".
  5. Extend your AX application to access the "coupling DBs":

    USING MyProfiDriveAccess;
    
    // ...
    
    FUNCTION SetProfiDriveValues
       VAR_TEMP
          myEncoder : REF_TO Encoder;
       END_VAR
    
       myEncoder := GetRefToEncoder();
       myEncoder^.T81.Input.G1_XIST1 := PosAxis^.Actor._Interface.AddressIn.G2_XIST1;
       myEncoder^.T81.Input.G1_XIST2 := PosAxis^.Actor._Interface.AddressIn.G2_XIST2;
       myEncoder^.T81.Input.G1_ZSW   := PosAxis^.Actor._Interface.AddressIn.G2_ZSW;
       // ...
    

    Note

    Please note that AX Code does not currently offer intellisense support for "coupling DB". For this reason, all usages of the library are marked as erroneous in the IDE. However, the build process works without errors. If you're unfamiliar with the naming and structure, it's recommended to refer to the TIA Portal project.

  6. Build and download the AX application.

    Note

    Remember to download with the option --non-overwriting to preserve the "coupling DBs" loaded with TIA Portal.

Note

After updating the Motion Control version in the TIA Portal project the "coupling DBs" need to be downloaded again via TIA Portal offline in STOP mode. In additon the Motion Control version of SIMATIC AX must be updated as well and match the Motion Control version of the TIA Portal project! The import-db command needs to be executed again to synchronize the data definition in TIA Portal and data access via SIMATIC AX. The AX application must be downloaded again.