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 (codemaking and codebreaking), but they also find application in common digital circuits.
To encode something is to convert an unambiguous piece of information into a form of code that is not so clearly understood. To decode is to perform the reverse operation: translating a code back into an unambiguous form.
This question gets students thinking about encoding and decoding in general terms  terms which they are probably already familiar with. This is a good first step in instruction, to identify a wellknown context for a new subject, so students have an easier time relating to it.
The simple switchanddiode circuit shown here is an example of a digital encoder. Explain what this circuit does, as the switch is moved from position to position:

This encoder generates a threebit binary code corresponding to the switch position (one out of eight positions).
Followup question: trace the path of electron flow through the circuit with the switch in position #3.
Challenge question: are there other codes (besides binary) that could possibly be generated with a circuit of this general design?
Ask your students to explain how the term “encoder” applies to this simple circuit. What, exactly, is being encoded, and what form of code is the data being converted to?
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:

After months of hard work, you unveil your latest masterpiece, the 16line to 4line 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, outoflimit travel switches, etc.), and then the encoder outputs drive a fourLED 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.
I’ll answer this question with another question: what if two failures occur on this machine at the same time?
Despite the overly simplistic nature of the company’s product, this scenario accurately reflects the realistic nature of product development and customer application. Often, a company designs, builds, and markets a product, and the customers experience trouble because their applications are improper for that product, or the application reveals a deficiency in the product that wasn’t detected during development.
As elegant as the “diode network” design of encoder is, it certainly has its limitations. Ask your students whether the output of this encoder circuit will always be incorrect if two inputs are simultaneously activated, or if only particular combinations of active inputs cause problems. Which condition would be easier to troubleshoot?
Discuss alternative solutions with your students, being sure to first define what the problem is so that all understand.
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):


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

This question helps students understand the purpose of the diodes in this type of encoder circuit: to steer the power to the appropriate output lines, and only to those lines.
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):


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

This question helps students understand the purpose of the diodes in this type of encoder circuit: to steer the power to the appropriate output lines, and only to those lines.
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):


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

This question helps students understand the purpose of the diodes in this type of encoder circuit: to steer the power to the appropriate output lines, and only to those lines.
Explain how the following decimaltoBCD encoder circuit works:

Also, determine which output (D or A) is the most significant bit of the BCD output.
I’ll let you figure out the details of how this circuit functions, but I will tell you that D is the MSB.
Followup question: what would have to be modified in order to turn this into a hexadecimaltobinary (16 line to 4 line) encoder? Would any additional OR gates have to be added to the circuit?
Nonpriority encoder circuits such as this one are fairly simple to figure out, and so I do not provide an explanation for students in the “Answer” section.
Suppose OR gate U_{3} were to fail with the output terminal always high. Which output codes would be affected by this fault?

The following output codes would be adversely affected by this fault: 1, 4, 5, 8, and 9.
Ask your students to explain how they determined the affected codes. Although the question itself is relatively simple, there is room for creativity in the answers!
Here is the block symbol for the 74HC147 decimaltoBCD 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.
To encode the number 7, you would have to make the I_{7} line low (connect it to ground). This would make the outputs assume the following states:
This is a good review of activelow inputs, how they are drawn on schematics, and what they mean in practical digital circuits. A potentially confusing aspect of this question is the presence of activelow inputs and outputs, but it is well worth your time to review with students, because like it or not there are many ICs with activelow I/O lines.
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.
A priority encoder encodes only the highestorder active input, even if multiple inputs are activated.
Be sure to ask your students where and how they found their respective priority encoder datasheets.
The circuit shown here is a fourbit analogtodigital 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 fourbit binary code, and not a regular encoder. What problem(s) would we have if we were to use a nonpriority encoder in this ADC circuit?
I won’t directly answer this question, but instead pose a “thought experiment.” Suppose the analog input voltage (V_{in}) were slowly increased from 0 volts to the reference voltage (V_{ref}). What do the outputs of the comparators do, one at a time, as the analog input voltage increases? What input conditions does the encoder see? How would a primitive “diode network” type of encoder (which we know does not encode based on priority) interpret the comparator outputs?
Here, I show students a very practical application of a priority encoder, in which the necessity of priority encoding should be apparent after some analysis of the circuit.
Predict how the operation of this “flash” analogtodigital 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):

For each of these conditions, explain why the resulting effects will occur.
The purpose of this question is to approach the domain of circuit troubleshooting from a perspective of knowing what the fault is, rather than only knowing what the symptoms are. Although this is not necessarily a realistic perspective, it helps students build the foundational knowledge necessary to diagnose a faulted circuit from empirical data. Questions such as this should be followed (eventually) by other questions asking students to identify likely faults based on measurements.
This “flash” ADC circuit has a problem. The output code jumps from 0000 to 1111 with just the slightest amount of input voltage (V_{in}). 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.
One possible fault is that resistor R_{16} has failed open, but this is not the only possibility.
Have your students explain their reasoning in class to you, so that you may observe their diagnostic thought processes.
The truth table shown here is for a 4line to 16line 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.
Output line 5: A[B]C[D]
Output line 8: [A] [B] [C] D
Output line 13: A[B]CD
Followup question: based on what you see here, what kind of logic gate circuitry is a decoder such as this comprised of? You don’t have to actually draw a schematic diagram, but just generally describe the circuitry necessary to implement sixteen different SOP expressions.
Nothing really complex or tricky here. Just a straightforward application of Boolean SOP expressions.
The truth table shown here is for a 4line to 16line 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.
Output line 2: [A]B[C] [D]
Output line 11: A B[C] D
Output line 14: [A] B C D
Followup question: based on what you see here, what kind of logic gate circuitry is a decoder such as this comprised of? You don’t have to actually draw a schematic diagram, but just generally describe the circuitry necessary to implement sixteen different SOP expressions.
Nothing really complex or tricky here. Just a straightforward application of Boolean SOP expressions.
Suppose a crane has fifteen hydraulic solenoid valves controlling its motion:
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 lightweight 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.
(Solenoid drive circuitry not shown):

Followup question: can you think of any disadvantages to this crane control strategy, compared to using a thicker cable where each pushbutton has its own dedicated conductor?
Challenge question: my choice of activelow inputs and outputs was not arbitrary. Explain why.
If time permits, you might want to ask students to sketch a “typical” solenoid drive subcircuit, interposing the decoder outputs to DC (or AC!) solenoid valve coils. Several options are possible here, each with their own merits and drawbacks.
The challenge question is a good one to discuss, even if most students were not able to answer it on their own. It is not good enough to merely have a system that works  we must also have a system that is safe.
The type 74HC154 integrated circuit is a standard TTL decoder, 4line to 16line. Its block symbol looks like this:

What do the “wedge” symbols next to the output lines represent? Also, what purpose do the [G1] and [G2] inputs serve, and why is there an ampersand character (&) next to them?
The “wedge” symbols represent complementation in the IEEE/ANSI digital schematic convention, similar to “bubbles” placed near outputs or inputs of traditional logic gate symbols. Similarly, the ampersand character represents the AND function.
Perhaps the best way to determine what the [G1] and [G2] inputs do is to examine the truth table given in the datasheet for this integrated circuit.
Much may be learned from a good datasheet. This question, and others like it, prompts students to research manufacturer datasheets as a learning experience.
Note the truth table (likely) given in the datasheets your students collect. How are “irrelevant” states denoted in the truth tables? Ask your students what this means (especially with reference to the question regarding the strobe inputs).
What is the purpose of a sevensegment decoder circuit? What is a “sevensegment” display, and why do we need a decoder circuit to drive it? Research the part number for a typical sevensegment decoder circuit (either CMOS or TTL).
Sevensegment displays are a very common numerical interface for digital electronic equipment:

A special decoder circuit is needed to translate 4bit BCD codes into the particular combinations of segment activations that represent decimal digits.
Followup question: what does the internal schematic of a typical sevensegment display look like? Is there just one type, or are there different types of sevensegment displays?
Be sure to ask your students to reveal the decoder datasheets they found. Once again, manufacturer datasheets contain a wealth of information, and your students will learn much by researching them.
Design a circuit to convert fourbit binary to fourbit Gray code. Hint: it uses ExclusiveOR gates.

This circuit is very easy to design, if you remember the conversion process going from binary to Gray. There are many good references available for students to learn (or relearn) this process from, so don’t simply tell them how to do it! Let them research it on their own.
Design a circuit to convert fourbit Gray code to fourbit binary. Hint: it uses ExclusiveOR gates.

Challenge question: this circuit is not as suited to highspeed conversion as a binarytoGray converter, even though it uses the same quantity and same type of logic gate. Explain why problems may arise if this circuit is forced to convert Gray code inputs that are changing rapidly (for instance, translating the output of a Graycode rotary encoder into binary, when the mechanical encoder is rotating at a very high speed).
This circuit is very easy to design, if you remember the conversion process going from Gray to binary. There are many good references available for students to learn (or relearn) this process from, so don’t simply tell them how to do it! Let them research it on their own.
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 circuitbuilding exercises, follow these steps:
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 5volt 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 timesaving technique is to reuse 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.
Let the electrons themselves give you the answers to your own “practice problems”!
It has been my experience that students require much practice with circuit analysis to become proficient. To this end, instructors usually provide their students with lots of practice problems to work through, and provide answers for students to check their work against. While this approach makes students proficient in circuit theory, it fails to fully educate them.
Students don’t just need mathematical practice. They also need real, handson practice building circuits and using test equipment. So, I suggest the following alternative approach: students should build their own “practice problems” with real components, and try to predict the various logic states. This way, the digital theory “comes alive,” and students gain practical proficiency they wouldn’t gain merely by solving Boolean equations or simplifying Karnaugh maps.
Another reason for following this method of practice is to teach students scientific method: the process of testing a hypothesis (in this case, logic state predictions) by performing a real experiment. Students will also develop real troubleshooting skills as they occasionally make circuit construction errors.
Spend a few moments of time with your class to review some of the “rules” for building circuits before they begin. Discuss these issues with your students in the same Socratic manner you would normally discuss the worksheet questions, rather than simply telling them what they should and should not do. I never cease to be amazed at how poorly students grasp instructions when presented in a typical lecture (instructor monologue) format!
I highly recommend CMOS logic circuitry for athome experiments, where students may not have access to a 5volt regulated power supply. Modern CMOS circuitry is far more rugged with regard to static discharge than the first CMOS circuits, so fears of students harming these devices by not having a “proper” laboratory set up at home are largely unfounded.
A note to those instructors who may complain about the “wasted” time required to have students build real circuits instead of just mathematically analyzing theoretical circuits:
What is the purpose of students taking your course?
If your students will be working with real circuits, then they should learn on real circuits whenever possible. If your goal is to educate theoretical physicists, then stick with abstract analysis, by all means! But most of us plan for our students to do something in the real world with the education we give them. The “wasted” time spent building real circuits will pay huge dividends when it comes time for them to apply their knowledge to practical problems.
Furthermore, having students build their own practice problems teaches them how to perform primary research, thus empowering them to continue their electrical/electronics education autonomously.
In most sciences, realistic experiments are much more difficult and expensive to set up than electrical circuits. Nuclear physics, biology, geology, and chemistry professors would just love to be able to have their students apply advanced mathematics to real experiments posing no safety hazard and costing less than a textbook. They can’t, but you can. Exploit the convenience inherent to your science, and get those students of yours practicing their math on lots of real circuits!
Published under the terms and conditions of the Creative Commons Attribution License
by Robert Keim
by Gary Elinoff
by Gary Elinoff
by Steve Arar