What is BCD and How is it Used in Automation?The BCD system offers relative ease of conversion between machine-readable and human-readable numerals.
In this article, we will learn about BCD, Binary Coded Decimal, which offers relative ease of conversion between machine-readable and human-readable numerals.
As computers evolved from very early transistor-based models to the desktop personal computers using microchips, memory and instruction registers were 8-bits in length with computing, having to adapt to the standard decimal-based system.
Specific instructions used by programmers early on were designed with 8-bits in length to facilitate all of computing. These instructions have been maintained throughout the years of computer development, and will most likely continue to be used in the future.
Boolean Logic and Expressions
Within computers, each of the 8-bits has only two values for representing either a logic 1 (or True) and a logic 0 (or False).
This is what is referred to as Boolean in computer science. Boolean logic and expressions make the system of using binary numbers perfect for use in digital or electronic circuits and systems.
The BCD system offers relative ease of conversion between machine-readable and human-readable numerals.
Advantage of the BCD System
An advantage of the Binary Coded Decimal system is each decimal digit is denoted by a group of 4 binary digits and that it allows easy conversion between decimal a base-10 system and binary a base-2 system.
Disadvantage of the BCD System
A disadvantage is BCD code does not used all the states between binary 1010 for the decimal 10 and binary 1111 for the decimal 15.
Binary Numbering System Used in Computers
Binary coded decimal has specifically important applications using digital displays.
Now let’s talk about the binary numbering system used in computers.
This system is a Base-2 numbering system which follows the same set of rules used with decimal or base-10 number system.
Base-10 uses powers of ten, for example 1, 10, 100, 1000 and so on, where binary numbers use powers of two, effectively doubling the value of each sequential bit, for example 1, 2, 4, 8, 16, 32 and so on.
This conversion between binary and decimal values is called Binary-coded decimal and allows for easy conversion between decimal and binary numbers.
Binary-Coded Decimal or BCD
Binary-coded decimal or BCD is a code using a series of binary digits or bits that when decoded represents a decimal digit.
A decimal number contains 10 digits, zero to nine.
So, each decimal digit 0 through 9 is represented by a series of four binary bits where the numerical value when decoded is equivalent to a decimal digit.
In BCD we will use binary numbers from 0000-1001, which are equivalent to decimal 0-9.
Using the decimal number 5 for example, 5 in BCD is represented by 0101 and 2 in BCD is represented by 0010 and 15 in BCD is represented by 0001 0101.
Weighted BCD of Decimal Numbers and Weighted Decimal
Let’s look a bit closer on how this conversion works.
As you can see in the illustration below, the decimal weight of each decimal digit to the left increases by a factor of 10.
With BCD number system, the binary weight of each digit increases by a factor of 2.
The first digit has a weight of 1 or (20), the second digit has a weight of 2 or (21), the third digit has a weight of 4 or (22), and the fourth digit has a weight of 8 or (23).
BCD Truth Table
Now with the basic understanding of the binary-weighted system, the relationship between decimal numbers and weighted binary coded decimal digits for decimal values of 0 through 15 are provided as a truth table for BCD.
Binary-Coded Decimal vs. Binary to Decimal Conversion
Keep in mind, Binary-coded decimal is not the same as binary to decimal conversion. For example, if I would represent the decimal number 72 in both forms, the bit formation would be like this:
BCD: 0111 0010
Binary: 0100 1000
When we use a table to explain and expand out the weighted values, using 16 bits, we can convert the following decimal numbers: 9620, 120 and 4568 into their binary equivalents.
By adding together all the decimal number values from right to left from each of the bit positions that are represented by a 1 gives us the decimal equivalent.
9620 (=8192+1024+256+128+16+4) equals this Binary value: 0010 0101 1001 0100
120 (=64+32+16+8) equals this Binary value: 0000 0000 0111 1000
4568 (=4096+254+128+64+16+8) equals this Binary value: 0001 0001 1101 1000
However, for the same decimal number, the BCD form representation will be like this:
9620 (9, 6, 2, 0) equals this BCD value: 1001 0110 0010 0000
120 (1, 2, 0) equals this BCD value: 0001 0010 0000
4568 (4, 5, 6, 8) equals this BCD value: 0100 0101 0110 1000
Electronic circuits and systems can be divided into two types of circuits, analog and digital.
Analog Circuits amplify varying voltage levels that can alternate between a positive and negative value over a period of time and Digital Circuits produce distinct positive or negative voltage levels representing either a logic level 1 or a logic level 0 state.
HIGH and LOW States in Digital Signals
Voltages used in digital circuits could be any value, however in digital and computer systems they are below 10 volts.
In digital circuits voltages are called logic levels and typically one voltage level will represent a HIGH state, and the lower voltage level will represent a LOW state.
A binary number system will use both of these two states.
Digital signals consist of discrete voltage levels that change between these two HIGH and LOW states.
BCD Usage in Alpha-Numeric Display and RTC
BCD was commonly used for displaying alpha-numeric in the past but in modern-day BCD is still used with real-time clocks or RTC chips to keep track of wall-clock time and it’s becoming more common for embedded microprocessors to include an RTC.
It’s very common for RTCs to store the time in BCD format.
A binary clock might use LEDs to express binary values. With this clock each column of LEDs displays a binary-coded decimal numeral.
7 Segment Displays and Thumbwheel Switches
Back in the days, before touchscreens, seven segment displays, and thumbwheel switches were used for a numerical interface between PLCs and humans.
Even before the PLC, these BCD type devices were the only graphical way to interface with system circuits numerically.
BCD in Siemens S7 Standard Timer and Counter Data Types
Some PLCs for example, Siemens S7 standard timer and counter data types use Binary Coded Decimal in their data structures because these structures go back to when engineers had to deal with things like these thumbwheels and 7 segment displays.
In fact, the S7 timer setpoints are still entered as S5T#2S for a two-second setpoint because this is inherited from the S5 PLC platform.
These timers use three BCD digits or 12 bits and two extra bits for the time base. This is true for counters in which they only count from 0 to +999.
This concludes the article, What is Binary-Coded-Decimal or BCD and how is it used in Automation.
Want to Learn More?
By downloading the RealPars app, you can have access to a wealth of practical knowledge as an automation engineer right in your pocket and you will also receive new fresh out of the oven videos each and every week.
If you would like to get additional training on a similar subject please let us know in the comment section.
Check back with us soon for more automation control topics.
Got a friend, client, or colleague who could use some of this information? Please share this article.
In this blog post, you’ll learn about the mindset that helped me getting a PLC programming job with NO experience. This is my personal experience as someone who searched for a job in this field and as an employer who reviews resumes and interviews candidates for a variety of projects. So let’s get started!
Siemens has made their TIA-Portal version 16 available at a reduced price for a period of time. In this article, we will show you how to: - Purchase the TIA Portal version 16 software, - Download and install the software, and - Install the software license so that it...
A control valve is a power-operated device used to regulate or manipulate the flow of fluids, such as gas, oil, water, and steam. It is a critical part of a control loop and is an example of a final control element. The Control Valve is by far the most common final...
Learn how to program PLCs, install and wire industrial devices, and at the same time purchase them online.
+31 10 316 6400
Mon - Fri 8:30 am to 5:30 pm (CET)
Rotterdam Science Tower, Marconistraat 16,
3029AK Rotterdam, Netherlands
© 2020 RealPars B.V. All rights reserved.
Created with coffee and tea in Rotterdam.