Rockwell Automation T3833 User Manual

ICS Regent
I
mportant!
®
PD-6043
Math Package for
W
INTERPRET
Floating Point Math Function Block
(T3833)
Issue 1,
The Math pac package which allows the user to create Floating Point Math function blocks for Regent application programs. When installed on the PC, the math package is seamlessly integrated with the base WINTERPRET
Floating point math function blocks are used to perform mathematical calculations that require floating point precision or use values that exceed the 16-bit signed integer range (-32768 to +32767) used in ladder logic math operations. The expressions that can be used in floating point math function blocks include addition, subtraction, division, multiplication, exponentiation, logarithms, and square root.
kage for W
INTERPRET
is an add-in software
software.
March, 06

Software Installation

The Math package is installed on the PC running the W
INTERPRET
package provides the necessary installation software to install this add-in math package. The math package should be installed at the same time or after you have installed the W
INTERPRET

Installation Procedure

The files on the Math package diskette are in compressed
form. You cannot simply copy the files to your hard drive — they must be decompressed before they will run. You must have the WINTERPRET base package distribution disk in order to run the setup procedure to install the Math package.
To install the Math package, use the following sequence:
1
application software. The W
base package.
INTERPRET
base
Math Package for
1. Insert the WINTERPRET base package distribution disk into
W
INTERPRET
drive A: or B:
(T3833)
2. Start Windows (if it isn’t already running).
3. Choose Run from the Program Manager’s File menu.
4. Type a:\
W
INTERPRET base package disk in drive B: type
b:\setup.exe
5. In the WINTERPRET Setup dialog box enter the name of the
directory in which you have installed the WINTERPRET base package (This assumes that you have already installed WINTERPRET). Choose Continue.
6. In the WINTERPRET Installation dialog box check the Math
package box.
7. Choose OK to have the setup program install the Math
package software.
When the installation is completed, you can run the W
INTERPRET application and create floating point math
function blocks in you application programs.
setup.exe
.) Choose OK or press ENTER.
in the text box. (if you inserted the

Working with Floating Point Math Function Blocks

Floating point math function blocks are created as part of an application program which may also contain other types of function blocks. A single application program is made up of as many as 50 function blocks of any type or combination.
When you installed the Math package, additional sof was added to W point math function blocks. With this additional software you can create floating point math function blocks by opening a project, opening a program and opening (or creating) a function block.
For an overview about Regent application programs and function blocks and how to create them using WINTERPRET refer to Section 5, Working with Programs and Function Blocks in the Regent User’s Guide.
INTERPRET
to allow you to work with floating
tware
,
2
Industrial Control Services
Math Package for
W
INTERPRET
(T3833)

Using Floating Point Math Statements

In floating point math function blocks you enter mathematical equations and expressions in the form of statements. Each line can contain one statement that calculates the result of a mathematical equation. For example, consider the quadratic equation below.
y = 1.6x2 +8x -22.4
Using floating point math the statement representing this equation would be:
Y = 1.6*X^2 + 8*X - 22.4
You can also enter comments in any line by entering a semicolon (;) and placing your comments after the semicolon as shown below.
Y
= 1.6*X^2 + 8*X - 22.4 ; This is a comment.
Floating point math also allows you to create conditional statements using IF, ELSE, ENDIF, WHILE, ENDW, AND and OR operations. Below is an example of using IF, ELSE and ENDIF to calculate the absolute value of the difference between two variables.
PD-6043
March, 06
IF AI1 > AI2 DIFF = AI1 - AI2 ELSE DIFF = AI2 - AI1 ENDIF
Using combinations of conditional statements and mathematical operations allows you to configure floating point function blocks to meet a wide range requirements.

Mathematical Operations

of control
The mathematical operators perform arithmetic and functional operations.
3
Math Package for
Operator Operation
^ Exponentiation * Multiplication /
Division
+
Addition
- Subtraction
Operator Operation
SQRT(x)
Returns the square root of x
EXP(x)
Raises e to the x power
LOG(x)
Returns the logarithm of x
LN(x)
Returns the natural logarithm of x
Note:
Note:
W
INTERPRET
(T3833)

Arithmetic Operations

Table 1 shows the arithmetic operators recognized by floating point math listed in their default order of precedence.
Table 1. Arithmetic Operators.
Multiplication and division have equal precedence from
right, as do addition and subtraction.
The exponent, X, in an exponential expression (
Y^X
left to
) is always
evaluated as an integer (fractional portion is truncated). Do not use the exponentiation operator to perform square root calculations, instead use the below.
SQRT(X)
function described
Parentheses may be used to clarify the order of operation: operations within parenthesis are performed first. Inside the parentheses, the usual order of precedence is maintained.

Functional Operators

A functional operator is used in an expression to perform a predetermined operation that is to be performed on one or more operands. The Regent’s floating point math has four standard functions that reside in the system as shown in Table 2.
Table 2. Functional Operators.
In each function you can enter a variable or arithmetic expression within the parenthesis of the function. For example the following statement is valid.
4
Industrial Control Services
Math Package for
Note:
W
INTERPRET
(T3833)
The exponentiation operator (
integer power X. If you need to calculate values of X you can use the shown below.

Conditional Statements

ROOT1 = (-B + SQRT(B^2 - 4*A*C)) / (2*A)
Y^X
) can only raise Y to an
YX for non-integer
LN(X)
and
EXP(X)
functions as
Y_2_THE_X = EXP(X*LN(Y))
The statements available in the floating point math let you alter program flow base

IF, ELSE, and ENDIF

d on testing of conditions.
The IF statement is used to make a decision regarding program flow based on the result returned by an expression. The expression can include mathematical and logical operators. The use of ELSE within the lines controlled by the IF statement is optional.
Syntax:
IF expression
• ELSE (optional)
• ENDIF
IF, ELSE, and ENDIF statements must not the same line.

WHILE and ENDW

be combined on
The WHILE statement executes a series of statements in a l
oop as long as the expression is true. The expression can
include mathematical and logical operators. Syntax:
WHILE expression
PD-6043
March, 06
• loop statement
5
Math Package for
Operator
Relation Tested
Expression
=
Equality
X = Y <> Inequality
X <> Y
<
Less than
X < Y
>
Greater than
X > Y <= Less than or equal to
X <= Y
>= Greater than or equal to
X >= Y
Important!
If the expression is true (not zero), loop statements are executed until the ENDW statement is encountered. Floating point math then returns to the WHILE statement and checks expression. If expression is still true, the process is repeated. If the expression is not true, execution resumes with the statement following the ENDW statement.
To avoid infinite loops, the expression must be modified (its
value changed) during repeated execution to make the expression false and exit the loop.
W
INTERPRET
• ENDW
(T3833)
WHILE and ENDW statements may be nested.

Relational and Logical Operators

Relational and logic operators are often used in the expressions for IF and WHILE statements to control the execution of other mathematical statements.

Relational Operators

Relational operators compare two values. The result of the comparison is either true (1) or false (0
). The result can then be used to make a decision regarding program flow. The relational operators are shown in Table 3.
Table 3. Relational Operators.
6
When arithmetic and relational operators are combined in one expression, the arithmetic is always p
Industrial Control Services
erformed first.
Math Package for
Value
A
Value
B
Result
A AND B
Result
A OR B
T T T T T F F T F T F T F F F
F
W
INTERPRET
(T3833)

Logical Operators

Logical operators perform logical, or boolean, operations on numeric values. Just as the relational operators are usually used to make decisions regarding program flow, logical operators are used to connect two or more relations and return a true or false value to be used in a decision.
A logical operator takes a combination of true/false values and returns a true or false result. An operand of a logical operator is considered to be true if it is not equal to zero, or
false if it is equal to zero. The result of the logical operation is a number which is, again, true if it is not equal to zero, or false if it is equal to zero.
In an expression, logical operations are performed after arithmetic and relational operations.
Table 4. Logical Operators.

Using Variables and Constants

Constants

Constants are static values used by the floating point math function blocks during execution of your program. All constants are numeric.
Numeric constants can be either positive or negative. Numeric constants must not contain commas. For example, if the number 20,000 is needed as a constant, it should be typed in the floating point math statement as 20000.
There are two types of numeric constants: integer and floating point.
PD-6043
March, 06
7
Math Package for
W
INTERPRET
(T3833)
Integer Constants
Integer constants are constants entered as whole numbers that do not contain decimal points or commas. Entering
an integer constant greater than 7 numerals long is allowed but the precision of the actual number stored and used in the Regent is limited to 7 significant digits. For example, the integer constants 12345678 and 12345679 may result in an equal values when converted and stored in the Regent.
Floating Point Constants
Floating point constants are positive and negative numbers represented in exponential form (similar to scientific notation). A floating point constant consists of an optionally signed integer or fixed point number (the mantissa) followed by the letter "E" and an optionally signed integer (the exponent). The "E" means "times ten to the power of."
For example:
33E-2
Here, 33 is the mantissa, and -2 is the exponent. This number could be read as "thirty-three times ten to the power of negative two." You could also write this number as 0.33 in regular fixed point notation.
8
You can represent any number from -1.175494E-38 to
3.402823E38 as a floating point constant.

Variables

Variables are names representing values used in the float
ing point math function blocks. All of the variables you use in a floating point math function block must be shared variables, I/O points, or local variables used by floating point math function blocks only. For example, if you scale an analog input value to a register, the register should be defined as a shared variable register if you want to use the scaled result in a floating point function block.
The floating point math compiler assumes that any local var
iables found in the function block will be local floating point registers. If a local variable is used in both a floating point math and other type of function block, a local data allocation error will be reported when you attempt to load the
Industrial Control Services
Loading...
+ 18 hidden pages