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.
-
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_TEL81andPD_TEL81_opt), it is necessary to include a Motion Control library in theapax.ymlfile before running theimport-dbcommand! This ensures that the generated library refers to the same version of the telegrams like defined in theapax.ymlfile. "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.yThe Motion Control version in SIMATIC AX (e.g. V8) must match the Motion Control version of TIA Portal!
-
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 MyMotionProject -n MyProfiDriveAccessBased 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_optwith the same structure as in the TIA Portal project and - the access function GetRefToEncoder with the signature:FUNCTION GetRefToEncoder : REF_TO Encoder -
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 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 Codedoes 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. -
Build and download the AX application.
Note
Remember to download with the option
--non-overwritingto 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.