246
6 BASIC INSTRUCTIONS
6.5 Data Conversion Instructions
Converting BCD 4-digit data to binary data
BIN(P)
These instructions convert the binary-coded decimal data in the device specified by (s) to binary data, and store the converted
data in the device specified by (d).
Use this instruction to convert a binary-coded decimal (BCD) value such as a value set by a digital switch into binary (BIN)
data and to receive the converted binary data so that the data can be handled in operations in CPU module.
■Descriptions, ranges, and data types
■Applicable devices
• These instructions convert the BCD 4-digit data (0 to 9999) in the device specified by (s) to 16-bit binary data, and store the
converted data in the device specified by (d).
• The data in the device specified by (s) can be converted if it is in the range from 0 to 9999 (BCD).
• The table below shows nibble specification for the data in the device specified by (s) and (d).
Ladder diagram Structured text
ENO:=BIN(EN,s,d);
ENO:=BINP(EN,s,d);
Operand Description Range Data type Data type (label)
(s) Binary-coded decimal data or the head device where the
binary-coded decimal data is stored
0 to 9999 BCD 4-digit ANY16
(d) Head device for storing the binary data 16-bit signed binary ANY16
Operand Bit Word Double word Indirect
specification
Constant Others
X, Y, M, L,
SM, F, B, SB
U\G T, ST,
C, LC
T, ST, C, D,
W, SD, SW, R
U\G Z LC LZ K, H E $
(s)
(d)
BIN 9999
BCD 9999
32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1
1100 00 000011
11111111
1111
00 00 00 00
(s)
(d)
Thousands place Hundreds place Tens place Ones place
Always becomes "0".
Binary conversion
BIN
(s)
(d)
BCD
BIN
9786
BIN CPU module
Command
input
In case of K4X0
X14 to
X17
X10 to
X13
X4 to
X7
X0 to
X3