How do you define the constants in an S7-SCL program in STEP 7 (TIA Portal)?
In STEP 7 V5.x you can define the local constants in the declaration part on the SCL block code and use them in the program as shown in Fig. 1.
In TIA Portal it is not possible to define constants in the declaration part CONST/END_CONST of the SCL program code.
This is how you define constants in TIA Portal V13:
- You define the local user constants in the block interface of an FC/FB under "Constant" and you can then use them in the block program. Here you must define a data type for the use constants.
- You define the global user constants, which are to be available CPU-wide, in the PLC tags in the "User constants" tab. Also when defining the global user constants you must define the data type.
Only use local constants within a block. In this way the block remains universal and can be used in a library.
In TIA Portal V11 and V12 you can define global user constants. Refer to the information given in the Online Help when migrating projects from STEP 7 V5.5 to STEP 7 (TIA Portal).
Excerpt of the Online Help:
"In the TIA portal, symbolic constants cannot be declared in the block interface. If symbolic constants are declared in the original program, they are converted to global constant declarations and are available in the PLC tag table. Name conflicts are handled as below.
- If both constants have the same value, a global constant is created with that value.
- If the values are different, the two constants are renamed. The renaming is performed consistently at all points of usage."
The screens in this FAQ response were created with STEP 7 (TIA Portal) V13.0 and STEP 7 V5.3.
More rules and recommendations for programming are available in the Programming Style Guide for S7-1200/S7-1500 in Entry ID 109478084.