# What is BCD in Automation and Why is it Still Used?

Binary Coded Decimal (BCD) has been an integral part of automation systems for decades Even though newer data types have emerged, BCD continues to be used in modern automation controllers like PLCs In this article, we will take a closer look at what BCD is, why it was created, its advantages and disadvantages, and the reasons it is still commonly used in the automation industry today.

## What is Binary Coded Decimal (BCD)?

Binary Coded Decimal (BCD) is a binary encoding of decimal numbers. In BCD, each digit of a decimal number is represented by a binary sequence. This allows easy conversion between human-readable decimal numbers and machine-readable binary numbers.

Here’s an example

Decimal: 27
BCD: 0010 0111

As you can see, the decimal number 27 is represented by the binary sequence 0010 for the “2” and 0111 for the “7”.

Each decimal digit in BCD is represented by a 4-bit binary sequence:

• Decimal 0 = 0000
• Decimal 1 = 0001
• Decimal 2 = 0010
• Decimal 3 = 0011
• Decimal 4 = 0100
• Decimal 5 = 0101
• Decimal 6 = 0110
• Decimal 7 = 0111
• Decimal 8 = 1000
• Decimal 9 = 1001

So in BCD, every decimal number from 0 to 9 has a corresponding 4-bit binary representation. By concatenating the 4-bit codes for each decimal digit, any decimal number can be uniquely encoded in binary.

## Why Was BCD Created?

BCD was created to simplify the interface between digital circuitry and decimal numeric displays like seven-segment displays. In the early days of digital circuits, engineers needed an easy way to display decimal digits on numerical displays. BCD provided a straightforward mapping that allowed each display segment to operate based on 1 bit from the binary representation of the digit.

Before BCD, pure binary numbers were used internally in computers and other digital devices. But binary numbers are not intuitive for humans to read and understand. BCD bridged this gap by providing effortless conversion between binary and familiar decimal numerals.

Here are some of the key advantages of Binary Coded Decimal:

• Simple decimal digit encoding: BCD offers a very straightforward way to encode a decimal digit in binary using 4 bits. This simplicity made it easy for early digital circuits to interface with decimal numeric displays.

• Efficient storage: Storing a decimal number in pure binary would require more bits than in BCD. For example, the decimal number 27 is 10111 in pure binary but 0010 0111 in BCD. So BCD provides more compact storage.

• Easy conversion: BCD allows quick and painless conversion between human-readable decimals and machine-readable binaries. The 4-bit patterns make decoding simple.

• Error detection: Because only certain 4-bit patterns are valid in BCD, it easy to detect encoding errors by looking for invalid bit sequences. Pure binary does not have this inherent error detection ability.

BCD also comes with the following drawbacks:

• Range limits: Since BCD uses 4 bits per digit, it can only represent numbers from 0 to 9999. For larger numbers, more bits are required.

• Inefficient math operations: Mathematical operations like addition and subtraction are more complex on BCD numbers than pure binaries. Extra conversion steps are required.

• No representation for hexadecimal: BCD can only handle decimal numbers, while hexadecimal (base 16) numbers require pure binary representation.

• Not widely used in computers: Modern processors and memory use pure binary rather than BCD to represent numbers internally.

## Why is BCD Still Used in Automation?

Despite its drawbacks, BCD enjoys continued use in modern automation systems like PLCs. Here are some key reasons:

• Compatible with old systems: Current automation controllers still need to interface with legacy systems, panels, and displays that use BCD. So support for BCD is maintained for backwards compatibility.

• Human interaction: In industrial settings, human machine interaction often involves decimal numeric data. BCD makes it easy to display this data to operators and technicians.

• Timer/Counter presets: Timers and counters in PLCs allow setting presets and limits using BCD thumbwheel switches. The presets get stored internally in BCD format.

• Real-time clocks: Real-time clocks and date chips used in automation devices like PLCs often use BCD to store the time and date values.

• Less memory for decimal data: Storing decimals in pure binary takes more memory space. BCD’s compact encoding helps optimize memory in space-constrained PLCs.

• Easy debugging: Viewing data in BCD during troubleshooting makes decimal numbers more human-readable compared to raw binary.

## Examples of BCD Usage

Here are some examples of where Binary Coded Decimal is still utilized in modern automation systems:

• PLC Timers and Counters: As mentioned above, PLC timers and counters often accept BCD thumbwheel presets and store values internally in BCD format. For example, Siemens S7 timers use 12 bits of BCD to represent countdown values.

• Operator Panels: Many operator panels and HMIs use BCD to display numeric data to plant technicians and machine operators. This avoids showing cryptic pure binary representations.

• Digital Panel Meters: Digital panel meters that display analog values from sensors commonly use BCD. This allows easy calibration using decimal numbers.

• Serial Communications: Automation protocols like Modbus have data types to represent BCD digits. This enables devices to communicate BCD data efficiently.

• Robotics: In robotics applications, BCD is used to convert decimal values into machine-readable data that can be processed by the robotic arm controllers.

Although BCD has some disadvantages compared to pure binary, it continues to be used in modern automation systems due to its compact storage, human readability, and compatibility with legacy components. So while newer data types have emerged, the venerable BCD system still plays an important role in industrial automation today.

## What is the difference between BCD and American Standard Code for Information Interchange (ASCII) code?

BCD is a numerical representation scheme used to represent decimal digits, while ASCII is a character encoding scheme used to represent letters, symbols, and other characters used in text-based communication.

## What is the difference between unpacked BCD and packed BCD?

Unpacked BCD uses one byte (eight bits) to represent each decimal digit, while packed BCD uses four bits to represent each decimal digit. Packed BCD is more space-efficient but requires additional processing to convert to and from unpacked BCD.

## What is Binary Coded Decimal (BCD) and How is it Used in Automation?

What is BCD in automation?

Binary-coded decimal (BCD) in automation is a type of code that uses binary symbols to represent decimal digits, meaning the series of numbers following a decimal point. Binary refers to a class of computing languages that only use two symbols in their code, usually zero and one.

What is binary-coded decimal (BCD)?

Binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each decimal is represented by a fixed number of bits, usually four or eight, which goes against the way humans compute data. This disconnect can cause problems for programmable logic controller (PLC) users. Computers hate decimals.

What is a BCD data type?

This is exactly the purpose of BCD. When interfacing with older displays and devices, it is possible in many PLCs and control systems to reserve multiples of 4 bits with a BCD data type. The system will recognize how this number converts to decimal and typical binary.

What is BCD encoding?

An obvious way of encoding digits is Natural BCD (NBCD), where each decimal digit is represented by its corresponding four-bit binary value, as shown in the following table. This is also called “8421” encoding. This scheme can also be referred to as Simple Binary-Coded Decimal ( SBCD) or BCD 8421, and is the most common encoding.