0% found this document useful (0 votes)
72 views

Binary Codes

Digital codes can be classified in several ways, including weighted and non-weighted codes, self-complementary codes, sequential codes, and error detection/correction codes. Binary coded decimal (BCD) is commonly used to represent decimal numbers in binary form, with each decimal digit represented by 4 bits. Gray code is a non-weighted, self-complementary code where only one bit changes between successive values. Excess-3 code is a BCD-derived code useful for decimal arithmetic. ASCII and EBCDIC are alphanumeric codes to represent letters, numbers and symbols using 7-8 bit binary encodings. Seven-segment displays represent numbers using arrangements of light segments mapped to a code.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Binary Codes

Digital codes can be classified in several ways, including weighted and non-weighted codes, self-complementary codes, sequential codes, and error detection/correction codes. Binary coded decimal (BCD) is commonly used to represent decimal numbers in binary form, with each decimal digit represented by 4 bits. Gray code is a non-weighted, self-complementary code where only one bit changes between successive values. Excess-3 code is a BCD-derived code useful for decimal arithmetic. ASCII and EBCDIC are alphanumeric codes to represent letters, numbers and symbols using 7-8 bit binary encodings. Seven-segment displays represent numbers using arrangements of light segments mapped to a code.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Digital Codes / Binary Codes

Many specialized codes are used in digital systems

Classification of Binary Codes


 Weighted & Non-weighted Codes
 Self Complimentary Codes
 Sequential Codes
 Alphanumeric Codes
 Error Detection & Error Correction Codes
Digital Codes / Binary Codes - Binary Coded Decimal (BCD)
 The binary coded decimal (BCD) is a type of binary code used to represent a given
decimal number in an equivalent binary form.

 BCD-to-decimal and decimal-to-BCD conversions are very easy and straightforward

 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.

 Examples of such interfaces are keypad inputs and digital readouts


Binary Codes - BCD
 The 8421 code is a type of BCD (binary coded decimal) code.
 Binary coded decimal means that each decimal digit, 0 through 9, is represented by a binary code of four bits.
 It a weighted code
Binary Codes - BCD
Convert each of the following decimal numbers to BCD:

Convert each of the following BCD codes to decimal:


Binary Codes - BCD
BCD-to-Binary Conversion
 BCD number: 0010 1001.0111 0101.
 Corresponding decimal number: 29.75.
 The binary equivalent of 29.75 can be determined to be 11101 for the
integer part and .11 for the fractional part.
 Therefore, (0010 1001.0111 0101)BCD =(11101.11)2.

Binary-to-BCD Conversion

 The decimal equivalent of this binary number can be determined to be 171.625.


 The BCD equivalent can then be written as 0001 0111 0001.0110 0010 0101.
Gray code is a non-weighted code that
Binary Codes- The Gray Code is used as a unit distance code.

 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.

Although there can be more than one Gray code


for a given word length, the term was first
applied to a specific binary code for non-
negative integers and called the binary-
reflected Gray code or simply the Gray code.
Binary Codes- The Gray Code
Binary-to-Gray Code Conversion

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:

(a) Convert the binary number 11000110 to Gray code.


(b) Convert the Gray code 10101111 to binary.
Binary Codes- The Gray Code
n-ary Gray Code
Other types of Gray code. One such code is the n-ary Gray code, also called the non-Boolean Gray code
owing to the use of non-Boolean symbols for encoding

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

Excess-3 code is also known as XS-3 code.


Excess-3 code is a non-weighted code that is derived from the 8421 BCD
code.
Excess-3 code is a non-weighted code
Binary Codes: Excess 3 Code that is derived from the 8421 BCD code

Decimal BCD XS Code


(+0011)

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

The EBCDIC (Extended Binary Coded Decimal Interchange Code)

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.

 A single seven-segment display or a stack of such displays invariably meets our


display requirement.

 There are both LED and LCD types of seven-segment display.

 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

You might also like