Tell Idle From Request Zero With an SN74HC148 Priority Encoder
An eight-line priority encoder can tell a service panel which request to handle first. Three output bits give the selected input number. On the Texas Instruments SN74HC148, those bits read high at idle and also when request 0 wins. Build a slow, static test panel and measure two extra outputs to tell the cases apart.
Put each request on a defined voltage
Use one Texas Instruments SN74HC148DR, the 16-pin small-outline integrated circuit (SOIC) in package D, soldered with the correct pin-1 orientation to a narrow SOIC-to-breadboard adapter. The tape-and-reel suffix R does not change the electrical pinout. Check continuity from each chip lead to its adapter pad with power off. The silicon uses high-speed complementary metal–oxide–semiconductor (HC CMOS) logic. Its project supply is 4.50 V even though the manufacturer's recommended operating range is 2 to 6 V. The 7 V absolute maximum is a stress limit.
Feed pin 16 (VCC) from a regulated independent channel of a SIGLENT SPD3303X, initially set to 4.50 V and a 20 mA current limit. Connect pin 8 and the supply negative to G0. Put a 100 nF ceramic bypass capacitor between those pins with short leads. The capacitor supplies brief local current as the logic changes.
Connect each of the eight single-pole, single-throw request switches from its own input to G0. Give each input a separate 4.7 kΩ, ±1% pull-up resistor to VCC. A pull-up sets a voltage near VCC when its switch is open. Closing a switch connects the input to G0 and asserts that request. Use the same cell for pin 5, EI, the active-low enable input. Closing the separate enable switch activates the encoder. Opening it disables the encoder.
- Request pins I0 through I3 go to physical pins 10, 11, 12 and 13 respectively.
- Request pins I4 through I7 go to physical pins 1, 2, 3 and 4 respectively.
- Give A2, A1, A0, GS, EO separate test points at physical pins 6, 7, 9, 14 and 15 respectively. Measure EI at its pin-5 test point.
The request and enable switches carry about 4.50 V / 4.7 kΩ = 0.96 mA each when closed. Even at 4.55 V with 1% low resistors, all nine pull-ups use under 8.9 mA and each resistor dissipates under 4.5 mW. Typical quarter-watt resistors have ample margin. An open switch still leaves its input connected to the supply through the resistor. Never remove a pull-up or attach a debounce capacitor directly to an HC input. Texas Instruments specifies a maximum 500 ns transition time at a 4.5 V supply. This procedure changes switch settings with the output of the supply off and checks settled DC states after power is reapplied.
Understand why three ones are ambiguous
Active-low means the low voltage asserts the signal. The requests and EI use that convention. When enabled and one or more requests are asserted, the highest-numbered request wins. A2 is the most significant bit, with weight four. The encoder supplies the bitwise complement of the selected number. For example, request 6 is binary 110, so the code pins measure 001. You can also treat the three pins as an unsigned number and subtract that number from 7.
GS, group select, goes low when the enabled device has a request to serve. Read the three code pins only when GS is low. EO, enable output, goes low when the part is enabled and all requests are inactive. That signal can enable a lower-priority stage in an expanded circuit. Here it lets the reader distinguish enabled idle from disabled operation.
| Condition | A2 A1 A0 | GS / EO |
|---|---|---|
| Enabled, idle | 111 | H / L |
| Enabled, request 0 | 111 | L / H |
| Disabled | 111 | H / H |
Measure one condition at a time
Use a Fluke 115 digital multimeter in direct-current voltage mode. Put its black lead in COM at G0 and its red lead in the voltage jack. Its nominal input impedance exceeds 10 MΩ in this mode, corresponding to less than 0.46 µA of meter loading at 4.55 V. Leave the outputs free of LEDs and any other load. Measure each test point in sequence while leaving the switch settings alone. A probe that bridges two adapter pads can short two signals, so prefer the output test points.
- With the power off, set the enable switch closed and all eight request switches open. Turn on the supply output. Check the voltage at the chip supply and confirm the supply remains in constant-voltage mode. On this first run, measure the open request input nodes one by one. Each should be near VCC. Fix unexpected input levels before recording the outputs.
- Open the observation worksheet in a plain CSV editor. For each trial follow the request settings in the
closedcolumn.-means no request closed and2+6means both 2 and 6 closed. Close EI for all trials except rows starting withdisabled_. Confirm the physical switches match the intended row. Turn off the supply output and wait for the rail to fall before each change, then reapply power. Keep the configuration fixed until every voltage for that row is recorded. - Record the chip supply, EI, A2, A1, A0, GS and EO in volts. Compare all eight individual inputs. Then compare the simultaneous requests 2 and 6 with the next trial, where 6 is open and 2 remains closed. In the two disabled trials, a request of 7 should make no difference. Re-enable the part in the final trial and check request 0 again.
Texas Instruments specifies logic input thresholds of 1.35 V maximum for low and 3.15 V minimum for high at VCC = 4.5 V. At that same supply, the lightly loaded output limits at 20 µA are 0.10 V maximum low and 4.40 V minimum high. The checker's fixture screen accepts measured VCC from 4.45 to 4.55 V, and accepts logic levels within 0.20 V on the inside of either rail, with 0.05 V allowed past the rail for meter and supply tolerances. Those windows are practical screening bounds, separate from manufacturer characterization or certification. If a value is nearer neither rail, recheck wiring, supply, meter mode and switch positions before repeating the row.
This circuit chooses among levels present at its inputs and keeps no record of old requests. A lower-numbered request can be hidden while a higher-numbered one remains asserted. The datasheet also warns that changing input levels can produce wrong addresses, and a falling EI can momentarily pull GS low even when all requests are inactive. A capture or interrupt circuit needs its own timing and switch-conditioning design. The static experiment makes no claim about those transients.
Predict what changes when one request clears
In an enabled panel, requests 0 and 5 are both asserted. What pin pattern should you see? What happens after 5 clears, then after 0 clears?
Answer
The code starts at 010, the complement of 101 for request 5, with GS low and EO high. Clearing 5 leaves request 0 and code 111 while GS stays low and EO stays high. Clearing 0 leaves the code at 111 but GS goes high and EO goes low.
Check the voltage list with Python
Run python3 priority_panel.py observations.csv on the completed worksheet. The checker requires all 16 named trials, accepts the rows in any order and verifies the measured enable pin and all five output levels. Return code 0 means the entered settled voltages support the checked table. Code 1 means an observation is missing, outside the fixture screen or inconsistent with the table. Code 2 means a file or CSV read failed. The software trusts your written switch settings, so a matching output does not independently verify every physical input position.
Download the standalone checker or use the experiment archive for the checker, editable diagram, blank worksheet, synthetic practice data and tests. The practice CSV and automated tests are synthetic. No physical bench measurements are included.
Complete source for priority_panel.py
#!/usr/bin/env python3
"""Check settled voltages from an SN74HC148DR priority encoder test panel."""
import argparse
import csv
from decimal import Decimal, InvalidOperation
from pathlib import Path
import sys
HEADER = ("case", "closed", "vcc_v", "ei_v", "a2_v", "a1_v", "a0_v", "gs_v", "eo_v")
OUTPUTS = ("A2", "A1", "A0", "GS", "EO")
TRIALS = {
"idle": (True, "-"),
"zero": (True, "0"), "one": (True, "1"), "two": (True, "2"), "three": (True, "3"),
"four": (True, "4"), "five": (True, "5"), "six": (True, "6"), "seven": (True, "7"),
"pair_2_6": (True, "2+6"), "release_6": (True, "2"),
"triple_0_3_7": (True, "0+3+7"), "all_closed": (True, "0+1+2+3+4+5+6+7"),
"disabled_idle": (False, "-"), "disabled_7": (False, "7"),
"restored_zero": (True, "0"),
}
class ObservationError(ValueError):
"""The recorded voltages do not establish the intended truth table."""
def voltage(raw, label):
try:
value = Decimal(raw)
except InvalidOperation as error:
raise ObservationError(f"{label}: enter a voltage in decimal volts") from error
if not value.is_finite():
raise ObservationError(f"{label}: voltage must be finite")
return value
def level(raw, vcc, label):
value = voltage(raw, label)
if not Decimal("-.05") <= value <= vcc + Decimal(".05"):
raise ObservationError(f"{label}: voltage outside the fixture rails")
if value <= Decimal(".20"):
return "0"
if value >= vcc - Decimal(".20"):
return "1"
raise ObservationError(f"{label}: voltage beside neither rail")
def expected(enabled, closed):
if not enabled:
return "11111"
if closed == "-":
return "11110"
highest = max(map(int, closed.split("+")))
return f"{7 - highest:03b}01"
def condition(bits):
code, gs, eo = bits[:3], bits[3], bits[4]
if gs == "0":
return f"request {7 - int(code, 2)}"
return "idle" if eo == "0" else "disabled"
def check(rows):
rows = iter(rows)
if tuple(next(rows, [])) != HEADER:
raise ObservationError("CSV: use the exact worksheet header")
states = {}
for number, row in enumerate(rows, 2):
if len(row) != len(HEADER):
raise ObservationError(f"line {number}: expected nine CSV fields")
name, closed, raw_vcc, raw_ei, *values = row
if name not in TRIALS:
raise ObservationError(f"line {number}: unknown trial {name!r}")
if name in states:
raise ObservationError(f"{name}: duplicate trial")
enabled, planned_closed = TRIALS[name]
if closed != planned_closed:
raise ObservationError(f"{name}: closed switches must be {planned_closed}")
vcc = voltage(raw_vcc, f"{name}: supply")
if not Decimal("4.45") <= vcc <= Decimal("4.55"):
raise ObservationError(f"{name}: supply must be 4.45 to 4.55 V")
if level(raw_ei, vcc, f"{name}: EI") != ("0" if enabled else "1"):
raise ObservationError(f"{name}: EI disagrees with the stated enable condition")
bits = "".join(level(value, vcc, f"{name}: {pin}") for value, pin in zip(values, OUTPUTS))
wanted = expected(enabled, closed)
if bits != wanted:
raise ObservationError(f"{name}: pin pattern {bits}, expected {wanted} in A2 A1 A0 GS EO order")
states[name] = condition(bits)
missing = TRIALS.keys() - states.keys()
if missing:
raise ObservationError(f"CSV: missing trial(s): {', '.join(sorted(missing))}")
return [(name, states[name]) for name in TRIALS]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("observations")
args = parser.parse_args()
try:
with Path(args.observations).open(newline="", encoding="utf-8-sig") as stream:
states = check(csv.reader(stream, strict=True))
except ObservationError as error:
print(f"UNRESOLVED: {error}", file=sys.stderr)
return 1
except (OSError, UnicodeError, csv.Error) as error:
print(f"ERROR: {error}", file=sys.stderr)
return 2
for name, outcome in states:
print(f"{name:18} {outcome}")
return 0
if __name__ == "__main__":
sys.exit(main())
Related experiments and primary sources
- Compare two four-bit values with a CD74HC85 to see how a different logic chip uses several result pins. The SN74HC14 switch experiment measures the timing and thresholds of a conditioned switch.
- Texas Instruments SN74HC148 datasheet SCLS109H, especially §§5, 6, 8.3, 9 and 10. The exact SN74HC148DR part page identifies package D and the ordering suffix.
- Texas Instruments advisory on slow or floating CMOS inputs, Fluke 115 manual and SIGLENT SPD3303X specifications and quick start guide.