Learning Objectives
By the end of this lab, you will be able to:
- Construct a 2-to-4 line decoder from 74HC04/08 gates, verify its one-hot behavior (exactly one output active for each binary input code), and relate it to the commercial 74HC138/139 decoders.
- Operate a BCD-to-7-segment decoder/driver (CD4511, the 74HC4511's twin) driving a real 7-segment display, and trace how a 4-bit code becomes a human-readable digit.
- Construct a 4-to-2 encoder from 74HC32 OR gates, demonstrate the inverse relationship between encoding and decoding, and explain why commercial encoders (74HC147/148) add priority logic.
- Build a 2-to-1 multiplexer implementing Y = SΜΒ·A + SΒ·B, and demonstrate that a demultiplexer is simply a decoder whose enable input carries the data β converting your Part 1 circuit into a 1-to-4 demux with one wire.
- Construct a 4-bit R-2R ladder DAC, measure its 16 output levels, calculate its resolution (1 LSB = Vref/16 β 0.3125 V), and generate a staircase waveform by driving it from a 74HC193 binary counter.
- Construct a 2-bit flash ADC from a resistor reference ladder and three LM741 comparators, map its quantization thresholds with a potentiometer sweep, and encode its thermometer-code output to binary with your Part 3 encoder.
- Evaluate the resolution/speed/complexity trade-offs of flash conversion (2βΏβ1 comparators) and quantization error (Β±Β½ LSB), and identify the analog-digital boundary as a critical point in real systems β including their security.
Key Terms & Concepts
Click any card to reveal its definition. Review these before you build.
π₯ Tinkercad Setup Notes: Building What the Library Doesn't Stock
Seventh lab, and by now the pattern is the point: Tinkercad's library carries some of these functions as chips and omits others β and the omissions become the best builds. Here's the inventory honestly mapped:
- What Tinkercad HAS: the CD4511 BCD-to-7-segment decoder/driver (functional twin of the 74HC4511; the classic 74xx part is the 7447 β pinout documented in tab β‘), the 7-segment display (common cathode), the 74HC193 up/down counter you'll meet again in the counters lab, and all your gate chips and LM741s from previous labs.
- What it LACKS: no 74HC138/139 decoder, no 74HC147/148 encoder, no 74HC151/157 MUX, no DAC0808, no ADC0804. Every one of those functions gets constructed in this lab from 74HC04/08/32 gates, plain resistors, and 741 comparators β and the commercial 74xx parts are documented alongside each build so you can translate to real hardware immediately.
- 7-segment display wiring: Tinkercad's common-cathode display needs its common pin(s) to GND and one 220 Ξ© resistor per segment (seven total) β not one shared resistor, which makes brightness vary with the digit. Hover each display pin: Tinkercad labels them aβg.
- R-2R ladder values: use 1 kΞ© and 2 kΞ© exactly. The ladder's magic depends on the 2:1 ratio, not the absolute values β but mixing tolerances breaks the binary weighting. Measure the output with the multimeter (V mode); it has effectively infinite input impedance in Tinkercad, so no buffering needed.
- Comparators for the flash ADC: three LM741s on a single +5 V/GND supply (pin 7 β +5 V, pin 4 β GND β no negative rail this time). Outputs won't reach the full rails (expect β1.5 V inside), which is why the ADC's indicators are LEDs driven directly rather than logic inputs. The optional binary-encoding step notes the level caveat.
- The pot is your analog signal: a 10 kΞ© potentiometer across +5 V/GND, wiper = Vin, exactly as in the op-amp lab. Sweep it slowly and watch codes change in steps β that stepping IS quantization.
π§ Virtual Parts List
| Qty | Component (Tinkercad name) | Setting / Part | Used In |
|---|---|---|---|
| 1 | Breadboard (small) | β | All parts |
| 1 | Power Supply | 5.00 V | All parts |
| 4 | Slideswitch | SPDT harness | Code inputs A/B Β· data Β· DAC bits |
| 1 ea | 74HC04 Β· 74HC08 Β· 74HC32 | NOT Β· AND Β· OR | Decoder Β· encoder Β· MUX (Parts 1, 3, 4) |
| 1 | CD4511 | BCD β 7-segment (β74HC4511) | Part 2 |
| 1 | 7-Segment Display + 7 Γ 220 Ξ© | common cathode | Part 2 |
| 1 | 74HC193 | 4-bit up/down counter | Part 5 staircase drive |
| 8 | Resistor | 4 Γ 1 kΞ© Β· 4 Γ 2 kΞ© | R-2R ladder (Part 5) β plus 1 spare 2 kΞ© for the terminator |
| 4 | Resistor 1 kΞ© | reference ladder | Flash ADC thresholds (Part 6) |
| 3 | Op Amp LM741 | single 5 V supply | Flash ADC comparators (Part 6) |
| 1 | Potentiometer 10 kΞ© | wiper = V_in | Part 6 analog input |
| 1 | Function Generator | square Β· 1 Hz Β· 0β5 V | Part 5 counter clock |
| 4β6 | LED + 220 Ξ© | assorted colors | Decoder/encoder/MUX/ADC indicators |
| 1 ea | Multimeter Β· Oscilloscope | V mode Β· 500 ms/div | DAC levels Β· staircase waveform |
| ~24 | Wires | red / black / green | All parts |
π The Circuits You Will Build
Five figures for six builds β the demux shares Figure 1's circuit, because that identity is the lesson. Commercial 74xx equivalents are noted on every figure for translation to real hardware.
Commercial 74xx / Converter Reference
| Function | This lab's build | Commercial part | Key pins (commercial) |
|---|---|---|---|
| 2-to-4 / 3-to-8 decoder (+demux) | '04 + '08 gates | 74HC139 / 74HC138 | '138: A,B,C in 1-3 Β· Y0-Y7 out 15-7 Β· enables 4,5,6 Β· pwr 8/16 |
| BCD β 7-segment | CD4511 (in Tinkercad) | 74HC4511 / 7447 | 4511: A=7 B=1 C=2 D=6 Β· a-g=13,12,11,10,9,15,14 Β· pwr 8/16 |
| Encoder (priority) | '32 gates | 74HC147 / 74HC148 | '148: in 0-7 Β· A0-A2 out 9,7,6 Β· EI 5 Β· pwr 8/16 |
| 2-to-1 / 8-to-1 MUX | '04+'08+'32 gates | 74HC157 / 74HC151 | '151: D0-D7 Β· select 11,10,9 Β· Y 5 Β· pwr 8/16 |
| DAC | R-2R ladder + '193 drive | DAC0808 (8-bit) | '193: clk-up 5 Β· QA-QD 3,2,6,7 Β· clear 14 Β· pwr 8/16 |
| ADC | 3 Γ LM741 flash | ADC0804 (8-bit SAR) | 741 (each): +in 3 Β· βin 2 Β· out 6 Β· V+ 7 Β· Vβ 4 |
π Step-by-Step Procedure
Session 1 = Parts 1β2 (decoders) Β· Session 2 = Parts 3β4 (encoder, MUX/DEMUX) Β· Session 3 = Parts 5β6 (DAC/ADC).
Part 1 β 2-to-4 Decoder from Gates (β25 min)
- Workspace. New circuit "LastName β Interface Lab." Breadboard, 5.00 V supply to rails. Two slide switches (SPDT harness) as inputs A1 and A0; four LED + 220 Ξ© indicators as Y0βY3.
- Seat the '04 and '08. Power ritual on both (14 β +5 V, 7 β GND). Wire A1 β 04 pin 1 and A0 β 04 pin 3; their outputs (pins 2, 4) are AΜ 1 and AΜ 0. Run A1, AΜ 1, A0, AΜ 0 to four labeled distribution columns.
- Wire the four recognizers per Figure 1 on the '08: gate 1 (pins 1,2β3) gets AΜ 1, AΜ 0 β Y0; gate 2 (4,5β6) gets AΜ 1, A0 β Y1; gate 3 (9,10β8) gets A1, AΜ 0 β Y2; gate 4 (12,13β11) gets A1, A0 β Y3.
- One-hot verification. Simulate. Step the switches through 00, 01, 10, 11 and record which LED lights in Data Table 1. Acceptance test: exactly one LED per code, every code. Two LEDs ever lit at once means a distribution wire is crossed.
- Think ahead. One sentence in the report: your computer's RAM has ~34 address bits. How many outputs would a full 34-to-2Β³β΄ decoder have? (This is why memory decoders are built in trees.)
Part 2 β The Applied Decoder: BCD β 7-Segment (β25 min)
- Seat the CD4511 (16-pin: VDD = 16 β +5 V, GND = 8). Immediately tie the control pins: LTΜ (3) β +5 V, BLΜ (4) β +5 V, LE (5) β GND. Skipping these is the #1 failure in this part.
- Inputs. Four slide switches β the BCD pins in their scattered order: bit 0 β pin 7 (A), bit 1 β pin 1 (B), bit 2 β pin 2 (C), bit 3 β pin 6 (D). Label the switches on the workspace.
- Display. Place the 7-segment (common cathode), its common pin β GND. Wire segment outputs through seven individual 220 Ξ© resistors: pin 13βa, 12βb, 11βc, 10βd, 9βe, 15βf, 14βg (hover the display's pins to match aβg).
- Count 0 through 9. Enter each BCD code 0000β1001 and record the displayed digit in Data Table 2. Then try 1010β1111 (10β15): the 4511 blanks β note this, and contrast with what a hex-capable decoder would do.
- Control-pin experiments. Momentarily ground LTΜ (all segments light β lamp test), ground BLΜ (display blanks), and raise LE with a digit showing, then change the switches (display freezes β LE is a latch, last lab's lesson hiding inside this chip). Record all three.
Part 3 β 4-to-2 Encoder from OR Gates (β15 min)
- Inputs and outputs. Four pushbuttons D0βD3, each with a 10 kΞ© pull-down (button from +5 V to its column, resistor from column to GND). Two LEDs as the code output A1 (MSB), A0 (LSB).
- Wire the '32 per Figure 3: gate 1 (pins 1,2β3): D1, D3 β A0. Gate 2 (4,5β6): D2, D3 β A1. D0 connects to nothing β pressing it yields code 00 by silence.
- Verify. Press each button alone and record the 2-bit code in Data Table 3: D0β00, D1β01, D2β10, D3β11 β the exact inverse of Part 1.
- Find the flaw. Press D1 and D2 together: the output claims 11, i.e. "D3" β a lie. Record it, and explain in one sentence what the 74HC148's priority logic would have answered instead (highest input wins: 10).
Part 4 β MUX, then the DEMUX Revelation (β25 min)
- Build the 2-to-1 MUX per Figure 3 with spare gates: inputs A and B from two slide switches, select S from a third; S β 04 spare inverter β SΜ; AND gate 1: SΜΒ·A; AND gate 2: SΒ·B; OR them β Y β LED.
- Prove selection. Set A = 1, B = 0. S = 0 β Y shows A (1). S = 1 β Y shows B (0). Now wiggle the unselected input and watch Y ignore it completely. Fill Data Table 4.
- Route a live signal. Replace input B with the function generator (square, 1 Hz, 0β5 V). S = 1: the LED blinks (you routed the generator). S = 0: steady A. One wire = many sources, taking turns.
- The demux revelation. Return to your Part 1 decoder. Pick ONE change: replace the AΜ 1Β·AΜ 0-style two-input recognition with three-input recognition by routing a DATA switch through spare '08 gates β concretely: take each decoder output Yn into a fresh AND gate paired with DATA, and move the LEDs to those gate outputs. Now A1 A0 select a destination and DATA's value appears there: 1-line-to-4-line demultiplexer. Toggle DATA with the code at 10 β only LED 2 blinks. Record in Data Table 4.
- Say it in one sentence. For the report: why do 74HC138 datasheets title the chip "decoder/demultiplexer"?
Part 5 β R-2R DAC & the Staircase (β30 min)
- Build the ladder per Figure 4 on a clear breadboard area: backbone of three 1 kΞ© resistors between four node columns; a 2 kΞ© leg rising from each node to a slide switch (SPDT: GND / leg / +5 V); the 2 kΞ© terminator from the LSB-end node to GND. Multimeter (V) from the MSB-end node (Vout) to GND.
- Predict, then measure the corners. Predict with Vout = 5 Γ code/16, then measure codes 0000, 0001 (1 LSB!), 1000 (MSB alone = 2.5 V), 1111. Record predicted vs measured in Data Table 5.
- Fill the table. Measure the remaining codes (order suggested in the table). The steps should march up by β0.3125 V each time. Any code that breaks the pattern β check that bit's 2 kΞ© leg and switch.
- Binary weight check. From your data: does code 1000 alone equal the sum of 0111 + 1 LSB? Show the arithmetic in the report β that identity is binary weighting, measured.
- Automate: the staircase. Seat the 74HC193 (16-pin: VCC 16, GND 8; tie CLR pin 14 β GND, LOAD pin 11 β +5 V, DOWN-clock pin 4 β +5 V). Function generator (square, 1 Hz, 0β5 V) β UP-clock pin 5. Replace the four switches: QA (pin 3) β b0 leg, QB (2) β b1, QC (6) β b2, QD (7) β b3. Oscilloscope on Vout, 500 ms/div.
- Watch it climb. Run: Vout ascends 16 steps and wraps to zero β a staircase waveform, the counting of the '193 made visible as voltage. Sketch or screenshot it; record step height and period in Data Table 5. You have built a (slow) signal generator from a counter and eight resistors.
Part 6 β 2-Bit Flash ADC (β30 min)
- Reference ladder. Four 1 kΞ© resistors in series from +5 V to GND. Verify the taps with the multimeter: 3.75 V, 2.50 V, 1.25 V top to bottom.
- Comparator bank. Three LM741s, each powered single-supply: pin 7 β +5 V, pin 4 β GND. Wire each tap to one comparator's inverting input (pin 2): C1 gets 1.25 V, C2 gets 2.50 V, C3 gets 3.75 V.
- Analog input. 10 kΞ© pot across +5 V/GND; wiper β all three non-inverting inputs (pin 3), and β multimeter so you can read Vin precisely.
- Thermometer display. Each comparator output (pin 6) β LED + 220 Ξ© β GND, stacked vertically L1 (bottom) to L3 (top).
- Sweep and map. Turn the pot slowly from 0 to 5 V. The LEDs fill bottom-up β thermometer code. Record in Data Table 6 the Vin at which each LED turns on, versus the ladder's theoretical thresholds. Then park the pot at 1.8 V and nudge it Β±0.2 V: the code doesn't move. You are standing inside one quantization step β that immobility is quantization error, experienced.
- Optional: close the loop to binary. Route L1, L2, L3 into encoder logic (b1 = L2; b0 = L3 + (L1Β·LΜ2) β one OR, one AND, one inverter from your spares) and two LEDs show the count 00β11 in binary. Note: the 741's HIGH (~3.5 V) is marginal for 74HC inputs; in Tinkercad it works β on real hardware you'd use an LM339 comparator with a pull-up. Record the binary column in Data Table 6.
- Wrap up. Complete the Analysis Questions and Knowledge Check, then Print/Save your report with all six data tables.
π Data Tables
Tables persist when you print this page.
Data Table 1 β 2-to-4 Decoder (Part 1)
| A1 | A0 | Y0 | Y1 | Y2 | Y3 | # of LEDs lit |
|---|---|---|---|---|---|---|
| 0 | 0 | |||||
| 0 | 1 | |||||
| 1 | 0 | |||||
| 1 | 1 |
Data Table 2 β BCD β 7-Segment (Part 2)
| D C B A | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010β1111 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Digit shown |
| Control experiment | Observed display behavior |
|---|---|
| LTΜ grounded | |
| BLΜ grounded | |
| LE raised, then inputs changed |
Data Table 3 β 4-to-2 Encoder (Part 3)
| Button pressed | A1 | A0 | Code correct? |
|---|---|---|---|
| D0 | |||
| D1 | |||
| D2 | |||
| D3 | |||
| D1 + D2 together |
Data Table 4 β MUX & DEMUX (Part 4)
| Test | S / code | Y / destination | Observation |
|---|---|---|---|
| MUX: A=1 B=0 | S=0 | ||
| MUX: A=1 B=0 | S=1 | ||
| MUX: wiggle unselected input | β | ||
| MUX: B = 1 Hz generator | S=1 | ||
| DEMUX: DATA toggled | code 10 | ||
| DEMUX: DATA toggled | code 01 |
Data Table 5 β R-2R DAC (Part 5)
| Code b3b2b1b0 | Decimal | Predicted V = 5Β·n/16 | Measured V_out |
|---|---|---|---|
| 0000 | 0 | ||
| 0001 | 1 | ||
| 0010 | 2 | ||
| 0100 | 4 | ||
| 0111 | 7 | ||
| 1000 | 8 | ||
| 1100 | 12 | ||
| 1111 | 15 | ||
| Staircase: step height Β· period per full ramp | |||
Data Table 6 β Flash ADC (Part 6)
| V_in range | Theoretical threshold | Measured turn-on V_in | L3 L2 L1 | Binary b1 b0 (opt.) |
|---|---|---|---|---|
| 0 β 1.25 V | β | β | ||
| 1.25 β 2.50 V | 1.25 V | |||
| 2.50 β 3.75 V | 2.50 V | |||
| 3.75 β 5.00 V | 3.75 V | |||
| Quantization test: code change while nudging pot Β±0.2 V inside a step? | ||||
π Interactive Signal-Path & Conversion Playground
All six circuits, live. The digital modes draw the signal path with active routes in green; the converter modes plot the transfer function β the staircase that defines digital-analog conversion β with your operating point riding on it. Rehearse each part here before wiring it.
β Analysis Questions
Answer in complete sentences in your lab report.
- State the input/output relationship of a decoder and an encoder in one sentence each, and use your Data Tables 1 and 3 to show they are inverses.
- In Part 3 you caught the simple encoder lying when two buttons were pressed. Explain how the 74HC148's priority scheme resolves it, and give one real device where priority encoding is essential.
- Defend the sentence "a demultiplexer is a decoder with data on its enable" using your Part 4 step 4 observations. Why do manufacturers sell one chip for both jobs?
- From Data Table 5: compute the measured step size between consecutive codes and compare to the theoretical 1 LSB = 312.5 mV. Then compute what 1 LSB would be for an 8-bit and a 16-bit converter on the same 5 V reference β and explain what those numbers mean for audio quality.
- Your staircase generator (counter + DAC) is a primitive arbitrary-waveform generator. Describe what waveform you'd get if the '193 counted down instead, and what you'd get alternating up/down.
- Flash conversion needed 3 comparators for 2 bits. Derive the comparator count for n bits, evaluate it for 8 and 10 bits, and explain the engineering trade this architecture makes (and why oscilloscope front-ends pay it gladly).
- Security connection: sensor-spoofing attacks target exactly the boundary you built in Part 6 β if an attacker can nudge Vin across one comparator threshold, the digital system downstream sees a different "fact." Using your Data Table 6 thresholds, state the minimum voltage perturbation that changes your ADC's output code, and explain in two sentences why more bits of resolution can make such tampering both harder to hide and easier to detect.
Key Facts Reference Box
Interactive Knowledge Check
Six questions drawn directly from the lab. Select an answer for each, then press Grade My Quiz.