Instruction Manual
128 User Variables and Arithmetic • User Variables
Publication 1398-PM601A-EN-P — October 2000
TUTORIAL
setup data (all the variables that are used to make a particular part) could be nonvolatile variables.
Volatile variables are variables that are reset to a known state each time power is applied to the ULTRA
Plus or IQ or at each Hard Reset. V and F variables are volatile. Volatile variables are useful if you want
to know that power has been removed and to force the operator to do some initialization. In addition,
volatile variables may be used for temporary variable use in calculations. At power-up or a Hard Reset,
V variables are reset to zero and F flag variables are OFF.
Resolution and Accuracy
B and F variables are flag variables. They have only two states: ON or OFF. Flags are used in logical
expressions and as conditions in conditional expressions. Flags are often used to indicate that some
event has occurred or that the program has executed to a particular point. For example, if you want
some instructions to execute only when power is first applied you might do the following:
IF F1 OFF ;F flags are OFF at Power-up
{ ;Start of block
… Statements ;Whatever code you want
F1 = ON ;Indicate code ran once
} ;End of block
G and V variables are stored internally as 4 bytes for the mantissa (the part before the decimal point), 2
bytes for a numerator (the top part of a fraction), and 2 bytes for a denominator (the bottom part of a
fraction). The range of numbers that can be represented in 4 bytes is ±2,147,483,648. The range of num-
bers that can be represented in 2 bytes is ±32,767. Therefore, the range of numbers that can be contained
in a G or V variable and any intermediate value is:
Numbers that result from division are stored in the numerator and denominator. For example:
G1 = 2/3;The numerator of G1 contains 2 and the denominator 3
As a result of this type of storage, calculations such as (2/3) are not rounded off (0.6666667) and main-
tain their full precision. If the result (or intermediate result) of a calculation has a denominator larger
than 32,767, the values are converted to the closest fraction with a denominator of 10,000. Subsequent
calculations will then appear to be standard arithmetic with 4 decimal places of accuracy.
Variable Characteristics Summary
Name Qty Type Power-Up Resolution
G 64 Value Nonvolatile 4 byte mantissa + 2 byte numerator & 2 byte
denominator -or- 0.0001
V 64 Value Volatile 4 byte mantissa + 2 byte numerator & 2 byte
denominator -or- 0.0001
B 8 Flag Nonvolatile ON or OFF
F 64 Flag Volatile ON or OFF
G or V = ±+
±
±
2 147 483 648
32 767
32 767
,,,
,
,