EasyManua.ls Logo

Maple Systems Silver Series - Using Floating Point Registers Within Macros; Statements, Conditions & Expressions

Maple Systems Silver Series
272 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
// 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

Table of Contents