BCD to Decimal Converter for PLCs
Convert between decimal and packed BCD (binary coded decimal), the code used by thumbwheel switches, 7 segment displays and some PLC timer and counter values. The PLC word is shown in hex and binary.
- Write each decimal digit as 4 bits: 1 = 0001, 2 = 0010, 3 = 0011, 4 = 0100
- BCD = 0x1234
BCD Encoding
1234 → 0001 0010 0011 0100 = 0x1234
Valid BCD nibbles: 0 to 9 only
Packed BCD stores one decimal digit in each 4 bit nibble, so a 16 bit word holds 0 to 9999 and a 32 bit word 0 to 99,999,999. PLCs provide BCD and BIN (or BCD_TO_INT) instructions to convert.
Worked example
Decimal 1234 in BCD is 0x1234 (0001 0010 0011 0100). If the PLC reads that word as a normal integer it shows 4660, a classic thumbwheel bug.
Frequently Asked Questions
What is BCD?
Binary coded decimal: each decimal digit is stored in 4 bits. It is easy to display but wastes some of the binary range.
Where is BCD used in PLCs?
Thumbwheel switches, 7 segment displays, some legacy timer and counter presets and real time clock registers.
Why does my value read 4660 instead of 1234?
The PLC is reading the BCD word 0x1234 as a binary integer. Use the BCD to integer conversion instruction.
Learn more on the blog
Introduction to number systems
A practical, field focused guide on instrumentationblog.in that explains the theory behind this calculator and how engineers apply it on real plants.
Read Full Article