Skip to main content

SA0048: AT-declarations on direct addresses

Detects AT declarations on direct addresses

The use of direct addresses in the code is problematic because the address then appears in multiple locations:

  • First in the controller configuration where the assignment of a physical object to an address is defined

  • Second in the program where variables are assigned to these addresses.

If the addresses are relocated because the configuration is changed, then you need to reassign variables to addresses at a completely different location in the program. This is a cause of error and results in poorer readability and maintainability of the code. Therefore, it is best to perform all assignments in the I/O mapping of the device editor.

Importance: High

PLCopen rule: N1 / CP1

Note

We recommend that you use direct addresses ONLY in the I/O Mapping tab of the device editor.

Example 60. Example
PROGRAM PLC_PRG
VAR
    xVar1 AT %IX0.0 : BOOL;
    byVar1 AT %IB1 : BYTE;
    xVar2 AT %QX0.0 : BOOL;
END_VAR

Output in the Messages view:

  • sa_icon_message.png SA0048: Declaration uses direct address '%IX0.0'

  • sa_icon_message.png SA0048: Declaration uses direct address '%IB1'

  • sa_icon_message.png SA0048: Declaration uses direct address '%QX0.0'