Topic: DMD0499

Help File Version: 2.10.0.636

Using Constant Values


Constants - values that do not change throughout the program execution - can be used in most places where memory elements can be used. Constant values can even have Nicknames; these are called symbolic constants.

 

One of the places constant values are commonly used are as instruction parameters, for example:

  • Presets for Counters, Timers, etc.



  • Initial values of memory locations



  • Loop counters



  • Comparative Contacts


 


Constants can also be used in some of the utilities used for programming and debugging, for example: Find, Trend View, etc.

 

 


How to Specify the Data Format of a Constant

Constant values can be entered as Decimal, Hex, Real, or Octal values. The data format specifier can be manually entered with the value.

 

  • Hexadecimal value uses the '0x' prefix, for example: 0x63, 0x7FFF.



  • Octal value uses one leading zero, for example: 0377, 02000.


  • Real (floating point) value is any value with a decimal point or scientific notation, for example: 212.0, 1E+14.



  • Decimal value is any value with no format specifier.


 


Alternatively, clicking the 'three dot box' to the right of a parameter field will open the Element Picker, if the parameter allows constants, you can expand the Constants group which contains the list of the constants - or ranges of constants - that are acceptable for this parameter field. Clicking a constant range will select the first value in that range with the appropriate format specifier.

 

 


Status Mode Format Selection

 

If the programming session is online and rung status is ON, the right-click menu for a parameter filed can be used to select or change the display format of a constant value. If the instruction is a relational contact, using this method to change the format of the constant will change the format of both parameters.

 

 


Symbolic Constants

The Element Documentation Editor allows for the creation of symbolic constants for use in the project. These are constant values represented by text instead of the literal numeric value. The use of appropriately named symbolic constants can clarify the intent of the code, and additionally, if a specific value needs to be changed, reassigning a symbolic constant value once is more efficient and less error prone than replacing every instance of the value.

 

In the Documentation editor, the Element column will display 'Symbolic Const', the Nickname field will display the name of a symbolic constant and the Extra Info field will contain the constant value.

 

 


See Also:

Built-in Data Blocks

 

Structures and their Fields

 

User-Created Data Blocks and Structures

 

Arrays, Pointers and Tables

 

Cast Operations

 

Assignment Operations and Instructions

 

Using Constant Values

 

System Nicknamed Locations

 


Related Topics:

Element Browser

 

Element Picker

 

Element Documentation Editor