5 -11
5.3.2 The Coding of Numeric Numbers for FBs-PLC
FBs-PLC use the binary numbering system for its internal operations that is the data of external BCD inputs must be
converted to binary number before the PLC can process. As we know the binary code is very difficult to read and input to
the PLC for human, therefore FP-07 and WinProladder use the decimal unit or hexadecimal unit to input or to display the
data. But in reality, all the operations taking place in the PLC are performed with binary code.
Remark: If you input or display the data without going through the FP-07 or WinProladder (For instance, input data
into or take out data from PLC through the I/O terminals using thumb wheel switch or seven segment
display), then you have to use the Ladder program to perform the Decimal to Binary conversion. This
enables you to input and display data without using the FP-07 and WinProladder. Please refer to
FUN20(BIN
→
BCD) and FUN21(BCD
→
BIN).
5.3.3 Range of Numeric Value
As we have mentioned before that FBs-PLC uses binary numbers for its internal operations. 16-bit and 32-bit are
three different numeric data of FBs-PLC. The ranges of the three numeric values are shown below.
16-bit
−
32768
~
32767
32-bit
−
2147483648
~
2147483647
Floating point number
±
(1.8*10
-38
~
3.4*10
38
)
5.3.4
Representation of Numeric Value
(Beginners can skip this section)
The representation and specification of 16-bit and 32-bit numeric values are provided below to enable the user to further
understand the numeric value operation for more complicated applications.
The most significant bits MSB of 16-bits and 32-bits (B15 for 16-bit and B31 for 32-bit) are used to identify positive and
negative numbers (0: positive and 1: negative). The remaining bits (B14~B0 or B30~B0) represent the magnitude of the
number. The following example uses 16-bit for further explanations. Please note that everything also applies to 32-bit
numbers and the only difference is the length.
0: Positive Number
163
84
819
2
409
6
204
8
102
4
512
256
128
64
32
16
8
4
2
1
12345
Ö
0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 1
Ö
3039H
(Decimal)
B15
B0
(Hexadecimal)
8192+4096+32+16+8+1=12345
In the above example, regardless of its size (16-bit or 32-bit), and starting with the least significant bit LSB (B0). B0 is 1,
B1 is 2, B2 is 4, B3 is 8, and so on. The number represented by the neighboring left bit will double its value (1, 2, 4, 8, 16,
and so on) and the value is the sum of the numbers represented by the bits that are equal to 1.