# Encoder and Decoder

Encoder and Decoder are combinations of logic circuits in digital electronics. A major difference between these two terminologies is that the encoder gives the binary code as output whereas the decoder receives the binary code. Let us explore the difference between encoder and decoder. An encoder is a mechanism that can convert a data signal into a message that can be read by some kind of control device. Or in other words, combinational circuits that modify binary data into N output lines are known as encoders. The combinational circuit that converts binary data into 2N output lines is called a decoder.

## Encoder |What is an encoder in digital electronics?

An encoder is a digital circuit that performs the reverse operation of a decoder. An encoder has 2n    input lines and n output lines and the output lines produce binary code corresponding to the input value. An encoder is a device, algorithm, that is a software program  that converts the information from one format (code) to another. The main purpose of the encoder is security, speed ,standardization or saving space by shrinking size. They can be accepted one or more inputs and generates a multibit output code. Here this article gives the application of encoder to better understand this topic. An example of an encoder is the octal-to-binary encoder whose truth table is given in following Table  . It has eight(23 ) inputs (one for each of the octal digits) and three outputs that generate the corresponding their binary number. It is assumed that only one input has a value of 1 at a times.

The encoder can be applied with OR gates whose inputs are determined directly from the truth table. Output A2 is equal to 1 when the input octal digit is 1, 3, 5, or 7. Output A1 is 1 for octal digits 2, 3, 6, or 7, and output A0 is 1 for digits 4, 5, 6, or 7. These conditions can be expressed by the following Boolean output functions:

The encoder can be made with 03 OR gate.

 INPUTS OUTPUTS Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 A2 A1 A0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1

A2  =  Y4 + Y5 + Y6 + Y7

A1  =  Y2 + Y3 + Y6 + Y7

A0 =  Y1 + Y3 + Y5 + Y7 ### Combinational logic of encoder :-

The limit of the encoder shown in the table is that only one input can be active at any given time. If two inputs are simultaneously activated the output produces an undefined combination. For example, if D3 and D6 are 1 together, the output of the encoder will be 111 because all three outputs are equal 1 and Output 111 does not represent either binary 3 or binary 6. To resolve this ambiguity, the encoder circuit has to be installed . It has an input priority to ensure that only one input is encoded. If we set a higher priority to an input with a higher subscript number, and if both D3 and D6 are 1 at the same time, the output will be 110 because D6 has a higher priority than D3. Another ambiguity in octal-to-binary encoders is that an output with all 0s is produced when all inputs are 0; But this output is the same when D0 equals 1. The discrepancy can be resolved by providing another output to indicate whether at least one of the inputs is equal to 1.

### Uses of encoder :-

• Encoders are a very common electronic circuit used in all digital systems.
• Encoder is used to translate decimal values into binary so that binary functions like addition, subtraction, multiplication etc. can be performed.
• Other applications may include interrupt detection in microprocessor applications, specifically for priority encoders.
• Its monitoring  automatic health monitoring systems and RF-based home automation system.
• it is metal detector with robotics vehicle.
• War field flying robot with a using night-vision flying camera.
• Speed can be synchronized of multiple motors in industries.
• Encoder can be used for CNC machines and the medical industry most common for breast cancer treatment in the world.

## Decoder | what is decoder ?

A decoder has a combinational circuit that converts binary information from n input lines to a maximum of 2n  output lines. If the n -bit coded information has unused combinations, the decoder may have fewer than 2n outputs. Each combination of inputs will assert a unique output. The name decoder is also used with other code converters, such as the BCD-to-seven segment decoder.  At a particular tie one output line is active. The input to a decoder is parallel binary number and it is used to detect the presence of a specific binary number at the input. The output indicates the presence or absence of specific number at the decoder input. ### Combinational logic of decoder :-

As an example, consider 3 * 8  line decoder circuit is shown in the figure. The three inputs are decoded into eight outputs, each representing one of the minterms of the three input variables. The three inverters provide the complement of the inputs, and each one of the eight AND gates generates one of the minterms. A particular application of this decoder is binary-to-octal conversion. The input variables represent a binary number, and the outputs represent the eight digits of a number in the octal number system. However, 3*8 decoder can be used for decoding any three-bit code to provide eight outputs, one for each element of the code.

 INPUTS OUTPUTS Enable A2 A1 A0 Z7 Z6 Z5 Z4 Z3 Z2 Z1 Z0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0

Z0 = A0’.A1’.A2’                              Z3 = A0.A1.A2’                           Z6 = A0’.A1.A2

Z1 = A0.A1.A2                                 Z4 = A0’.A1’.A2                          Z7 = A0.A1.A2

Z2 = A0’A1.A2’                                Z5 = A0.A1’.A2 ### Uses of decoder :-

• It is used for code conversion.  i.e analog to digital conversion in the analog decoder and also used for data distribution.
• Decoder can be used to minimize the effect of system decoding for high performance memory system and it is used as address deoders in CPU memory location identification…
• Decoders are mainly used in logical circuits, data transfer and They can also be used to create simple other digital logics like half adders and full adders .
• Microprocessor can be selected different I/O devices.
• It is decoding to binary input to activate the LED segments so that the decimal number can be displayed.
• Microprocessor memory system an be selected different banks of memory.
• The decoder can be used as sequencing or a timing signals to turn the device on or off at specific times because when the decoder inputs come from a counter that is being continually pulsed, The decoder output will be activated sequentially.
• It  is used whenever an output or a group of output is to be activated only on the occurrence of a specific combination of input signals.
• It can be the application of switching function often with the fewer integrated circuit.

## Difference between Encoder and Decoder

A comparison between Encoder and decoder is given in table as mentioned below-

 S.NO. ENCODER DECODER 1. The combinational circuits that convert or modify the binary data into N output from 2N input lines are known as encoders. The combinational circuits that convert the binary data of N input signal into 2N output lines are called decoders. 2. In encoder, the output lines are N. In decoder, the output lines are 2N. 3. The implemented signal is considered as actual signal input. Decoder receives coded binary data as its input. 4. Encoder is utilized in videos, E-mail, and more. decoders are mostly utilized in memory chips, microprocessors, and more. 5. When it comes to the communication mode, the encoder is situated at the transmitting end. While the decoder is situated at the receiving side to decode the received signal. 6. The operating procedure of encoder is quite simple here. The operating procedure of decoder is complex.