242
6 BASIC INSTRUCTIONS
6.5 Data Conversion Instructions
6.5 Data Conversion Instructions
Converting binary data to BCD 4-digit data
BCD(P)
These instructions convert the binary data in the device specified by (s) to BCD data, and store the converted data in the
device specified by (d).
Binary data is used in operations in CPU module. Use this instruction to display numeric values on seven-segment display
unit equipped with BCD decoder.
■Descriptions, ranges, and data types
■Applicable devices
• These instructions convert the 16-bit binary data (0 to 9999) in the device specified by (s) to BCD 4-digit data, and store the
converted data in the device specified by (d).
• Data specified by (s) can be converted if it is within the range from K0 to K9999 BCD (decimal).
• The table below shows nibble specification for the data in the device specified by (s) and (d).
Ladder diagram Structured text
ENO:=BCD(EN,s,d);
ENO:=BCDP(EN,s,d);
Operand Description Range Data type Data type (label)
(s) Binary data or the head device where the binary data is
stored
0 to 9999 16-bit signed binary ANY16
(d) Head device for storing the BCD data BCD 4-digit 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
Make sure to set them to "0".
BCD conversion
BCD
(s) (d)
BIN
BCD
Command
input
When "K4Y000" is specified
CPU module BCD
Y14 to
Y17
Y10 to
Y13
Y4 to
Y7
Y0 to
Y3