SA0048: AT-declarations on direct addressesPermalink

Detects ‎AT‎ declarations on direct addresses

Justification: 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, and second in the program where variables are assigned to these addresses. If the addresses are relocated because the configuration is changed, then you have 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

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

--> SA0048: Declaration uses direct address '%IX0.0'
--> SA0048: Declaration uses direct address '%IB1
--> SA0048: Declaration uses direct address '%QX0.0'