Source: https://mokxi.com/decoder-simulator

Simulator

# A 3 to 8 decoder simulator: a 74HC138 lighting one LED of eight

Mokxi is a free online decoder simulator that runs in your browser, with nothing to install and no account needed. Three logic chips and no microcontroller: a 74HC14 oscillator clocks a 74HC161 counter, and a 74HC138 decodes the counter’s bottom three bits into one lit LED out of eight. Every pin is live, so you can follow the binary address in and the one low output out.

Start building free or decode BCD for a 7-segment display

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

One LED of eight lights at a time, moving on about every 0.385 seconds. Click the circuit to open it in the editor and probe the address pins.

## What you can do here

In the circuit above, or in the editor it opens.

- Follow a 3-bit binary address to the one output it selects
- Read the 138’s active-low outputs and see why the LEDs hang from 5 V
- Disable the chip with an enable pin and watch every output go high
- Change the clock’s capacitor and speed up the count
- Cascade two 138s into a 4 to 16 decoder
- Drive the address from an Arduino instead of a counter

## What the running circuit shows

Three bits in, one line low.

The 74HC161 counts up on every rising edge of its clock, and its Q0, Q1 and Q2 go to the 138’s A0, A1 and A2. The 138 pulls exactly one of its eight outputs low: Y3 when the address is binary 011. In the engine the selected output sits at about 0.26 V and the others at 5.00 V. Each LED runs from the 5 V rail through 330 ohms into one output, so only the low one lights, at about 8.8 mA.

The clock is one Schmitt inverter of the 74HC14 with 100 k from its output back to its input and 4.7 µF from the input to ground. A Schmitt input switches at two different voltages, so the capacitor chases the output between them, about 1.78 V and 2.78 V here, and it oscillates at about 0.8 × R × C. In the engine the light moves on every 0.385 seconds and runs along all eight LEDs in about 3.1 seconds. Change C1 to 1 µF and each step takes about 82 ms.

Q3 is not used, so the 138 never sees the fourth bit and the light runs along the row twice for every sixteen counts. The 138 also has three enables, E1 and E2 active low and E3 active high, all tied on here. Pull E3 low and every output goes high and every LED goes dark, which is how a second 138 takes over the next eight lines in a 4 to 16 decoder.

## How the chips are modeled

Logic levels, thresholds and nanoseconds.

Each chip follows its datasheet. The 138 works out every output separately, so an unknown input only makes an output unknown when it could change it, and its propagation delay is the SN74HC138’s typical 18 ns. The 161 changes all four outputs on the same clock edge, a synchronous counter, and the 74HC14’s inputs have real Schmitt thresholds, which is what lets a resistor and a capacitor make it oscillate.

What it leaves out: the few-nanosecond glitches a real 138 can show while its three address inputs change at slightly different times. Here the change from one output to the next is clean. If you clock something fast from a decoder output in hardware, that glitch is worth designing around.

The BCD to 7-segment decoder The multiplexer simulator The digital circuit simulator Digital logic lab experiments

## Questions

Is it free?

Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.

Do I need an account?

No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.

What does a 3 to 8 decoder do?

It takes a 3-bit binary number and selects one of eight outputs: address 0 selects Y0, address 5 selects Y5. On the 74HC138 the selected output goes low and the other seven stay high.

Why do the LEDs go from 5 V to the decoder’s outputs?

Because the 138’s outputs are active low. The selected output sinks current, so an LED from the 5 V rail through a resistor into it lights. Wired to ground instead, seven would light and one would go dark.

How do I make a 4 to 16 decoder?

Use two 138s. Wire the three address lines to both, and put the fourth bit on the enables: into E1 of the first chip and E3 of the second, so the first answers 0 to 7 and the second 8 to 15.

## More simulators

Each one opens on a circuit that is already running.

Online circuit simulator Breadboard simulator ESP32 simulator Op-amp simulator Logic gate simulator LED circuit simulator Servo simulator LCD simulator OLED simulator NeoPixel simulator 7 segment display simulator LED matrix simulator Stepper motor simulator Motor driver simulator Ultrasonic sensor simulator Rectifier simulator Digital circuit simulator Potentiometer simulator PWM simulator Relay simulator Shift register simulator DHT11 simulator RFID simulator Accelerometer simulator RGB LED simulator Buzzer simulator MOSFET simulator Circuit simulator for kids Flip-flop simulator Multiplexer simulator Full adder simulator I2C simulator UART simulator Thermistor simulator PIR sensor simulator Oscilloscope simulator Multimeter simulator DC motor simulator Traffic light simulator Diode simulator Capacitor simulator Series and parallel circuit simulator Wheatstone bridge simulator Voltage regulator simulator Soil moisture sensor simulator Zener diode simulator Solar panel simulator AC circuit simulator Thevenin simulator Encoder simulator PID simulator Robot arm simulator Load cell simulator IR sensor simulator LM35 simulator HC-05 Bluetooth simulator nRF24L01 simulator

## Decode a count

Open the circuit, probe the address pins and follow the light. Nothing to install, and no account needed.

Start building free Open the editor
