"Coupling DBs" for HMI (S7 communication) use case - 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
  1. Define a data block in the TIA Portal project (e.g. ./tia/tia-project/tia-project.ap19).
    This example shows a data block MySharedDB referencing the UDT (User-defined Data Type) tank two times:
    Data block and data-type in TIA Portal project
  2. Setup the HMI connection in TIA Portal via this data block.
  3. Download the TIA project to the PLC.
  4. Generate the SIMATIC AX library for "coupling DBs" in a terminal:

    apax tia2st import-db -i ./tia/tia-project --lib MyTiaProjectDB -n MyHmiAccess
    

    Based on this example it will generate a SIMATIC AX library MyTiaProjectDB.lib with following types and access function are located in the namespace MyHmiAccess: - Two types MySharedDB and tank with the same structure as in the TIA project and - the access function GetRefToMySharedDB with the signature:

    FUNCTION GetRefToMySharedDB : REF_TO MySharedDB
    
  5. 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".
  6. Extend your AX application to access the "coupling DBs":

    USING MyHmiAccess;
    
    // ...
    
    FUNCTION SetHmiValues
       VAR_TEMP
          sharedDb : REF_TO MySharedDB;
       END_VAR
    
       sharedDb := GetRefToMySharedDB();
       sharedDb^.processActive := TRUE;
    
       sharedDb^.tank1.full := TRUE;
       sharedDb^.tank1.level := REAL#100.0;
    
       sharedDb^.tank2.pump := TRUE;
       // ...
    
  7. Build and download the AX application.

    Note

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