Parts

74HC138 3-to-8 decoder: pinout, truth table, an LED select circuit and 16-line expansion

By

The 74HC138 is a 16-pin 3-to-8 decoder. Pins 1, 2 and 3 are the address (A, B, C, with A the lowest bit), pins 4, 5 and 6 are the enables (G2A and G2B active low, G1 active high), pin 8 is ground and pin 16 is VCC. Outputs Y0 to Y6 sit on the right side, Y0 on pin 15 down to Y6 on pin 9; Y7 is on pin 7. When the chip is enabled, the output whose number matches the address goes low and the other seven stay high.

The page covers the function table, the two naming schemes makers use for the same pins, input levels and delay, a worked circuit that lights one of eight LEDs from three microcontroller pins, and two chips wired as a 4-to-16 decoder. The figures come from Texas Instruments' SN74HC138 sheet and Diodes Incorporated's 74HC138 sheet; where they differ, both are shown.

Datasheet: Texas Instruments SNx4HC138 3-Line To 8-Line Decoders/Demultiplexers (SCLS107G) (PDF)Ask Datasheet Guru about the 74HC138N

Advertisement

Pinout by package

SN74HC138N DIP-16 · TI1=A 2=B 3=C 4=G2A 5=G2B 6=G1 7=Y7 8=GND 9=Y6 10=Y5 11=Y4 12=Y3 13=Y2 14=Y1 15=Y0 16=VCC
top view, notch upSN74HC138N116AVCC215BY0314CY1413G2AY2512G2BY3611G1Y4710Y7Y589GNDY6

Top view, notch up: pin 1 (A) is top left, the count runs down the left side and back up the right.

The SOIC (SN74HC138D) and TSSOP (PW) versions use the same pin numbers.

Source: Texas Instruments SNx4HC138 3-Line To 8-Line Decoders/Demultiplexers (SCLS107G), p. 3 (Section 5, D, DB, N, NS, PW, J or W package top view, and the pin functions table); Texas Instruments SNx4HC138 3-Line To 8-Line Decoders/Demultiplexers (SCLS107G), p. 15 (package option addendum: SN74HC138N, PDIP (N) 16 pins, −40 to 85 °C, marking SN74HC138N)

74HC138S16 SOP-16 · Diodes Inc.1=A0 2=A1 3=A2 4=E1 5=E2 6=E3 7=Y7 8=GND 9=Y6 10=Y5 11=Y4 12=Y3 13=Y2 14=Y1 15=Y0 16=VCC
top view, notch up74HC138116A0VCC215A1Y0314A2Y1413E1Y2512E2Y3611E3Y4710Y7Y589GNDY6

Top view, pin 1 at the dot. Same pin numbers as the TI part; only the names differ.

Diodes lists SO-16 and TSSOP-16 only, no DIP.

Source: Diodes Incorporated 74HC138 3 to 8 Line Decoder Demultiplexer, DS35488, p. 1 (Pin assignments, SO-16 / TSSOP-16 top view); Diodes Incorporated 74HC138 3 to 8 Line Decoder Demultiplexer, DS35488, p. 2 (Pin descriptions table: A0 to A2, E1 and E2 active low, E3 active high); Diodes Incorporated 74HC138 3 to 8 Line Decoder Demultiplexer, DS35488, p. 7 (Ordering information: 74HC138S16-13 (SO-16) and 74HC138T16-13 (TSSOP-16))

Which one do you have?

TI sells it as SN74HC138: SN74HC138N is the plastic DIP, SN74HC138D the SOIC and SN74HC138PW the TSSOP, all with the same pin numbers. Diodes Incorporated drops the prefix (74HC138S16 for SO-16, 74HC138T16 for TSSOP-16) and has no DIP. The SN54HC138 is TI's military-temperature version in ceramic packages.

The two makers label the same six pins differently. TI calls the address inputs A, B and C and the enables G1, G2A and G2B; Diodes calls them A0, A1, A2 and E3, E1, E2. The numbering is the same, so a circuit drawn with one set of names works with the other chip. Watch the enables: TI's G1, the active-high one, is Diodes' E3, not E1.

PinTIDiodesWhat it does1AA0address bit 0 (LSB)2BA1address bit 13CA2address bit 2 (MSB)4G2AE1enable, active low5G2BE2enable, active low6G1E3enable, active high
Figure 1. Same pin, two names. The outputs, ground on pin 8 and VCC on pin 16 are named the same by both makers.

A 74HCT138 is the TTL-input version with the same pins; it runs from 4.5 to 5.5 V and is not covered here. A 74LS138 is the older bipolar part, also with the same pinout but with different input currents and levels.

Truth table: how the address picks an output

With G1 high and both G2 pins low, the chip reads C B A as a binary number from 0 to 7 and pulls that output low: 0 0 0 selects Y0, 1 0 1 selects Y5, 1 1 1 selects Y7. If any enable is in its wrong state (G1 low, or G2A or G2B high), all eight outputs go high and the address is ignored. Both datasheets give the same table.

C B AY0Y1Y2Y3Y4Y5Y6Y7address0 0 0LHHHHHHH0 0 1HLHHHHHH0 1 0HHLHHHHH0 1 1HHHLHHHH1 0 0HHHHLHHH1 0 1HHHHHLHH1 1 0HHHHHHLH1 1 1HHHHHHHLenabled: G1 high, G2A and G2B low; otherwise all H
Figure 2. One low output per address. The low output is the one you use: an LED, a chip-select line or a relay driver hangs off each Y pin.

The outputs are active low. TI aims the part at memory decoders, and memory chip-select inputs are active low too. To drive something that wants an active-high signal, add an inverter or a transistor stage, or wire the load from VCC to the output so it runs when the output goes low, as the worked example below does.

Absolute maximum ratings

The two makers agree on the supply: 7 V absolute maximum, 2 to 6 V recommended. Each output may carry ±25 mA and the VCC or ground pin 50 mA for the whole chip. TI rates its SN74HC138 from −40 to 85 °C; the Diodes part is rated to 125 °C and also states a 500 mW total power limit, which TI's sheet does not give.

Absolute maximum and recommended ratings, from each maker's datasheet
ParameterSN74HC138NDIP-1674HC138S16SOP-16
Supply voltage, absolute maximum VCC−0.5 to 7 V−0.5 to 7.0 V
Supply voltage, recommended VCC2 to 6 V2.0 to 6.0 V
Continuous output current IO±25 mA±25 mA
Current through VCC or GND ICC, IGND±50 mA50 mA
Input and output clamp current IIK, IOK±20 mA±20 mA
Total power dissipation PTOTnot given500 mW
Operating temperature TA−40 to 85 °C (SN74)−40 to 125 °C
Input rise or fall time, max Δt/ΔvVCC = 4.5 V500 ns500 ns/V

Because the decoder only ever pulls one output low, the 50 mA ground-pin limit is hard to reach in normal use. The per-output limit is the one to watch when an output sinks an LED or a relay coil directly.

Input levels, output drive and speed

At VCC = 4.5 V unless marked (min/max unless marked typical)
ParameterSN74HC138NDIP-1674HC138S16SOP-16
High-level input voltage, min VIH3.15 V3.15 V
Low-level input voltage, max VIL1.35 V1.35 V
Output high, min VOHIOH = −4 mA, 25 °C3.98 V (4.3 V typ)3.98 V (4.32 V typ)
Output low, max VOLIOL = 4 mA, 25 °C0.26 V (0.17 V typ)0.26 V (0.15 V typ)
Output low, max VOLIOL = 4 mA, −40 to 85 °C0.33 V0.33 V
Supply current, max ICCVCC = 6 V, inputs at a rail8 µA (25 °C), 80 µA (to 85 °C)8 µA (25 °C), 80 µA (to 85 °C)
Address to output delay, max tpdCL = 50 pF, 25 °C36 ns (18 ns typ)30 ns
Address to output delay, max tpdCL = 50 pF, −40 to 85 °C45 ns38 ns
Enable to output delay, max tpdCL = 50 pF, 25 °C31 ns30 ns
Power dissipation capacitance Cpdtypical, no load85 pF19 pF (at 5 V, 1 MHz)

At 4.5 V an input below 1.35 V counts as low and above 3.15 V as high, the same pair on both sheets. Diodes' feature list claims Schmitt-trigger action on every input; TI's sheet makes no such claim, so do not count on hysteresis when the part might come from either maker. Tie unused enables to their active level and never leave an input open.

The output figures that matter for a load: at 4 mA an output stays below 0.26 V when low at 25 °C and below 0.33 V over the full temperature range. Typical is 0.17 V on TI's sheet and 0.15 V on Diodes'.

2 VTI, 25 °C180 nsTI, to 85 °C225 nsDiodes, 25 °C150 ns4.5 VTI, 25 °C36 nsTI, to 85 °C45 nsDiodes, 25 °C30 ns6 VTI, 25 °C31 nsTI, to 85 °C38 nsDiodes, 25 °C26 ns
Figure 3. Address-to-output delay, maximum, at a 50 pF load. At 2 V the limit is five times the 4.5 V figure.

At 4.5 V the worst address-to-output delay is 36 ns at 25 °C on TI's sheet (18 ns typical) and 45 ns up to 85 °C; Diodes gives 30 ns at 25 °C. When a microcontroller sets the address in software, that is too short to matter; on a memory bus it counts. Also, while the address bits change one after another, the chip briefly decodes the in-between values, so a different output can pulse low for a few nanoseconds. Hold an enable inactive while the address changes if those glitches would hurt.

What it is good for

  • Chip-select decoding: three address lines pick one of eight SPI devices, memories or peripherals.
  • Scanning an LED matrix or a multiplexed seven-segment display one column at a time. TI's own application section shows it as the column selector beside a 74HC595.
  • Saving microcontroller pins: three pins select eight lines, four pins and two chips select sixteen.
  • Demultiplexing: put a data signal on one enable and it appears, inverted or not, on the selected output only.

It is a poor choice when two outputs must be active at once, because it can only ever pull one low; a shift register such as the 74HC595 handles that. For the gates that usually sit around it, see the 74HC logic gates page. The logic families lesson compares HC with the other CMOS and TTL families.

Worked example: one of eight LEDs from three pins on 5 V

A 5 V microcontroller drives A, B and C. G1 is tied to 5 V and G2A and G2B to ground, so the chip is always enabled. Each output gets a red LED and a resistor from the 5 V rail: the LED lights when its output goes low. Neither maker prints a 5 V row, so the numbers use the 4.5 V limits, the nearest supply both sheets specify.

1. Pick the current. The output-low limits are written for 4 mA, so design to that. It is well inside the 25 mA absolute maximum and bright enough for an indicator LED.

2. Size the resistor. The resistor drops VCC minus the LED's 2 V minus the output's worst-case low level, 0.33 V: R = (5 − 2 − 0.33) / 4 mA = 668 Ω. The next standard E12 value is 680 Ω.

3. Worst-case current. With 680 Ω and the hot-chip 0.33 V low level: (5 − 2 − 0.33) / 680 = 3.93 mA.

4. Typical current. TI's typical 0.17 V at 4 mA behaves like 42.5 Ω in series, so the current is (5 − 2) / (680 + 42.5) = 4.15 mA, and the output sits at about 0.176 V.

5. Check the chip. Only one output is low at a time, so the ground pin carries one LED's current: 3.93 mA to 4.15 mA, about 8 % of the 50 mA pin limit. The seven high outputs have 5 V on both ends of their LED and resistor, so their LEDs stay dark.

6. Select an LED. To light LED 5, set C B A to 1 0 1. The resistor dissipates about 12 mW, so any 0.25 W part will do.

5 G2B 4 G2A 6 G1 3 C 2 B 1 A 10 Y5 15 Y0 16 VCC 8 GND U1 74HC138 +5 V LED 0 R1 680 Ω LED 5 R2 680 Ω +5 V A = 1 B = 0 C = 1 +5 V
Figure 4. The select circuit as ngspice checked it, with outputs Y0 and Y5 drawn: address 1 0 1 pulls Y5 low and LED 5 carries 4.15 mA; Y0 stays high and LED 0 stays dark. Y1 to Y4, Y6 and Y7 are wired the same way. Put 100 nF from pin 16 to pin 8 at the chip.

To scan all eight LEDs so they look lit together, step the address through 0 to 7 a few hundred times a second. Each LED is then on for an eighth of the time, so it looks dimmer; the LED circuits lesson covers brightness and duty cycle.

Worked example in numbers

Resistor
680 Ω
LED current, worst case
3.93 mA
LED current, typical
4.15 mA
Address for LED 5
1 0 1

Two chips as a 4-to-16 decoder

The three enables are there so decoders can be stacked with no extra logic. For 16 lines, wire A0 to A2 to both chips. Send the fourth address bit, A3, to G2A of the first chip and to G1 of the second. When A3 is low the first chip is enabled and the second is disabled, so lines 0 to 7 come from the first chip; when A3 is high it is the other way round.

A0 A1 A2A3U1A B CG1 VCCG2A A3G2B GNDY0 to Y7lines 0 to 7U2A B CG1 A3G2A GNDG2B GNDY0 to Y7lines 8 to 15A3 low: U1 decodes. A3 high: U2 decodes.
Figure 5. The fourth address bit decides which chip is enabled. Both chips see the same three low bits.

TI's overview says the same trick reaches 24 lines with three chips and no inverter, and 32 lines with four chips and one inverter. Diodes gives the 16-line and 32-line versions.

  • 1 chip: 8 lines from 3 address bits, extra logic: none.
  • 2 chips: 16 lines from 4 address bits, extra logic: none.
  • 3 chips: 24 lines from 5 address bits, extra logic: none.
  • 4 chips: 32 lines from 5 address bits, extra logic: one inverter.
Advertisement

Tips and checks

  • Fit 100 nF from pin 16 to pin 8, right at the chip.
  • Never leave an enable open. A floating G2A or G2B can read high, and then every output stays high and the chip looks dead.
  • When reading a Diodes or other non-TI schematic, map E1, E2 and E3 by pin number, not by the digit: E3 is the active-high one.
  • Change the address with an enable held off if the load reacts to nanosecond glitches, such as a clock or a latch input.
  • For loads above a few milliamps, let the output drive a transistor or a 2N7000 gate rather than the load itself.

The IC power and decoupling and pull-up and pull-down lessons cover the first two points in detail.

Substitutes

The TI and Diodes parts swap freely: same pins, same function table, same input and output limits at 4.5 V. Only the pin names on the drawing change.

Pin numbers as on the DIP-16 or SO-16 top view, notch or dot at pin 1.
PartPinsVerdict
74HC138S16 (Diodes)same pins, names A0-A2, E1-E3A true equivalent in SO-16: same pins, same function table and the same 4.5 V input and output limits. Only the pin names differ, and it is rated to 125 °C.Diodes Incorporated 74HC138 3 to 8 Line Decoder Demultiplexer, DS35488, p. 2; Diodes Incorporated 74HC138 3 to 8 Line Decoder Demultiplexer, DS35488, p. 5
SN74HC138D / SN74HC138PWsame as the DIPThe same TI die in SOIC and TSSOP. Same pin numbers, same data sheet, for a PCB.Texas Instruments SNx4HC138 3-Line To 8-Line Decoders/Demultiplexers (SCLS107G), p. 3

Bench check: is it working?

  1. Power it from 5 V with G1 to VCC, G2A and G2B to ground and A, B, C to ground, and measure the supply current. It should be a few microamps; TI allows 80 µA at 6 V up to 85 °C. Milliamps means a floating input or a damaged chip.
  2. With a meter on pin 15 (Y0), check it reads near 0 V and that pin 14 (Y1) reads near 5 V.
  3. Move A to 5 V: Y0 should go high and Y1 low. Step through all eight addresses and check one output at a time goes low, following Figure 2.
  4. Pull G1 to ground. Every output should go high, whatever the address. If one stays low, that output or an enable pin is damaged.

What we'd do

Use a 74HC138 whenever a few microcontroller pins have to pick one of many things: chip selects, LED columns, relay drivers. Power it from the same rail as the microcontroller, tie the enables you do not use to their active level, and wire loads from VCC to the outputs. Size LED resistors for 4 mA with the worst-case 0.33 V low level, which gives 680 Ω on 5 V for a red LED. Buy the DIP from TI for the breadboard and either maker's SO-16 for a board.

Questions people ask

What is the pinout of the 74HC138?

Pins 1, 2, 3: address A, B, C. Pins 4 and 5: active-low enables G2A and G2B. Pin 6: active-high enable G1. Pin 7: Y7. Pin 8: ground. Pins 9 to 15: Y6 down to Y0. Pin 16: VCC.

Why are the 74HC138 outputs active low?

TI aims it at memory decoding, and memory chip-select inputs are active low. The selected output goes low and the rest stay high, so a load wired from VCC to an output runs only when that output is selected.

What do G1, G2A and G2B do?

They enable the chip. All three must be active, G1 high and both G2 pins low, or every output goes high. Diodes calls them E3, E1 and E2. Two or more chips use them to share one address bus.

Can a 74HC138 drive LEDs directly?

Yes, with a series resistor and the LED wired from VCC to the output. At 4 mA a 680 Ω resistor suits a red LED on 5 V. Only one output is low at a time, so the chip never carries more than one LED's current.

Does the 74HC138 work on 3.3 V?

Yes. It is specified from 2 to 6 V, and on 3.3 V it accepts 3.3 V logic directly. It is slower there: the delay limit lies between the 2 V and 4.5 V figures in Figure 3.

Buying the 74HC138 in India

The DIP is stocked by most Indian component sellers, usually as TI's SN74HC138N and sometimes with no maker named. Check the full number on the body: a listing for the 74HC138 may turn out to be a 74HCT138 or a 74LS138, both with the same pins but different input levels. Our guide to buying electronic components in India compares ten online sellers and covers how to spot fakes.

Advertisement

One email a month from the bench

New circuits, lessons, part guides and calculators, on the first Sunday of each month.

We'll send one email to confirm. Every email has a one-click unsubscribe. Privacy policy

Used in these lessons

Lessons that go deeper

Datasheets this page was checked against

Makers revise datasheets. If the copy you download has a newer revision and a number here disagrees with it, the datasheet wins, and we would like to hear about it.