Binary-Coded Decimal (BCD) is a digital encoding system where each individual decimal digit from 0 to 9 is represented by its own separate four-bit binary sequence. If you are asking what BCD is while troubleshooting a digital panel meter, a PLC counter, or a vintage digital clock, the short answer is that it is the hardware bridge between machine logic (base-2) and human readability (base-10). In a real circuit, using BCD changes how you route data: instead of sending an 8-bit pure binary word to represent a number up to 255, you send two 4-bit nibbles to represent two distinct decimal digits (00-99). This eliminates the need for complex binary-to-decimal division algorithms in hardware, at the cost of wasting six binary states per nibble.
Pure Binary vs. BCD: The Core Difference
The most common mistake hobbyists and junior technicians make is confusing BCD with pure binary or hexadecimal. While hexadecimal uses the letters A-F to represent values 10-15, BCD strictly forbids those states. BCD only cares about human-readable digits.
In pure binary, the entire string of bits is evaluated as a single mathematical value. In BCD, the string is chopped into 4-bit blocks, and each block is evaluated independently as a decimal digit from 0 to 9. According to foundational digital logic principles outlined by All About Circuits, this makes BCD highly inefficient for data storage, but incredibly efficient for driving displays.
| Decimal Value | Pure Binary (8-bit) | BCD (8-bit) | Hexadecimal |
|---|---|---|---|
| 5 | 0000 0101 | 0000 0101 | 0x05 |
| 9 | 0000 1001 | 0000 1001 | 0x09 |
| 10 | 0000 1010 | 0001 0000 | 0x0A |
| 15 | 0000 1111 | 0001 0101 | 0x0F |
| 19 | 0001 0011 | 0001 1001 | 0x13 |
| 47 | 0010 1111 | 0100 0111 | 0x2F |
Worked Numeric Example: Encoding a Digital Clock
Let us look at a real-world numeric example. Imagine you are programming an FPGA or wiring a discrete logic clock to display 47 seconds.
Step 1: The Pure Binary Approach
To represent the number 47 in pure 8-bit binary, you calculate the powers of two: 32 + 8 + 4 + 2 + 1.
Result: 0010 1111.
To drive a two-digit display with this, your hardware must perform a division by 10 to isolate the tens digit (4) and a modulo-10 operation to isolate the ones digit (7). In discrete logic, building a divider circuit for this is a nightmare of flip-flops and gates.
Step 2: The BCD Approach
In BCD, you ignore the total value of 47 and simply encode the digits '4' and '7' side-by-side.
Decimal 4 = 0100
Decimal 7 = 0111
Combined BCD Result: 0100 0111.
By keeping the tens and ones digits isolated in their own 4-bit nibbles, you can route the first nibble directly to a 'tens' display decoder, and the second nibble directly to a 'ones' display decoder. No division math is required in the hardware. As detailed in the Texas Instruments SN74LS47 Datasheet, the decoder chip simply reads the 4-bit nibble and pulls the corresponding segment pins low to illuminate the LED.
Where You Meet BCD in Practice
While modern software handles binary-to-decimal conversion in microseconds, BCD remains heavily used in specific hardware applications where software overhead is undesirable or where physical interfaces demand it.
- 7-Segment Display Decoders: The CD4511 (CMOS) and 74LS47 (TTL) are legendary BCD-to-7-segment latch/decoders. You feed them 4 BCD wires, and they handle the current sinking and segment mapping for the LED display.
- Industrial Thumbwheel Switches: Look at the back of an industrial motor drive or a Schneider Electric Zelio PLC relay. The physical dials used to set parameters (like a VFD acceleration time) are often BCD thumbwheel switches. They output 4 physical contacts (representing 1, 2, 4, 8) per digit, allowing the PLC to read a human-readable setting without an ADC.
- Digital Multimeters (DMMs): The analog-to-digital converters inside bench multimeters (like the classic ICL7106/7107 chips) natively output BCD signals to drive the LCD or LED front panel, because the measurement is inherently base-10.
- Real-Time Clocks (RTCs): Many I2C RTC modules (like the DS3231) store time registers in BCD format. When you read the seconds register over I2C, a value of 0x59 means 59 seconds (0101 1001 in BCD), not 89 seconds in pure decimal.
Hardware Math and the BCD Adder Correction
BCD gets complicated when you try to do math with it. If you add 5 (0101) and 4 (0100) in BCD, you get 9 (1001), which is perfectly valid.
But what happens when you add 5 (0101) and 8 (1000)? Standard binary addition yields 13 (1101). In BCD, 1101 is an illegal state. To fix this, hardware BCD adders (like the 74LS83 paired with correction logic) use the +6 correction rule. If the sum of a nibble exceeds 9, the circuit automatically adds 6 (0110) to the result. Adding 6 to 13 yields 19 (0001 0011), which correctly splits into a BCD '1' and a BCD '9', generating the proper carry bit to the next decimal column. For a deeper look at how these logic gates are arranged, Electronics Tutorials provides excellent gate-level schematics of BCD adders.
Frequently Asked Questions About BCD
What is BCD used for in modern microcontrollers?
While an ESP32 or Arduino handles pure binary math natively, BCD is still used when interfacing with legacy hardware, reading I2C real-time clocks (RTCs), or parsing data from industrial sensors that output 4-20mA scaled to BCD registers. It is also used in financial and embedded metering applications where exact decimal precision is required without floating-point rounding errors.
Why do people confuse BCD with hexadecimal?
The confusion stems from the fact that both systems group binary bits into 4-bit nibbles. However, hexadecimal is a base-16 system that uses the letters A, B, C, D, E, and F to represent values 10 through 15. BCD is strictly base-10; it simply stops at 9. If you see a 'C' in a data stream, it is hex, not BCD.
What is packed vs. unpacked BCD?
In packed BCD, two decimal digits are squeezed into a single 8-bit byte (one digit in the upper nibble, one in the lower nibble). This is highly efficient for memory. In unpacked BCD, each decimal digit takes up an entire 8-bit byte, with the upper 4 bits usually padded with zeros (or a sign indicator in mainframe computing). Microcontrollers typically use packed BCD to save RAM.
How do I read a BCD thumbwheel switch with an Arduino?
Wire the four output pins of the thumbwheel switch (labeled 1, 2, 4, 8) to four digital input pins on the Arduino, and wire the common pin to GND. Enable the internal pull-up resistors in your code. Read the pins, multiply the logic states by their respective weights (e.g., if the '4' pin reads LOW/active, add 4), and sum them. If the result is greater than 9, you have a wiring fault or a broken switch contact, as BCD cannot output a value higher than 9 per digit.






