Emerson PaCSystems VersaMax Series User Manual page 156

Table of Contents

Advertisement

User Manual
GFK-1503F
Data Types for Standard Math Functions
Standard math functions operate on these types of data:
INT
DINT
REAL
The input and output parameter data types must be the same (16 bits or 32 bits).
Avoiding Overflows
Be careful to avoid overflows when using Multiplication and Division functions.
If you have to convert Integer to Double-Precision Integer values, remember that the CPU
uses standard 2's complement with the sign extended to the highest bit of the second word.
You must check the sign of the low 16-bit word and extend it into the second 16 bit word. If
the most significant bit in a 16-bit INT word is 0 (positive), move a 0 to the second word. If
the most significant bit in a 16-bit word is –1 (negative), move a – 1 or hex 0FFFFh to the
second word.
Converting from Double-Precision Integer to Integer data is easier, because the low 16-bit
word (first register) is the integer portion of a Double-Precision Integer 32-bit word.
The upper 16 bits or second word should be either a 0 (positive) or –1 (negative) value or
the Double-Precision Integer number will be too big to convert to 16 bits.
Example
This example uses the Addition and Subtraction functions to keep track of the number of
parts in a temporary storage area. Each time a part enters the storage area, power flows
through relay %I0004 to a positive transition coil with reference %M0001. Relay % M0001
then enables the Addition function, adding the (constant) value 1 to the current total value
in %R0201.
Each time a part leaves the storage area, power flows through relay %I0005 to a positive
transition coil with reference %M0002. Relay %M0002 then enables the Subtraction
function, subtracting the (constant) value 1 from the current total value in %R0201.
Instruction Set Reference
Signed integer
Double precision signed integer
Floating Point
Chapter 10
Jan 2020
142

Advertisement

Table of Contents
loading

Table of Contents