// This routine
puts (2) 16-bit array variables into one 32-bit
variable
Int LVal
short Data[2]
LVal = (Data[1] < 16) + Data[0]
Using Floating Point Registers Within Macros
Reading and writing external floating point registers can only be used in a macro as a transfer function. The macro
routine has no functionality to interpret an external floating point formatted (IEEE-754 format) register. Although a
variable can be declared as a ‘float’ type within the macro, it can not store the external float register properly.
When reading or writing a 32-bit floating point (also call a ‘real’) register that is external to the macro using
GetData() or SetData(), you must use an array of (2) 16-bit ‘shorts’. Internally, the macro can use an ‘int’ type
variable to store a value up to +/- 2,147,483,647 (a signed 32-bit register). But when using the GetData() or
SetData() functions it only does a 16-bit external transfer even though it may be declared as ‘int’ (32-bit).
// This routine will not work – a GetData of more than one
element requires
// a variable that is declared as an array
float RealData
// get the floating point register and store it in ‘RealData’
GetData(RealData ,F8_Binplc ,1,2)
// This routine reads a 32-bit holding register
short Data[2]// grab a 32-bit register [(2) 16-bit] value from a
PLC register address 4x:1 GetData(Data[0] ,4x_Binplc ,1,2)
Statements, Conditions & Expressions
An
expression
combines constants, variables, arrays, functions, and operators under certain rules. Expressions can
be logical or mathematical equations.
Below are listed some of the different styles of statements:
·
A
declaration
(definition) statement is constructed like the following:
Format
Examples
Explanation
type
name
short
MyVar
This defines the name of the variable
register and its
type
type
name
[constant]
Short
MyVars[10]
This defines an array name and the
[constant] is the number of ‘
type
elements’
in the array
·
An
assignment
statement will transfer (assign) an expression to a variable. The form is:
Format
Examples
Explanation
variable = expression
MyVar = 10
MyVar = x + y
This assigns the result of the expression to
a variable
·
A
logic
or
conditional
statement processes a logic expression and branches depending on the result. This
assigns the result of the expression to a variable. The ending statement
‘End If’
is written as two words, not
one word. Note that there is a difference between the conditional equality noted by two equal signs ‘= =’
(read as: ‘is equal to’) and the assignment equality noted by only one equal sign ‘=’.
1010-1001a, Rev 02
Macros
253
Содержание 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...