# Encoders and Decoders

## Digital Circuits

• #### Question 1

What does it mean, in general terms, to encode something? Conversely, what does it mean to decode something? Perhaps the most common context for these terms to be used is cryptography (code-making and code-breaking), but they also find application in common digital circuits.

• #### Question 2

The simple switch-and-diode circuit shown here is an example of a digital encoder. Explain what this circuit does, as the switch is moved from position to position:

• #### Question 3

Having learned how to build simple encoder circuits using diode networks, you set out to form your own encoder manufacturing company: Encoders, Inc. After agreeing on a policy of truth in advertising, your board of directors drafts this slogan:

 ”Our encoder circuits are more reliable because there′s less to break.”

After months of hard work, you unveil your latest masterpiece, the 16-line to 4-line encoder:

However, your first customer has a complaint with your encoder circuit. He claims it often outputs false codes. After sending it back to your workshop for warranty repair, you determine there is nothing wrong with the encoder circuit itself: it always outputs the correct codes when you energize the appropriate inputs. Perhaps the problem is in how the customer is using it.

You then telephone the customer and ask him how he is using the encoder. He tells you it is used as part of a fault diagnostic circuit for an important piece of machinery. Each input of the encoder is connected to a different sensor on the machine (low oil pressure switch, high temperature switch, out-of-limit travel switches, etc.), and then the encoder outputs drive a four-LED display for maintenance technicians to view. They would have rather used a separate LED for each “trouble” sensor, but the display panel was too small to accommodate fifteen LEDs, so they decided to use four LEDs and an encoder, having their technicians interpret a binary code to determine which of the fifteen sensors is activating.

To the best of your ability, determine why your company’s flagship encoder circuit sometimes produces false codes in this application. Then, recommend a solution for your customer.

• #### Question 4

Identify which diode is failed in this circuit, given the following truth table (showing the actual operation of the encoder circuit, not what it should do):

 Switch position Output code 0 000 1 001 2 010 3 011 4 100 5 001 6 110 7 111

Be sure to specify whether you think the failed diode is open or shorted.

• #### Question 5

Identify which diode is failed in this circuit, given the following truth table (showing the actual operation of the encoder circuit, not what it should do):

 Switch position Output code 0 000 1 111 2 010 3 111 4 100 5 111 6 110 7 111

Be sure to specify whether you think the failed diode is open or shorted.

• #### Question 6

Identify which diode is failed in this circuit, given the following truth table (showing the actual operation of the encoder circuit, not what it should do):

 Switch position Output code 0 000 1 001 2 110 3 111 4 100 5 101 6 110 7 111

Be sure to specify whether you think the failed diode is open or shorted.

• #### Question 7

Explain how the following decimal-to-BCD encoder circuit works:

Also, determine which output (D or A) is the most significant bit of the BCD output.

• #### Question 8

Suppose OR gate U3 were to fail with the output terminal always high. Which output codes would be affected by this fault?

• #### Question 9

Here is the block symbol for the 74HC147 decimal-to-BCD encoder:

Describe what sort of input conditions would be required to make it generate the code for the number 7, and how that numerical quantity would be represented on the output (Y) lines.

• #### Question 10

What is a priority encoder circuit, and how does it differ from a regular encoder? Find a datasheet for a priority encoder, and explain how the encoder circuit works.

• #### Question 11

The circuit shown here is a four-bit analog-to-digital converter (ADC). Specifically, it is a flash converter, so named because of its high speed:

Explain why we must use a priority encoder to encode the comparator outputs into a four-bit binary code, and not a regular encoder. What problem(s) would we have if we were to use a non-priority encoder in this ADC circuit?

• #### Question 12

Predict how the operation of this “flash” analog-to-digital converter (ADC) circuit will be affected as a result of the following faults. Consider each fault independently (i.e. one at a time, no multiple faults):

Resistor R16 fails open:
Resistor R1 fails open:
Comparator U13 output fails low:
Solder bridge (short) across resistor R14:

For each of these conditions, explain why the resulting effects will occur.

• #### Question 13

This “flash” ADC circuit has a problem. The output code jumps from 0000 to 1111 with just the slightest amount of input voltage (Vin). In fact, the only time it outputs 0000 is when the input terminal is slightly negative with reference to ground:

Identify at least two possible component faults that could cause this problem, and explain your reasoning in how you made the identifications.

• #### Question 14

The truth table shown here is for a 4-line to 16-line binary decoder circuit:

For each of the sixteen output lines, there is a Boolean SOP expression describing its function. Just for example, write the Boolean expressions for output lines 5, 8, and 13.

• #### Question 15

The truth table shown here is for a 4-line to 16-line binary decoder circuit:

For each of the sixteen output lines, there is a Boolean SOP expression describing its function. Just for example, write the Boolean expressions for output lines 2, 11, and 14.

• #### Question 16

Suppose a crane has fifteen hydraulic solenoid valves controlling its motion:

Tilt up (fast)
Tilt down (fast)
Tilt up (slow)
Tilt down (slow)
Turn left (fast)
Turn right (fast)
Turn left (slow)
Turn right (slow)
Cable up (fast)
Cable down (fast)
Cable up (slow)
Cable down (slow)
Bucket open (fast)
Bucket open (slow)
Bucket close (slow)

You are part of a team building a remote “pendant” control for this crane with fifteen buttons on it for controlling each of the fifteen solenoid valves. This control pendant connects to the main system by a multiconductor cable, but you really want to limit the number of conductors in this cable to keep it as light-weight as possible:

Draw a simple schematic diagram showing how a digital encoder and decoder circuit pair could be used to relay the same fifteen commands across fewer cable conductors, compared to if we used one conductor per pushbutton switch.

• #### Question 17

The type 74HC154 integrated circuit is a standard TTL decoder, 4-line to 16-line. Its block symbol looks like this:

What do the “wedge” symbols next to the output lines represent? Also, what purpose do the $$\bar{G}\bar{1}$$ and $$\bar{G}\bar{2}$$ inputs serve, and why is there an ampersand character (&) next to them?

• #### Question 18

What is the purpose of a seven-segment decoder circuit? What is a “seven-segment” display, and why do we need a decoder circuit to drive it? Research the part number for a typical seven-segment decoder circuit (either CMOS or TTL).

• #### Question 19

Design a circuit to convert four-bit binary to four-bit Gray code. Hint: it uses Exclusive-OR gates.

• #### Question 20

Design a circuit to convert four-bit Gray code to four-bit binary. Hint: it uses Exclusive-OR gates.

• #### Question 21

 Don’t just sit there! Build something!!

Learning to analyze digital circuits requires much study and practice. Typically, students practice by working through lots of sample problems and checking their answers against those provided by the textbook or the instructor. While this is good, there is a much better way.

You will learn much more by actually building and analyzing real circuits, letting your test equipment provide the “answers” instead of a book or another person. For successful circuit-building exercises, follow these steps:

1. Draw the schematic diagram for the digital circuit to be analyzed.
2. Carefully build this circuit on a breadboard or other convenient medium.
3. Check the accuracy of the circuit’s construction, following each wire to each connection point, and verifying these elements one-by-one on the diagram.
4. Analyze the circuit, determining all output logic states for given input conditions.
5. Carefully measure those logic states, to verify the accuracy of your analysis.
6. If there are any errors, carefully check your circuit’s construction against the diagram, then carefully re-analyze the circuit and re-measure.

Always be sure that the power supply voltage levels are within specification for the logic circuits you plan to use. If TTL, the power supply must be a 5-volt regulated supply, adjusted to a value as close to 5.0 volts DC as possible.

One way you can save time and reduce the possibility of error is to begin with a very simple circuit and incrementally add components to increase its complexity after each analysis, rather than building a whole new circuit for each practice problem. Another time-saving technique is to re-use the same components in a variety of different circuit configurations. This way, you won’t have to measure any component’s value more than once.