L9_DIV: Divide
(Original Document)
Naming
Name in LL984 Editor
Function Block Name
name of legacy 984 instruction
name in other tools and editors like:
  • Type Library Browser
  • Data Editor
  • Animation Tables
  • Search Results
Function Description
The L9_DIV procedure divides unsigned VALUE1 by unsigned VALUE2, and then posts the quotient in the RESULT word and the remainder in the RESULT+1 implied word.
L9_DIV has two inputs. The divide operation begins when the input to the ENABLE pin is turned ON. The REM input indicates whether any remainder value will be expressed as a decimal (ON) or fraction (OFF) value.
L9_DIV can activate 1 of 3 outputs. The OUT output turns ON upon the successful completion of the operation. The OVERFL output turns ON if there is an overflow in the RESULT. The DIVBY0 output turns ON if VALUE2 equals 0.
Formula
RESULT[1] = VALUE1 / VALUE2
RESULT[2] = VALUE1 MOD VALUE2 (fraction) or
RESULT[2] = (VALUE1 MOD VALUE2)*(10000 / VALUE2) (decimal)
Representation
Parameters
Input Pin
Name
Data Type
Address Range
Meaning
Top
ENABLE
OFF to ON initiates the operation.
Middle
REM
BOOL
Indicates how any remainder will be expressed; ON = decimal; OFF = fraction.
Node
Node
Name
Data Type
Address Range
Meaning
Top
IN
VALUE1
ArrUINT2
The dividend.
Can be either a double precision value with a valid range of 0..99,999,999 or a constant value with a range of 0..65,535.
Middle
IN
VALUE2
UINT
%IW, %MW
The divisor can be displayed as an integer constant, or can be stored in a variable located in a %IW input word, a %MW memory word or an unlocated word.
Valid range: 0..65,535
Bottom
IN/OUT
RESULT
ArrUINT2
%MW
The quotient and any remainder. Must be located in 2 %MW memory words or 2 unlocated UINT words; the first word holds the quotient, the second word holds the remainder. For example, if VALUE1 = 8 and VALUE2 = 3:
  • the quotient value in the first word is 2
  • the remainder value in the second word can be expressed as either the decimal value 6,666 or the fractional value 2.
Output Pin
Name
Data Type
Address Range
Meaning
Top
OUT
BOOL
ON indicates the division operation succeeded. (Echoes the status of the ENABLE input).
Middle
OVERFL
BOOL
ON indicates an overflow: the value in the first RESULT word > 9,999.
Bottom
DIVBY0
BOOL
ON indicates VALUE2 = 0, thereby attempting division by 0.