Math Instructions - Mitsubishi Electric FX2N Beginners Manual

Hide thumbs Also See for FX2N:
Table of Contents

Advertisement

More Advanced Programming
5.4

Math Instructions

All the controllers of the MELSEC FX family can perform all four basic arithmetical operations
and can add, subtract, multiply and divide integer numbers (i.e. non-floating-point numbers).
These instructions are described in this section.
The controller base units of the FX
series can also process floating-point numbers. This is done with special instructions that are
documented in detail in the Programming Manual of the MELSEC FX series.
After every addition or subtraction you should always program instructions to check the states
of the special relays listed below to see whether the result is 0 or has exceeded the permitted
value range.
b M8020
This special relay is set to "1" if the result of an addition or subtraction is 0.
b M8021
Special relay M8021 is set to "1" if the result of an addition or subtraction is smaller than
-32,767 (16-bit operations) or -2,147,483,648 (32-bit operations).
b M8022
Special relay M8022 is set to "1" if the result of an addition or subtraction is greater than
+32,767 (16-bit operations) or +2,147,483,647 (32-bit operations).
These special relays can be used as enable flags for continuing with additional math opera-
tions. In the following example the result of the subtraction operation in D2 is used as a divisor.
Since dividing by 0 is impossible and causes an error the division is only executed if the divisor
is not 0.
Ladder Diagram
M8000
0
M8020
8
FX Beginners Manual
, FX
FX
2N
2NC,
SUB D0 D1 D2
DIV D3 D2 D5
, FX
, FX
, FX
3G
3GC
3GE
3S
Instruction List
0 LD
M8000
1 SUB
D0
8 LDI
M8020
9 DIV
D3
Math Instructions
, FX
and FX
3U
3UC
D1
D2
D2
D5
5 – 21

Advertisement

Table of Contents
loading

Table of Contents