In the example above, a set-bit object was placed on the screen as a ‘+’ button. When this button is pushed, it forces
LB:1 to ON and the ‘AddTwo’ macro executes, storing the result in LW:2 and turning LB:1 to OFF and the macro
stops.
Vari ables, Dec la ra tions and Mem ory Us age
Variables, constants & functions are named by the programmer. Variables and constants are called
operands
.
Variable names can be any character or number (a-z, A-Z, 0-9, or ‘_’) and can be as many characters as you need to
describe it (the compiler has been tested to variable name lengths of 32 characters, but it is best to keep the variable
names small for ease of reading the code). Variable names are not case sensitive, so ‘result’ is the same as ‘ReSult’
or ‘RESULT’. Variable names must always start with a letter (i.e. variables cannot begin with a number or the
underscore ‘_’ character).
Memory Usage:
Macros use a minimum of about 2.5K, plus the memory required for each variable type:
• float: 4 bytes (32-bits)
• int: 4 bytes (32-bits)
• short: 2 bytes (16-bits)
• char: 1 byte (8-bits)
• bool: 1 bit
• arrays: the corresponding number of bytes for each element, plus another 2 bytes for the index
Macros use memory from the background task (defined as
Window 0
) area. There is a default memory size of
320K available for macros (only 220K is allotted if the ‘Fast Selection’ task bar is enabled) and the there are other
background task objects that also use memory in this area, such as:
• Trends
• XY Plots
• Data Transfers
• Alarms
• Events
• PLC Controls
• Printer functions
If the application exceeds the 320k limit, both the simulator and the OIT will display a
System Severe Error message. To check the memory usage; right-click on the
Simulator window and select System Resource from the menu. To add more memory to
this area, reduce the number of total pop-ups possible. The setting is in the system
parameters {General} tab. The default is 6; change this to 4 and the memory will
increase (be re-allocated) for window 0 (background task) functions.
Variable Declarations
Each variable that will be used in the macro needs to be declared as a specific ‘type’ of register. The declarations are
listed as the first part of the macro. Any declarations contained within the macro function is considered ‘Local’ and
any variable outside the macro function is considered ‘Global’. Local variables are only seen within the function
they are declared in. Global variables retain their values and can be globally used by all functions. Below, are listed
the various data types that can be declared:
TypeDescription
Float
Single-Precision Floating point variable (32-bit signed,
IEEE-754 format)
Int
Integer variable (32-bit signed)
Short
Short integer variable (16-bit signed)
Char
1010-1001a, Rev 02
248
Sil ver Se ries In stal la tion & Op er a tion Man ual
Содержание Silver HMI504T
Страница 1: ...1010 1001A Rev 02...
Страница 20: ...1010 1001a Rev 02 16 Silver Series Installation Operation Manual OIT to PC Serial Port Pin Assignments...
Страница 32: ...1010 1001a Rev 02 28 Silver Series Installation Operation Manual...
Страница 128: ...1010 1001a Rev 01 124 Silver Series Installation Operation Manual...
Страница 156: ...1010 1001a Rev 02 152 Silver Series Installation Operation Manual...
Страница 166: ...1010 1001a Rev 02 162 Silver Series Installation Operation Manual...
Страница 216: ...1010 1001a Rev 01 212 Silver Series Installation Operation Manual...
Страница 251: ...1010 1001a Rev 02 Macros 247 Set Bit Objects Attributes Dialog Project Example of Add 2...
Страница 264: ...End Macro_Command 1010 1001a Rev 02 260 Silver Series Installation Operation Manual...
Страница 268: ...1010 1001a Rev 01 264 Silver Series Installation Operation Manual...