Mitsubishi Electric FX2N Beginners Manual page 33

Hide thumbs Also See for FX2N:
Table of Contents

Advertisement

An Introduction to Programming
When binary numbers are stored in a word (see above) the value of each digit (position) in the
word is one power of 2 higher than that of the digit to its right. The principle is exactly the same
as in decimal representation, but with increments of 2 instead of 10 (see graphic):
Base 2 Notation
*
In binary values bit 15 is used to represent the sign (bit 15=0: positive value, bit 15=1: negative value)
To convert a binary value to a decimal value you just have to multiply each digit with a value of 1
by its corresponding power of 2 and calculate the sum of the results.
Example
00000010 00011001 (binary)
00000010 00011001 (binary) = 1 x 2
00000010 00011001 (binary) = 512 + 16 + 8 + 1
00000010 00011001 (binary) = 537 (decimal)
Hexadecimal numbers
Hexadecimal numbers are easier to handle than binary and it is very easy to convert binary
numbers to hexadecimal. This is why hexadecimal numbers are used so often in digital tech-
nology and programmable logic controllers. In the controllers of the MELSEC FX family hexa-
decimal numbers are used for the representation of constants. In the programming manual
and other manuals hexadecimal numbers are always identified with an H after the number to
avoid confusion with decimal numbers (e.g. 12345
Base: 16
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (the letters A, B, C, D, E and F represent the
decimal values 10, 11, 12, 13, 14 and 15)
The hexadecimal system works in the same way as the decimal system – you just count to F
(15) instead of to 9 before resetting to 0 and incrementing the next digit (F
à 30
2F
H
1A7F
H
FX Beginners Manual
15
14
13
12
11
2
2
2
2
2
0
0
0
0
0
Decimal Value
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
à 100
, FF
etc). The value of digit is a power of 16, rather than a power of 10:
H
H
H
0
16
= 1
(in this example: 15 x 1
1
16
= 16
(in this example: 7 x 16
2
16
= 256
(in this example: 10 x 256
3
16
= 4096
(in this example: 1 x 4096
10
9
8
7
6
2
2
2
2
2
2
0
0
0
0
0
0
Base 2 Notation
1
2
4
8
16
32
64
128
9
4
3
+ 1 x 2
+ 1 x 2
+ 1 x 2
).
H
Number Systems
5
4
3
2
1
0
2
2
2
2
2
0
0
0
0
0
Decimal Valuet
8
2
256
9
2
512
10
2
1024
11
2
2048
12
2
4096
13
2
8192
14
2
16384
15
2
32768*
0
à 10
H
H
= 15)
= 112)
= 2560)
= 4096)
6783 (decimal)
H
à 20
, 1F
,
H
H
3 – 3

Advertisement

Table of Contents
loading

Table of Contents