Mitsubishi Electronics FX3G Video Gaming Accessories User Manual


 
289
FX3G/FX3U/FX3UC Series Programmable Controllers
Programming Manual - Basic & Applied Instruction Edition
10 Arithmetic and Logical Operation (
+
,
,
×
,
÷
) – FNC 20 to FNC 29
10.10 FNC 29 – NEG / Negation
1
Introduction
2
Overview
3
Instruction
List
4
Devices
in Detail
5
Specified the
Device &
Constant
6
Before
Programming
7
Basic
Instruction
8
FNC00-FNC09
Program Flow
9
FNC10-FNC19
Move & Compare
10
FNC20-FNC29
Arith. & Logic
Operation
Program examples
The program examples below are provided to obtain the absolute value of a negative binary value.
1. Obtaining the absolute value of a negative value using NEG instruction
2. Obtaining the absolute value by SUB (subtraction) instruction
Even if NEG instruction is not used, D30 always stores the absolute value of the difference.
Negative value expression and absolute value (reference)
In PLCs, a negative value is expressed in 2’s complement.
When the most significant bit is "1", it is a negative value, and its absolute value can be obtained by NEG
instruction.
M 0
FNC 29
NEGP
D 10
M8000
FNC 44
BON
D 10 M 0 K 15
RUN monitor
In BON (ON bit check) instruction, M0 turns ON
when the bit 15 (b15 among b0 to b15) of D10 is "1".
NEGP instruction is executed for D10 only when M0
turns ON.
D10
D10
X000
M 10
M 11
M 12
FNC 21
SUB
D 10 D 20 D 30
FNC 21
SUB
D 20 D 10 D 30
FNC 10
CMP
D 10 D 20 M 10
(D 10) > (D 20) (D10) = (D 20) (D 10) < (D 20)
M 10 = ON M 11 = ON M 12 = ON
In the case of "D10
D20",
D10
D20
D30.
In the case of "D10 < D20",
D20
D10
D30.
(D 10) = 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
(D 10) = 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
(D 10) = 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(D 10) =
1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
(D 10) =
2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(D 10) =
32767
(D 10) =
32768
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
(D 10) + 1 = 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
(D 10) + 1 = 2
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
(D 10) + 1 = 32767
(D 10) + 1 =
32768
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The absolute value can be obtained up to 32767.
......
......