Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (16.5 MB, 964 trang )
FX3S/FX3G/FX3GC/FX3U/FX3UC Series
Programming Manual - Basic & Applied Instruction Edition
5.1.2
5 How to Specify Devices and Constants to Instructions
5.1 Numeric Values Handled in PLC (Octal, Decimal, Hexadecimal and Real Numbers)
Conversion of numeric values
Numeric values handled in FX PLCs can be converted as shown in the table below:
Decimal number (DEC)
Octal number (OCT)
Hexadecimal number
(HEX)
0
0
00
0000
0000
0000
0000
1
1
01
0000
0001
0000
0001
2
2
02
0000
0010
0000
0010
3
3
03
0000
0011
0000
0011
4
4
04
0000
0100
0000
0100
5
5
05
0000
0101
0000
0101
6
6
06
0000
0110
0000
0110
7
7
07
0000
0111
0000
0111
8
10
08
0000
1000
0000
1000
0B
0000
1011
0001
0001
12
14
0C
0000
1100
0001
0010
13
15
0D
0000
1101
0001
0011
14
16
0E
0000
1110
0001
0100
15
17
0F
0000
1111
0001
0101
16
20
10
0001
0000
0001
0110
99
143
0011
1001
1001
Octal number (OCT)
Hexadecimal number
(HEX)
•••
0110
•••
63
•••
•••
13
•••
0000
11
•••
1001
•••
0000
0001
•••
1001
1010
•••
0000
0000
•••
09
0A
•••
11
12
•••
9
10
•••
BCD
•••
Binary number (BIN)
Major applications
Decimal number (DEC)
Constants (K) and
numbers of internal
devices except I/O
relays
154
Numbers of internal
I/O relays
Constants (H)
Binary number (BIN)
Processing inside
PLC
BCD
BCD digital switches
and seven-segment
display units
FX3S/FX3G/FX3GC/FX3U/FX3UC Series
5 How to Specify Devices and Constants to Instructions
Programming Manual - Basic & Applied Instruction Edition
1
Handling of numeric values in floating point operations
Introduction
5.1.3
5.1 Numeric Values Handled in PLC (Octal, Decimal, Hexadecimal and Real Numbers)
3
When handling a binary floating point (real number) in data registers, use a pair of data registers having consecutive
device numbers.
When D11 and D10 are used, for example, a binary floating point is handled as shown below:
D 11(b15 to b0)
2
2
6
2
5
2
1
2
0
D 10(b15 to b0)
2
-1
2
-2
2
-3
2-21
2-22
4
2-23
E7
E6
E5
E1
E0
A22
A21
A20
A2
A1
A0
b31
b30
b29
b28
b24
b23
b22
b21
b20
b2
b1
b0
23 bits in
mantissa part
A0 to A22 = 0 or 1
Sign for mantissa part
(0: Positive, 1: Negative)
0 in case "b0 to b31 = 0"
=
5
Specified the
Device &
Constant
8 bits in
exponent part
E0 to E7 = 0 or 1
Devices
in Detail
S
Binary floating point (real number)
± (20 + A22 × 2−1 + A21 × 2−2 + ... + A0 × 2−23)
× 2 (E7 × 2 + E6 × 2 + ... + E0 × 2 )/2127
Example: A22=1 , A21=0, A20=1, A19 to A0=0, E7=1, E6 to E1=0, E0=1
=
=
± (20 + 1 × 2−1 + 0 × 2−2 + 1 × 2−3 + ... + 0 × 2−23)
× 2 (1 × 2 + 0 × 2 + ... + 1 × 2 )/2127
±1.625 × 2129/2127 = ±1.625 × 22
6
Before
Programming
Binary floating point (real number)
Instruction
List
Binary floating point (real number)
7
2
Overview
Handling of numeric values in floating point operations
Binary integers are handled inside PLCs.
During division of integers, the answer "40 ÷ 3 = 13 ... 1" is obtained, for example.
During square root extraction operations, decimal points are ignored.
In FX3S, FX3G, FX3GC, FX3U and FX3UC PLCs, floating point operations are available to achieve higher accuracy in
such operations.
The sign bit b31 states whether data is positive or negative, but is not handled as a complement.
7
Basic
Instruction
Number of significant figures
The number of significant figures of binary floating point is approximately 7 when expressed in decimal. The binary
floating point range is as follows:
- Least absolute value: 1175494 × 10-44
- Most absolute value: 3402823 × 1032
8
- Zero flag
- Borrow flag
- Carry flag
FNC00-FNC09
Program Flow
Handling of the zero (M8020), borrow (M8021) and carry (M8022) flags
These flags operate as follows in floating point operations.
: 1 when the result is 0
: 1 when the result does not reach the minimum unit but is not 0
: 1 when the absolute value of the result exceeds the available numeric value range.
9
FNC10-FNC19
Move & Compare
Monitoring of binary floating point (real number)
A programming software supporting the display of floating point such as GX Works2 and GX Developer can directly
monitor binary floating point (real number).
A programming tool not supporting the display of floating point can monitor binary floating point (real number) when it
is converted into scientific notation (real number).
10
FNC20-FNC29
Arith. & Logic
Operation
155
FX3S/FX3G/FX3GC/FX3U/FX3UC Series
5 How to Specify Devices and Constants to Instructions
Programming Manual - Basic & Applied Instruction Edition
5.1 Numeric Values Handled in PLC (Octal, Decimal, Hexadecimal and Real Numbers)
Scientific notation (real number)
Because binary floating point (real number) is difficult to understand for users, it can be converted into scientific
notation (real number). But internal operations are executed using binary floating point (real number).
Scientific notation (real number) is handled by a pair of data registers having serial device numbers. Different from
binary floating point (real number), a data register having a smaller device number handles the mantissa part, and the
other data register having a larger device number handles the exponent part.
For example, when data registers D1 and D0 are used, they handle scientific notation as shown below. Data can be
written to D0 and D1 by MOV instruction.
Scientific notation (real number) =
[Mantissa D0] × 10 [Exponent D1]
Mantissa D0 = ± (1000 to 9999) or 0
Exponent D1 = −41 to +35
The most significant bit of D0 and D1 specifies the positive or negative sign respectively, and is handled as the
complement of 2 respectively.
The mantissa D0 does not allow "100", for example. In the case of "100", it is handled as "1000 × 10−1".
The scientific notation (real number) range is as follows:
- Minimum absolute value: 1175 × 10−41
- Maximum absolute value: 3402 × 1035
Number of significant figures
The number of significant figures of scientific notation is approximately 4 when expressed in decimal. The scientific
notation range is as described above.
Scientific notation (real number) is valid in the following instructions:
- Conversion from binary floating point (real number) into scientific notation (real number): FNC118 ([D]EBCD)
- Conversion from scientific notation (real number) into binary floating point (real number): FNC119 ([D]EBIN)
156
FX3S/FX3G/FX3GC/FX3U/FX3UC Series
5 How to Specify Devices and Constants to Instructions
Programming Manual - Basic & Applied Instruction Edition
1
Specification of Constants K, H and E
(Decimal, Hexadecimal and Real Number)
Introduction
5.2
5.2 Specification of Constants K, H and E (Decimal, Hexadecimal and Real Number)
5.2.1
Constant K (decimal number)
- When word data (16 bits) is used ...... K-32768 to K32767
- When double data (32 bits) is used ... K-2,147,483,648 to K2,147,483,647
4
Constant H (hexadecimal number)
Devices
in Detail
"H" indicates a hexadecimal number, and is mainly used to specify numeric values as operands in applied instructions.
(Example: H1234)
When using digits 0 to 9, the bit status (1 or 0) of each bit is equivalent to the BCD code, so BCD data can be specified
also.
(Example: H1234 ... When specifying BCD data, specify each digit of hexadecimal number in 0 to 9.)
The hexadecimal constant setting range is as follows:
5
Specified the
Device &
Constant
- When word data (16 bits) is used ...... H0 to HFFFF
(H0 to H9999 in the case of BCD data)
- When double data (32 bits) is used ... H0 to HFFFFFFFF (H0 to H99999999 in the case of BCD data)
5.2.3
3
Instruction
List
"K" indicates a decimal integer, and is mainly used to specify the set value of timers and counters and numeric values
as operands in applied instructions. (Example: K1234)
The decimal constant specification range is as follows:
5.2.2
2
Overview
When handling constants in a sequence program, use constant K (decimal), H (hexadecimal) or E (floating point).
In peripheral equipment for programming, add "K" to a decimal number, "H" to a hexadecimal number and "E" to a
floating point (real number) for operations associated with numeric values in instructions. (Examples: K100 (decimal
number), H64 (hexadecimal number) and E1.23 (or E1.23 + 10) (real number))
The roles and functions of constants are described below.
Constant E (real number)
6
Specify a numeric value as it is.
For example, specify "10.2345" in the form "E10.2345".
- Exponent expression: ..............
7
Basic
Instruction
- Normal expression: ..................
Before
Programming
"E" indicates a real number (floating point data), and is mainly used to specify numeric values as operands in applied
instructions. (Example: E1.234 or E1.234 + 3)
The real number setting range is from −1.0 × 2128 to −1.0 × 2−126, 0 and 1.0 × 2−126 to 1.0 × 2128.
In a sequence program, a real number can be specified in two methods, "normal expression" and "exponent
expression".
Specify a numeric value in the format "(numeric value) × 10n".
For example, specify "1234" in the form "E1.234 + 3".
"+3" in "E1.234 + 3" indicates "103".
8
FNC00-FNC09
Program Flow
9
FNC10-FNC19
Move & Compare
10
FNC20-FNC29
Arith. & Logic
Operation
157
FX3S/FX3G/FX3GC/FX3U/FX3UC Series
5 How to Specify Devices and Constants to Instructions
Programming Manual - Basic & Applied Instruction Edition
5.3
5.3 Character Strings
Character Strings
Character strings are classified into character string constants which directly specify character strings in operands in
applied instructions and character string data.
5.3.1
Character string constant ("ABC")
A device "character string" directly specifies a character string in a sequence program.
Put half-width characters inside quotation marks (example: "ABCD1234") in specification.
JIS8 code is available.
Up to 32 characters can be specified as a character string.
5.3.2
Character string data
With regard to character string data, a specified device to the NULL code (00H) is handled as one character string in
1-byte units.
When expressing (recognizing) character string data by bit devices with digit specification, however, 16 bits are
required for data including the NULL code (00H) specifying the end of the character string data because the instruction
length is 16 bits. (Refer to Example 2 in the step 2 below.)
In the following cases, an operation error occurs in the applied instruction (error code: K6706):
• When "00H" is not specified in the corresponding device range after the source device number specified in an
applied instruction
• When there are insufficient devices for storing character string data (including "00H" or "0000H" indicating the end
of the character string data) in the destination devices specified in an applied instruction
1)
Character string data stored in word devices
• Example of data which can be
recognized as character string data
b15
D100
D101
D102
b8 b7
• Example of data which cannot be
recognized as character string data
b0
b15
1st character
3rd character
5th character
D100
D101
00H
21st character
D7999 "n"th character
D102
"00H" indicating the end of
the character string can be
detected.
2)
2nd character
4th character
6th character
b0
1st character
3rd character
5th character
…
…
D110
b8 b7
2nd character
4th character
6th character
"(n-1)"th character
"00H" indicating the end of character string
cannot be detected from the specified
device to the end device number.
Character string data stored in bit devices with digit specification
• Example of data which can be
• Examples of data which cannot be
recognized as character string data
recognized as character string data
16 bits
16 bits
M115 to M100 2nd character
M131 to M116 4th character
M147 to M132
00H
13th character
…
M211 to M196
M115 to M100
M131 to M116
M147 to M132
2nd character
4th character
6th character
1st character
3rd character
5th character
…
6th character
1st character
3rd character
5th character
"00H" indicating the
end of the character
string can be
detected.
M7679 to
M7664
M7623 to M7608
M7639 to M7624
M7655 to M7640
M7671 to M7656
M7679 to M7672
"n"th character "(n-1)"th character
"00H" indicating the end of character string
cannot be detected from the specified
device to the end device number.
16 bits
2nd character
4th character
6th character
8th character
1st character
3rd character
5th character
7th character
00H
Because the data "00H" indicating the end
of the character string does not reach 16
bits, the end of the character string cannot
be recognized.
158