Digital Electronics - Binary Codes



Binary codes are one of the important concepts in digital electronics. A binary code is a type of digital code consisting of two digits, 0 and 1. Binary codes act as the primary language in any digital computing system. Binary codes can represent different types of information such as numbers, letters, images, videos, etc.

In this chapter, we will explain the basics of binary codes, their working, advantages, limitations, and applications.

What are Binary Codes?

Binary codes are used to represent text, numbers, images, or other types of information in the form of 0 and 1, i.e., binary digits. Binary codes form the primary language of a digital computing system like a computer.

All digital system can understand and manipulate information expressed in binary language only. In the case of binary codes, each digit is called a binary digit or bit.

Binary codes represents information using 0 and 1. In a digital system, the binary codes are organized into segments like bits or bytes. A bit is either a binary 0 or 1. When 8 bits are grouped together, then it is called a byte. Each byte represents a piece of information in a digital system.

Types of Binary Codes

Binary codes can be classified into the following major types −

  • Weighted Binary Codes
  • Non-weighted Binary Codes
  • Alphanumeric Code
  • Binary Coded Decimal (BCD)
  • Error Detecting Code
  • Error Correction Code

Let us discuss each type of code in detail.

Weighted Binary Codes

Weighted binary codes are a type of binary code in which each bit position has a specific weight associated with its positional value.

In weighted binary codes, the positional weights are defined in terms powers of 2. The value of each bit depends on its position in the binary code. Thus, in a given weighted binary code, the rightmost bit has the least weight and the leftmost bit has the highest weight.

In general, the weight of nth bit in a weighted binary code is given by,

nth bit = 2n

For example, let a 4-bit weighted binary code 1011. The value of the code is,

1 × 23 + 0 × 22 + 1 × 21 + 1 × 20

1 × 8 + 0 × 4 + 1 × 2 + 1 × 1

8 + 0 + 2 + 1 = 11

It is clear that the rightmost bit has a positional weight of 20 = 1, whereas the leftmost bit has a positional weight of 23 = 8.

Examples of weighted binary codes are 8421 BCD code, 5211 code, 2421 code, etc.

Non-Weighted Binary Codes

In digital electronics, the type of digital or binary codes in which each bit position does not have a specific weight associated with it is known as a non-weighted binary code.

In non-weighted binary codes, the value of the bit does not depend on the position within the number. Each bit position has an equal positional value.

Examples of non-weighted binary codes include Excess-3 code and Gray code.

Excess-3 Code

Excess-3 code is also called as XS-3 code. It is a type of non-weighted code used to express decimal numbers. Excess-3 code words are derived from the 8421 BCD code words adding (0011)2 or (3)10 to each code word in 8421.

Excess-3 codes are obtained as follows −

Non-Weighted Binary Codes

Take a look at the following example

Digital Electronics Binary Codes 2

Gray Code

Gray codes are a type of non-weighted code. They are not arithmetic codes, which means there are no specific weights assigned to the bit position.

Gray codes have a very special feature that, only one bit will change each time the decimal number is incremented (see the figure below). As only one bit changes at a time, gray codes are also known unit distance code.

Gray codes are cyclic codes and they cannot be used in arithmetic operation.

Gray Code Non-Weighted

Gray codes are popularly used in Shaft Position encoders. A shaft position encoder produces a code word that represents the angular position of the shaft.

Alphanumeric Codes

A binary digit or bit can represent only two states '0' or '1'. But this is not enough for communication between two computers because there we need many more symbols for communication. These symbols are required to represent 26 alphabets with capital and small letters, numbers from 0 to 9, punctuation marks and other symbols.

Alphanumeric codes are the codes that represent numbers and alphabetic characters. Mostly such codes also represent other characters such as symbol and various instructions necessary for conveying information.

Alphanumeric codes are binary codes that use character encoding schemes that represent both numbers and alphabetic characters. Alphanumeric codes are mainly used in applications involving character representation and information exchange.

Some common examples of alphanumeric codes are ASCII (American Standard Code for Information Interchange), Extended ASCII, EBCDIC (Extended Binary Coded Decimal Interchange Code), Unicode, etc.

An alphanumeric code should at least represent 10 digits and 26 letters of the alphabet, i.e., total 36 items. The following three alphanumeric codes are very commonly used for data representation −

  • American Standard Code for Information Interchange (ASCII)
  • Extended Binary Coded Decimal Interchange Code (EBCDIC)
  • Five bit Baudot Code

ASCII code is a 7-bit code, whereas EBCDIC is an 8-bit code. ASCII code is more commonly used, while EBCDIC is used primarily in large IBM computers.

Binary Coded Decimal (BCD)

Binary coded decimal or BCD is a binary code used to represent decimal numbers in their digital format. In this code, each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In BCD, each decimal digit is represented by a unique combination of binary bits.

BCD is mainly used in digital systems where decimal arithmetic operations are performed like in computers, calculators, display devices, digital sensors, etc.

In BCD, with 4 bits, we can represent sixteen numbers (0000 to 1111), but in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations, i.e., 1010 to 1111 are invalid in BCD.

>Binary Coded Decimal

Advantages of BCD Codes

  • BCD codes are very similar to the decimal system.
  • We need to remember the binary equivalent of the decimal numbers 0 to 9 only.

Disadvantages of BCD Codes

  • The addition and subtraction of BCD codes follow different rules.
  • BCD arithmetic is a little more complicated.
  • BCD needs more number of bits than binary to represent the decimal number. So, BCD is less efficient than binary.

Error Detecting Codes

Error detecting codes are special types of binary codes used to identify errors in digital communication and data storage. Error detecting codes add redundancy to the data that allows receiver to identify if there is any error occurred. Common examples of error detecting codes include parity bit, checksum, hamming code, etc.

Error detecting codes are important to ensure integrity in data transmission and storage. They help in improving the reliability of the system.

What are Errors?

An error is a condition when the output information does not match with the input information. During transmission, digital signals suffer from noise that can introduce errors in the binary bits travelling from one system to other. That means a 0 bit may change to 1 or a 1 bit may change to 0.

Error Detecting Codes

Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted. To avoid this, we use error-detecting codes which are additional data added to a given digital message to help us detect if an error occurred during transmission of the message. A simple example of error-detecting code is parity check.

Error Correcting Codes

Error correcting codes are binary codes designed to correct the errors occurred in a digital system during data transmission or storage. Error correcting codes add some additional information to the data to be transmitted or stored.

Error-correcting codes deploy the same strategy as error-detecting codes but additionally, such codes also detect the exact location of the corrupt bit. This allows the receiver to re-obtain the original data even if some of the bits are corrupted.

In error-correcting codes, parity check has a simple way to detect errors along with a sophisticated mechanism to determine the corrupt bit location. Once the corrupt bit is located, its value is reverted (from 0 to 1 or 1 to 0) to get the original message.

Just like error detecting codes, error correcting codes are important to maintain data integrity in digital communication and data storage applications.

Different types of error correcting codes are used in different digital systems depending on the type of communication channel, error pattern, degree of error correction, etc. Some common examples of error correcting codes are Hamming code, Reed-Solomon code, Low-Density-Parity-Check code, BCH code, etc.

How to Detect and Correct Errors?

To detect and correct the errors, additional bits are added to the data bits at the time of transmission.

  • The additional bits are called parity bits. They allow detection or correction of the errors.
  • The data bits along with the parity bits form a code word.

Parity Checking of Error Detection

It is the simplest technique for detecting and correcting errors. The MSB of an 8-bits word is used as the parity bit and the remaining 7 bits are used as data or message bits. The parity of 8-bits transmitted word can be either even parity or odd parity.

Parity Checking of Error Detection

Even Parity − Even parity means the number of 1's in the given word including the parity bit should be even (2,4,6,....).

Odd Parity − Odd parity means the number of 1's in the given word including the parity bit should be odd (1,3,5,....).

Use of Parity Bit

The parity bit can be set to "0" or "1" depending on the type of the parity required.

For even parity, this bit is set to 1 or 0 such that the number of "1 bits" in the entire word is even. See Fig. (a).

For odd parity, this bit is set to 1 or 0 such that the number of "1 bits" in the entire word is odd. See Fig. (b).

Use of Parity Bit

How Does Error Detection Take Place?

Parity checking at the receiver can detect the presence of an error if the parity of the receiver signal is different from the expected parity. That means, if it is known that the parity of the transmitted signal is always going to be "even" and if the received signal has an odd parity, then the receiver can conclude that the received signal is not correct.

If an error is detected, then the receiver will ignore the received byte and request for retransmission of the same byte to the transmitter.

Error Detection Take Place

Advantages of Binary Codes

Binary codes have several advantages in the field of digital electronics. Here are the key benefits of using binary codes −

  • Simplicity − Binary codes use only two digits, i.e., 0 and 1 to represent information. It simplifies the electronic circuit design and implementation.
  • Ease in Implementation − Binary codes use only two states namely, on and off. So, their implementation is straightforward.
  • Ease of Storage − Binary codes are easy to store in digital memory devices like hard disk, CD, DVD, pen drive, etc. They require compact storage at higher efficiency.
  • Easy and Fast Processing − Binary codes can be efficiently processed using digital systems having an arithmetic and logic unit. They allow fast and error-free computing.
  • Easy Communication − Binary codes provide an efficient method of information transmission at a very high speed. Various error detecting and correcting techniques can be applied to binary codes that make the digital communication more efficient.
  • Easy Scalability − Binary codes provide easy scalability of a digital system. We can increase the range of a digital system just by adding more bits in the code.
  • Compatibility − Binary codes are compatible with a wide range of digital devices and systems.
  • Reliability − Binary codes are highly immune to noise and interference that provide improved reliability in the digital system.

Disadvantages of Binary Codes

Binary codes have several advantages as given above. However, they also have some disadvantages and limitations.

Some key disadvantages of binary codes are listed below −

  • Binary codes are not human friendly. For human beings, reading and interpreting binary codes can be a complex task.
  • In some situations, binary codes have to be converted into other number systems that adds extra computational overhead to the system.
  • Binary codes require higher transmission bandwidth in communication channel.
  • In binary codes, it is quite difficult to identify the errors. It becomes more challenging in case of long binary sequences.

Applications of Binary Codes

Binary codes are widely used in various fields of digital electronics due to their high efficiency in information representation.

Listed below are some of the key applications of binary codes −

  • Digital Computers − Binary codes are primarily used in digital computer to represent information and instructions.
  • Digital Communication − Binary codes are also used for transmission of data and information using digital channels.
  • Digital Displays − Binary codes are also used to display numbers and alphabets in digital systems.
  • Barcode Systems − Binary codes are also used in barcode systems for product identification and inventory management. In this system, bars of different width and spaces between them represent binary digits that can be interpreted by a scanner.
  • Data Storage − Binary codes are used to store information in digital devices like computer memory.
  • Digital Control Systems − Binary codes are used to program a digital control system. In a digital control system, binary codes are used to represent different types of control signals and instructions used for automation.
  • Computer Graphics − Binary codes are also used in computer graphics to represent colors, shapes, pixel values, and other information.

Conclusion

In conclusion, binary codes are one of the crucial components of a digital system. They are used to represent information and instructions in digital format. There are several different types of binary codes used in digital electronics.

Different binary codes are used for different purposes depending on the nature of application. For example, ASCII code is used for alphanumeric data representation. In this chapter, we explained the basic concepts of binary codes. In the upcoming chapters, we will explore the different types of binary codes and their applications in digital electronics.

Advertisements