We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19
BINARY CODES
Classification of Binary Codes
1. Numeric and Alphanumeric Codes • Binary codes can be classified as numeric codes and alphanumeric codes. • Numeric codes are codes which represent numeric information, i.e. only numbers as a series of 0s and 1s. 8421, Excess-3, Gray code are numeric codes. • Numeric codes used to represent the decimal digits are called Binary Coded Decimal (BCD) codes. 8421, 2421, 5211 are BCD codes. • Alphanumeric codes are codes which represent alphanumeric information, i.e. letters of the alphabet and decimal numbers as a sequence of 0s and 1s. EBCDIC code and ASCII code are alphanumeric codes. 2. Weighted and Non-weighted Codes • The BCD codes may be weighted codes or non-weighted codes. • The weighted codes are those which obey the position- weighting principal. Each position of the number represents a specific weight. • For each group of four bits, the sum of the weights of those positions where the binary digits is 1 is equal to the decimal digit which the group represents. 8421, 2421, 84-2-1 are weighted codes. • Non-weighted codes are codes which are not assigned with any weight to each digit position, i.e. each digit position within the number is not assigned fixed value. Excess-3 code and Gray code are non-weighted codes. 3. Positively-weighted and Negatively- weighted Codes • The weighted codes may be either positively-weighted codes or negatively-weighted codes. • Positively-weighted codes are those in which all the weights assigned to the binary digits are positive. • In every positively-weighted code, the first weight must be 1, the second weight must be either 1 or 2, and sum of all the weights must be equal to or greater than 9. Example: 8421, 2421, 5211, 3321, 4321 codes. • Negatively-weighted codes are those in which some of the weights assigned to the binary digits are negative. Example: 642-3, 631-1, 84-2-1, 74-2-1 codes. 4. Error Detecting and Error Correcting Codes • Binary codes may also be error detecting codes or error correcting codes. • Codes which allow only error detection are called error detecting codes. Shift counter code, 2-out-of-5, 63210 codes are error detecting codes. • Codes which allow error detection as well as error correction are called error correcting codes. The Hamming code is a error correcting code. 5. Sequential Codes • Sequential code is one, in which each succeeding code word is one binary number greater than its preceding code word. The 8421 and Excess-3 codes are sequential. The codes 5211, 2421 and 642-3 are not sequential. 6. Self-complementing Codes • A code is said to be self-complementing, if the code word of the 9’s complement of N, i.e. of 9-N can be obtained from the code word of N by interchanging all the 0s and 1s. • Therefore, in a self-complementing code, the code for 9 is the complement of the code for 0, the code for 8 is the complement of the code for 1, and so on. The 2421, 5211, 642-3, 84-2-1 and Excess-3 codes are self- complementing codes. The 8421 and 5421 codes are not self-complementing codes. 7. Cyclic Codes • Cyclic codes are those in which each successive code word differs from the preceding one in only one bit position. • They are also called unit distance codes. The Gray code is a cyclic code. 8. Reflective Codes • A reflective code is a binary code in which the n least significant bits for code words 2n through 2n+1 - 1 are the mirror images of those for 0 through 2n - 1. The Gray code is a reflective code. The 8421 BCD Code • The 8421 BCD code is so widely used that is a common practice to refer to it simply as BCD code. • In this code, each decimal digit, 0 through 9, is coded by a 4-bit binary number. • It is also called the natural binary code because of the 8, 4, 2 and 1 weights attached to it. • It is a weighted code and is also sequential. Therefore, it is useful for mathematical operations. • The main advantage of this code is its ease of conversion to and from decimal. • It is less efficient than the pure binary, in the sense that it requires more bits. For example, the decimal number 14 can be represented as 1110 in pure binary but as 0001 0100 in 8421 code. • Another disadvantage of the BCD code is that, arithmetic operations are more complex than they in pure binary. The Gray Code • The Gray code is a non-weighted code, and is not suitable for arithmetic operations. It is not a BCD code. • It is a cyclic code because successive code words in this code differ in one bit position only, i.e. it is a unit distance code. • It is also reflective code, i.e. it is both reflective and unit distance. The n least significant bits for 2n through 2n+1 - 1 are the mirror images of the those for 0 through 2n - 1. • Gray codes are used in instrumentation and data acquisition systems where linear or angular displacement is measured. • They are also used in shaft encoders, I/O devices, A/D converters and other peripheral equipment. The ASCII Code • The American Standard Code for Information Interchange (ASCII) is a widely used alphanumeric code. • This is basically a 7-bit code. Since the number of different bit patterns that can be created with 7 bits is 27 = 128, the ASCII can be used to encode both lowercase and uppercase characters of the alphabet (52 symbols) and some special symbols as well, in addition to the 10 decimal digits. • It is used extensively for printers and terminals that interface with small computer systems.