- 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:
- Setup the HMI connection in TIA Portal via this data block.
- Download the TIA project to the PLC.
-
Generate the SIMATIC AX library for "coupling DBs" in a terminal:
apax tia2st import-db -i ./tia/tia-project --lib MyTiaProjectDB -n MyHmiAccessBased 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 -
Add the option
--libbelow the variableAPAX_BUILD_ARGSin theapax.ymlfile:variables: APAX_BUILD_ARGS: - "--lib ./lib/1500/MyTiaProjectDB.lib"IMPORTANT
- Regardless of the output folder you select for your library, the
1500folder will always be created in addition. - At present, there is no support for the
llvmtarget. 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".
- Regardless of the output folder you select for your library, the
-
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; // ... -
Build and download the AX application.
Note
Remember to download with the option
--non-overwritingto preserve the "coupling DBs" loaded with TIA Portal.