A SIMATIC PLC can grant external systems access to variables of an AX application in two ways:
- Through the OPC UA server
- Through the Web server
Each server can be independently enabled in the hardware configuration, either in the TIA Portal project used to set up the PLC or by using the AX hardware engineering.
For security reasons, no variable is accessible by default, adhering to the need-to-know principle. Therefore, you must explicitly enable access to the variables of your application!
This is achieved by adding pragmas to your ST code. For example:
VAR_GLOBAL
{S7.extern=ReadWrite}
MotorOn : BOOL; // variable can be read and written
{S7.extern=ReadOnly}
MotorState: INT; // variable can only be read
MotorFlags: UINT; // variable is not accessible by an external system (default: hidden)
END_VAR
The advantage of using pragmas is that the accessibility can be set in the ST code of libraries and is then enforced in any application using those libraries.
For more details on the OPC UA workflow in AX, refer to the related documentation.
The pragmas are also applied in the TIAX library workflow: they are mapped to the appropriate flags in the interface of a function block or UDT in TIA Portal.