Binary Codes
Binary Codes
BCD is a way to express each of the decimal digits with a binary code.
There are only ten code groups in the BCD system, so it is very easy to convert
between decimal and BCD.
Because we like to read and write in decimal, the BCD code provides an excellent
interface to binary systems.
Binary-to-BCD Conversion
The Gray code is unweighted and is not an arithmetic code; that It cannot be used for any arithmetic
is, there are no specific weights assigned to the bit positions. operations like addition, subtraction,
multiplication, and division (Boolean
The important feature of the Gray code is that it exhibits only a single algebraic operations).
bit change from one code word to the next in sequence.
Gray code implements a unique system
This property is important in many applications, such as shaft where only one bit changes for every
position encoders, where error susceptibility increases with the decimal number.
number of bit changes between adjacent numbers in a sequence.
This ensures alignment and
synchronicity, thus reducing error rate.
Binary Codes- The Gray Code
Gray code to encode data is much less than
the worst-case error encountered in the case of
straight binary encoding.
The last entry rolls over to the first entry. That is,
the last and the first entry also differ by only 1
bit. This is known as the cyclic property of the
Gray code.
The following rules explain how to convert from a binary number to a Gray code word:
The most significant bit (left-most) in the Gray code is the same as the corresponding
MSB in the binary number.
Going from left to right, add each adjacent pair of binary code bits to get the next Gray
code bit. Discard carries.
Binary Codes- The Gray Code
Gray-to-Binary Code Conversion
The following rules apply:
The most significant bit (left-most) in the binary code is the same as the corresponding bit in the Gray code.
Add each binary code bit generated to the Gray code bit in the next adjacent position.
Discard carries.
For example, the conversion of the Gray code word 11011 to binary is as follows:
The generalized representation of the code is the (n, k)-Gray code, where n is the number of independent digits used
and k is the word length.
A ternary Gray code (n=3) uses the values 0, 1 and 2, and the sequence of numbers in the two-digit word length
would be (00, 01, 02, 12, 11, 10, 20, 21, 22).
In the quaternary (n=4) code, using 0, 1, 2 and 3 as independent digits and a two-digit word length, the sequence of
numbers would be (00, 01, 02, 03, 13, 12, 11, 10, 20, 21, 22, 23, 33, 32, 31, 30).
It is important to note here that an (n, k) Gray code with an odd n does not exhibit the cyclic property of the binary
Gray code, while in case of an even n it does have the cyclic property.
Binary Codes- The Gray Code - Applications
The Gray code is used in the transmission of digital signals as it minimizes the occurrence of errors.
The Gray code is preferred over the straight binary code in angle-measuring devices. Use of the Gray
code almost eliminates the possibility of an angle misread, which is likely if the angle is represented in straight
binary. The cyclic property of the Gray code is a plus in this application.
The Gray code is used for labelling the axes of Karnaugh maps, a graphical technique used for
minimization of Boolean expressions.
The use of Gray codes to address program memory in computers minimizes power consumption. This is
due to fewer address lines changing state with advances in the program counter.
Gray codes are also very useful in genetic algorithms since mutations in the code allow for mostly
incremental changes. However, occasionally a one-bit change can result in a big leap, thus leading to new
properties.
Binary Codes: Excess 3 Code
The excess-3 code is another important BCD code.
It is particularly significant for arithmetic operations as it overcomes the shortcomings encountered while using the
8421 BCD code to add two decimal digits whose sum exceeds 9.
The excess-3 code has no such limitation, and it considerably simplifies arithmetic operations.
The excess-3 code for a given decimal number is determined by adding ‘3’ to each
decimal digit in the given number.
Excess 3 is a self complementing code. If the bits of the Excess-3 digit are
inverted, they yield the 9’s complement of the decimal equivalent.
Excess-3 code is useful for performing decimal arithmetic digitally
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
Binary Codes - Alphanumeric Codes
In order to communicate, you need not only numbers, but also letters and
other symbols.
In the strictest sense, alphanumeric codes are codes that represent numbers
and alphabetic characters (letters)
ASCII is the abbreviation for American Standard Code for Information Interchange.
ASCII is a universally accepted alphanumeric code used in most computers and other
electronic equipment. Most computer keyboards are standardized with the ASCII.
When you enter a letter, a number, or control command, the corresponding ASCII code goes
into the computer.
ASCII has 128 characters and symbols represented by a 7-bit binary code.
Actually, ASCII can be considered an 8-bit code with the MSB always 0. This 8-bit code is
00 through 7F in hexadecimal.
Binary Codes - Alphanumeric Codes
Binary Codes - Alphanumeric Codes
Extended ASCII Characters
In addition to the 128 standard ASCII characters, there are an additional 128 characters that were
adopted by IBM for use in their PCs (personal computers).
All IBM mainframe computer peripherals and operating systems use EBCDIC code, and their operating
systems provide ASCII and Unicode modes to allow translation between different encodings.
It may be mentioned here that EBCDIC offers no technical advantage over the ASCII code and its variant
ISO-8859 or Unicode.
Its importance in the earlier days lay in the fact that it made it relatively easier to enter data into larger
machines with punch cards.
Since, punch cards are not used on mainframes any more, the code is used in contemporary mainframe
machines solely for backwards compatibility.
Seven-segment Display Code
Seven-segment displays are very common and are found almost everywhere, from
pocket calculators, digital clocks and electronic test equipment to petrol
pumps.
There are common anode-type LED displays where the arrangement of different
diodes, designated a, b, c, d, e, f and g
Seven-segment Display Code