DL06 Micro PLC User Manual, 3rd Edition, Rev. E
5-260
Chapter 5: Standard RLL Instructions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A
B
C
D
Math - Binary (MATHBIN) (IB-501)
Math - Binary Format lets you enter complex mathematical expressions like you would in
Visual Basic, Excel, or C++ to do complex calculations, nesting parentheses up to 4 levels deep.
In addition to + - * /, you can do Modulo (% aka Remainder), Shift Right (>>) and Shift Left
(<<), Bit-wise And (&) Or (|) Xor (^), and some binary functions - Convert to BCD (BCD),
Convert to Binary (BIN), Decode Bits (DECO), Encode Bits (ENCO), Invert Bits (INV),
HEX to Seven Segment Display (SEG), and Sum Bits (SUM).
Example: ((V2000 + V2001) / (V2003 - K10)) *
SUM(V3000 & K001F)
Every V-memory reference MUST be to a single word binary formatted value. Intermediate
results can go up to 32 bit values, but as long as the final result fits in a 16 bit binary word,
the calculation is valid. Typical example of this is scaling using multiply then divide, (V2000
* K1000) / K4095. The multiply term most likely will exceed 65535 but fits within 32 bits.
The divide operation will divide 4095 into the 32-bit accumulator, yielding a result that will
always fit in 16 bits.
You can reference BCD V-Memory values by using the BIN conversion function on a
V-memory location but NOT an expression. That is, BIN(V2000) is okay and will convert
V2000 from BCD to Binary, but BIN(V2000 + V3000) will add V2000 as Binary, to V3000
as Binary, then interpret the result as BCD and convert it to Binary - NOT GOOD.
Also, the final result is a 16 bit binary number and so you could do BCD around the entire
operation to store the result as BCD.
MATHBIN Parameters
• WORD Result: specifies the location where the binary result of the mathematical expression will be
placed (result must fit into 16 bit single V-memory location)
• Expression: specifies the mathematical expression to be executed and the result is stored in specified
WORD Result. Each V-memory location used in the expression must be in binary format.
Parameter
DL06 Range
WORD Result
V
See DL06 V-memory map - Data Words
Expression
Text
DS
Used
HPP
N/A