Symbolic constants
You have the option of declaring symbolic names for constants and thus making constant values available under a name in the program. This makes a program more readable and easier to maintain when changing constant values.
A symbolic constant consists of the following elements:
-
Name
-
Data type
Symbolic constants always have a data type; non-typed notation is not possible for symbolic constants.
-
Constant value
You can select any value from the value range of the specified data type as constant value. For information on the value ranges, refer to the "Data types" chapter.
Declaration of constants
You can define constants with different scopes of validity:
-
Global constants that apply to all areas of the CPU
-
Local constants that only apply within a block
The table below shows the difference between the constant types:
|
Global constants |
Local constants |
|
|---|---|---|
|
Scope of validity |
|
|
|
Permitted characters |
|
|
|
Location of definition |
"Constants" tab from the PLC tag table |
Block interface |
|
Representation |
In quotation marks, for example.:
|
Prefixed with a number sign, for example:
|
Name conflicts can occur if you have declared a local and a global constant with the same symbolic name and have used this doubly specified name as the default value of a tag. In this case, the local constant is automatically used.
|
Note Downloading constant declarations (S7-300/400) Local and global constant declarations are not downloaded into the CPU. If you download a program from a device, the constant declarations may no longer be available. |
|
Note You can find more information on permissible characters in constant names in the Siemens Industry Online Support in the following entries: When should identifiers and operands be used in "quotation marks" in STEP 7 (TIA Portal)?
|