Practical case: 1-bit equality detector

1-bit equality detector prototype (Maker Style)

Level: Basic – Verify the operation of a 74HC7266 XNOR gate as a logical equality detector using its truth table.

Objective and use case

In this practical case, you will build a digital equality detector using a 74HC7266 XNOR logic gate, mechanical switches, and an LED indicator.

This circuit concept is highly useful in real-world digital electronics:
* Digital locks: Comparing an entered bit to a stored security key bit.
* Error detection: Verifying if two redundant sensor signals output the exact same digital state.
* Data routing: Confirming destination addresses in memory mapping or basic communication protocols.
* Automation: Checking if a machine’s actual state matches the commanded state.

Expected outcome:
* The output LED turns ON when both inputs are perfectly equal (both LOW or both HIGH).
* The output LED remains OFF when the inputs differ (one is HIGH and the other is LOW).
* Logic LOW is measured as approximately 0 V, and logic HIGH as approximately 5 V.

Target audience: Beginners learning fundamental digital logic gates and Boolean algebra.

Materials

  • V1: 5 V DC power supply, function: circuit power
  • SW1: SPST switch, function: input A control
  • SW2: SPST switch, function: input B control
  • R1: 10 kΩ resistor, function: pull-down for node VA
  • R2: 10 kΩ resistor, function: pull-down for node VB
  • R3: 330 Ω resistor, function: LED current limiting
  • D1: red LED, function: equality indicator
  • U1: 74HC7266 IC, function: XNOR logic gate

Pin-out of the 74HC7266

The 74HC7266 is a Quad 2-Input EXCLUSIVE-NOR (XNOR) gate with push-pull outputs.

Pin Name Logic function Connection in this case
1 1 A Input A of gate 1 Node VA
2 1B Input B of gate 1 Node VB
3 1Y Output of gate 1 Node VOUT
5, 6 2 A, 2B Inputs of gate 2 Node 0 (GND)
7 GND Ground Node 0 (GND)
8, 9 3 A, 3B Inputs of gate 3 Node 0 (GND)
12, 13 4 A, 4B Inputs of gate 4 Node 0 (GND)
14 VCC Positive supply Node VCC

Note: Unused inputs (pins 5, 6, 8, 9, 12, 13) must be tied to ground to prevent CMOS oscillation and excess power draw.

Wiring guide

  • V1: connects between node VCC and node 0 (GND).
  • SW1: connects between node VCC and node VA.
  • R1: connects between node VA and node 0.
  • SW2: connects between node VCC and node VB.
  • R2: connects between node VB and node 0.
  • U1: VCC pin (14) connects to node VCC.
  • U1: GND pin (7) connects to node 0.
  • U1: Pin 1 (1 A) connects to node VA.
  • U1: Pin 2 (1B) connects to node VB.
  • U1: Pin 3 (1Y) connects to node VOUT.
  • U1: Pins 5, 6, 8, 9, 12, and 13 connect directly to node 0.
  • R3: connects between node VOUT and node D1_ANODE.
  • D1: anode connects to node D1_ANODE, cathode connects to node 0.

Conceptual block diagram

Conceptual block diagram — PIN 74HC7266 XNOR Gate
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

VCC --> [ SW1: SPST ] --(Node VA)--> [ U1: Pin 1 (1 A) ]
                                            |
        (Node VA) --> [ R1: 10 kΩ ] --> GND  |
                                     [ U1: 74HC7266 XNOR ] --(Node VOUT)--> [ R3: 330 Ω ] --> [ D1: Red LED ] --> GND
        (Node VB) --> [ R2: 10 kΩ ] --> GND  |
                                            |
VCC --> [ SW2: SPST ] --(Node VB)--> [ U1: Pin 2 (1B) ]

* Power & Unused Pins:
  VCC --> [ U1: Pin 14 (VCC) ]
  GND <-- [ U1: Pin 7 (GND) ]
  GND <-- [ U1: Pins 5, 6, 8, 9, 12, 13 (Unused Inputs) ]
Electrical Schematic

Electrical diagram

Electrical diagram for case: 1-bit equality detector
Generated from the validated SPICE netlist for this case.

Truth table

VA (Input A) VB (Input B) VOUT (Output) D1 (LED Status)
0 0 1 ON
0 1 0 OFF
1 0 0 OFF
1 1 1 ON

Measurements and tests

  1. Initial Power Verification: Before actuating any switches, power on the circuit. Measure the voltage between VCC and 0 to ensure it is 5 V.
  2. Input State Testing: Set your multimeter to DC Voltage. Measure nodes VA and VB with respect to node 0. Toggle SW1 and SW2 to verify that an open switch yields ~0 V (thanks to the pull-down resistors) and a closed switch yields ~5 V.
  3. XNOR Logic Verification: Measure the voltage at VOUT with respect to node 0 for all four combinations of SW1 and SW2.
  4. Equality Confirmation: Ensure VOUT is approximately 5 V and the LED is illuminated ONLY when VA and VB are perfectly matched (0 V & 0 V, or 5 V & 5 V).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: 1-bit equality detector
.width out=256

V1 VCC 0 DC 5

* Control signals for SW1 and SW2 to simulate user interaction
VctrlA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
VctrlB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)

* SW1 and SW2 modeled as voltage-controlled switches
S1 VCC VA ctrlA 0 SWMOD
S2 VCC VB ctrlB 0 SWMOD

* Pull-down resistors R1 and R2
R1 VA 0 10k
R2 VB 0 10k

* U1: 74HC7266 XNOR Gate equivalent
XU1 VOUT VA VB 0 VCC GATE

* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Practical case: 1-bit equality detector
.width out=256

V1 VCC 0 DC 5

* Control signals for SW1 and SW2 to simulate user interaction
VctrlA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
VctrlB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)

* SW1 and SW2 modeled as voltage-controlled switches
S1 VCC VA ctrlA 0 SWMOD
S2 VCC VB ctrlB 0 SWMOD

* Pull-down resistors R1 and R2
R1 VA 0 10k
R2 VB 0 10k

* U1: 74HC7266 XNOR Gate equivalent
XU1 VOUT VA VB 0 VCC GATE

* LED current limiting resistor R3
R3 VOUT D1_ANODE 330

* Equality indicator LED D1
D1 D1_ANODE 0 DLED

* Subcircuit for canonical 2-input XNOR gate
.subckt GATE out in1 in2 gnd vcc
B1 out gnd V = 5 * (1 / (1 + exp(-5 * (V(in1)-2.5) * (V(in2)-2.5))))
.ends

* Models
.model SWMOD SW(VT=2.5 VH=0.2 RON=0.1 ROFF=100MEG)
.model DLED D(IS=1e-15 N=2.0 RS=10)

* Simulation commands
.op
.tran 1u 500u
.print tran V(VOUT) V(VA) V(VB) V(D1_ANODE)
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 500 us and captures the switching interval. Main ranges: v(vout) 1.35e-07 uV -> 5 V; v(va) 500 uV -> 5 V; v(vb) 500 uV -> 5 V.
Show raw data table (694 rows)
Index   time            v(vout)         v(va)           v(vb)           v(d1_anode)
0	0.000000e+00	5.000000e+00	4.999500e-04	4.999500e-04	1.650722e+00
1	1.000000e-08	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
2	2.000000e-08	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
3	4.000000e-08	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
4	8.000000e-08	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
5	1.600000e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
6	3.200000e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
7	3.637500e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
8	4.403125e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
9	4.615039e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
10	4.985889e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
11	5.088535e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
12	5.268165e-07	5.000000e+00	4.999500e-04	4.999500e-04	1.650721e+00
13	5.467041e-07	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
14	5.864794e-07	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
15	6.660299e-07	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
16	8.251311e-07	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
17	1.000000e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
18	1.031820e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
19	1.095461e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
20	1.222742e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
21	1.477303e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
22	1.986427e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
23	2.986427e-06	5.000000e+00	4.999950e+00	4.999950e+00	1.650721e+00
... (670 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: 1-bit equality detector
.width out=256

V1 VCC 0 DC 5

* Control signals for SW1 and SW2 to simulate user interaction
VctrlA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
VctrlB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)

* SW1 and SW2 modeled as voltage-controlled switches
S1 VCC VA ctrlA 0 SWMOD
S2 VCC VB ctrlB 0 SWMOD

* Pull-down resistors R1 and R2
R1 VA 0 10k
R2 VB 0 10k

* U1: 74HC7266 XNOR Gate equivalent
XU1 VOUT VA VB 0 VCC GATE

* LED current limiting resistor R3
R3 VOUT D1_ANODE 330

* Equality indicator LED D1
D1 D1_ANODE 0 DLED

* Subcircuit for canonical 2-input XNOR gate
.subckt GATE out in1 in2 gnd vcc
B1 out gnd V = 5 * (1 / (1 + exp(-5 * (V(in1)-2.5) * (V(in2)-2.5))))
.ends

* Models
.model SWMOD SW(VT=2.5 VH=0.2 RON=0.1 ROFF=100MEG)
.model DLED D(IS=1e-15 N=2.0 RS=10)

* Simulation commands
.op
.tran 1u 500u
.print tran V(VOUT) V(VA) V(VB) V(D1_ANODE)
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 500 us and captures the switching interval. Main ranges: v(vout) 1.35e-07 uV -> 5 V; v(va) 500 uV -> 5 V; v(vb) 500 uV -> 5 V.

Common mistakes and how to avoid them

  • Confusing 74HC7266 with 74HC266: The 74HC266 has open-drain outputs, which means it cannot source current to turn on an LED without an external pull-up resistor. Ensure you use the 74HC7266 (push-pull) or add a pull-up resistor if using the 74HC266.
  • Leaving CMOS inputs floating: Forgetting to ground the unused inputs of the 74HC7266 can cause internal high-frequency oscillation, drawing excessive current and potentially damaging the IC. Always tie unused inputs to GND or VCC.
  • Omitting pull-down resistors: If R1 and R2 are forgotten, the inputs will float unpredictably when the switches are open, causing the LED to flicker randomly.


Troubleshooting

  • Symptom: LED flickers or behaves erratically when switches are open.
    • Cause: Node VA or VB is floating.
    • Fix: Verify that R1 and R2 are securely connected between the switch inputs and ground.
  • Symptom: LED never turns on.
    • Cause: LED D1 is inserted backwards (reversed polarity) or R3 is too large (e.g., 100 kΩ instead of 330 Ω).
    • Fix: Check the orientation of D1 (longer leg to D1_ANODE) and verify the value of R3.
  • Symptom: LED is always ON regardless of switch positions.
    • Cause: Output pin (3) is shorted to VCC, or both switches are permanently shorted to the same logic level.
    • Fix: Inspect the wiring around VOUT, VA, and VB. Ensure the switches physically break the connection to VCC when toggled off.

Possible improvements and extensions

  • Audible Equality Alert: Connect a 5 V active piezoelectric buzzer in parallel with the LED/resistor combination to provide an audible tone whenever the input bits match.
  • 2-Bit Equality Detector: Use a second XNOR gate from the same IC for a second pair of inputs, and feed the outputs of both XNOR gates into an AND gate to verify if two 2-bit words are exactly equal.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary function of the 74HC7266 IC in this circuit?




Question 2: What is the expected behavior of the LED when both inputs to the XNOR gate are LOW?




Question 3: What happens to the output LED when one input is HIGH and the other is LOW?




Question 4: In this circuit, what voltage approximately represents a logic HIGH?




Question 5: In this circuit, what voltage approximately represents a logic LOW?




Question 6: Which real-world application uses this circuit concept to compare an entered bit to a stored security key bit?




Question 7: How is the XNOR gate concept used in error detection according to the text?




Question 8: What is the main objective of this practical case?




Question 9: Who is the target audience for this practical case?




Question 10: In automation, how is the XNOR gate concept applied based on the text?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Sensor fault detector

Sensor fault detector prototype (Maker Style)

Level: Basic – Implement an XOR gate circuit to activate a visual alarm when two redundant sensors present different logic states.

Objective and use case

You will build a digital logic comparator circuit using a 74LS86 XOR (Exclusive-OR) gate to monitor two redundant switches acting as system sensors. The circuit evaluates the inputs continuously and activates a visual LED alarm only when the two sensors report conflicting states, indicating a potential sensor failure.

This circuit is highly useful in practical scenarios such as:
* Industrial automation, for monitoring dual-redundant safety limit switches on heavy machinery.
* Aerospace and aviation control systems, to detect disagreements between redundant flight sensors.
* Basic logic fault-detection training for maintenance and electronics technicians.

Expected outcome:
* A high output logic level (VOUT > 2.4 V) triggering the LED when the sensor states do not match.
* A low output logic level (VOUT < 0.4 V) keeping the LED turned off when both sensors agree (both HIGH or both LOW).
* A clear, immediate visual indication of logic discrepancies to the operator.

Target audience: Basic-level students learning digital logic gates, boolean algebra, and redundancy systems.

Materials

  • V1: 5 V DC supply, function: primary power source
  • SW1: SPST switch, function: redundant sensor A simulator
  • SW2: SPST switch, function: redundant sensor B simulator
  • R1: 10 kΩ resistor, function: pull-down for VA
  • R2: 10 kΩ resistor, function: pull-down for VB
  • R3: 330 Ω resistor, function: LED current limiting
  • U1: 74LS86 Quad 2-Input Exclusive-OR Gate, function: fault detection logic
  • D1: red LED, function: visual fault alarm indicator

Pin-out of the IC used

Integrated Circuit: 74LS86

Pin Name Logic function Connection in this case
1 1 A Input 1 for Gate 1 Node VA (from SW1)
2 1B Input 2 for Gate 1 Node VB (from SW2)
3 1Y Output of Gate 1 Node VOUT (to R3 and D1)
7 GND Ground Node 0 (GND)
14 VCC Power Supply Node VCC (5 V)

Note: Pins 4, 5, 6, 8, 9, 10, 11, 12, and 13 belong to the other three unused XOR gates. It is highly recommended to tie unused inputs (pins 4, 5, 9, 10, 12, 13) to Node 0 (GND).

Wiring guide

  • V1: connects between VCC and 0.
  • SW1: connects between VCC and VA.
  • SW2: connects between VCC and VB.
  • R1: connects between VA and 0.
  • R2: connects between VB and 0.
  • U1: connects Pin 14 to VCC, Pin 7 to 0, Pin 1 to VA, Pin 2 to VB, and Pin 3 to VOUT.
  • R3: connects between VOUT and VLED.
  • D1: connects its anode to VLED and its cathode to 0.

Conceptual block diagram

Conceptual block diagram — COMPUERTA XOR gate
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

VCC --> [ SW1: Sensor A ] --(VA)-->
              |                   |
              v                   v
        [ R1: 10 kΩ ]            [ U1: 74LS86 XOR Gate ] --(VOUT)--> [ R3: 330 Ω ] --(VLED)--> [ D1: Red LED ] --> GND
              |                   ^
              v                   |
             GND                  |
                                  |
VCC --> [ SW2: Sensor B ] --(VB)-->
              |
              v
        [ R2: 10 kΩ ]
              |
              v
             GND
Electrical Schematic

Electrical diagram

Electrical diagram for case: Sensor fault detector
Generated from the validated SPICE netlist for this case.

Truth table

Sensor A (Node VA) Sensor B (Node VB) Output (Node VOUT) Alarm State (D1) System Status
0 0 0 OFF Normal (Agreement)
0 1 1 ON Fault (Disagreement)
1 0 1 ON Fault (Disagreement)
1 1 0 OFF Normal (Agreement)

Measurements and tests

  1. System Normal (Low): Leave both SW1 and SW2 open. Measure the voltage at nodes VA and VB with a multimeter; both should read 0 V. Measure VOUT; it should be < 0.4 V. The LED D1 must be OFF.
  2. Sensor A Fault: Close SW1 (applying 5 V to VA) while leaving SW2 open (0 V at VB). Measure VOUT; it should read > 2.4 V. The LED D1 must turn ON.
  3. Sensor B Fault: Open SW1 (0 V at VA) and close SW2 (applying 5 V to VB). Measure VOUT; it should read > 2.4 V. The LED D1 must turn ON.
  4. System Normal (High): Close both SW1 and SW2 so that both VA and VB read 5 V. Measure VOUT; it should drop back to < 0.4 V. The LED D1 must be OFF.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Sensor fault detector
.width out=256

* Main Power Supply
V1 VCC 0 DC 5

* Redundant Sensor A Simulator (Switch 1)
VCTRLA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
S1 VCC VA ctrlA 0 SWMOD

* Redundant Sensor B Simulator (Switch 2)
VCTRLB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)
S2 VCC VB ctrlB 0 SWMOD

* Pull-down Resistors for Inputs
R1 VA 0 10k
R2 VB 0 10k

* Fault Detection Logic (74LS86 XOR Gate)
XU1 VOUT VA VB 0 VCC GATE
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Practical case: Sensor fault detector
.width out=256

* Main Power Supply
V1 VCC 0 DC 5

* Redundant Sensor A Simulator (Switch 1)
VCTRLA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
S1 VCC VA ctrlA 0 SWMOD

* Redundant Sensor B Simulator (Switch 2)
VCTRLB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)
S2 VCC VB ctrlB 0 SWMOD

* Pull-down Resistors for Inputs
R1 VA 0 10k
R2 VB 0 10k

* Fault Detection Logic (74LS86 XOR Gate)
XU1 VOUT VA VB 0 VCC GATE

* Visual Fault Alarm Indicator (LED and Current Limiting Resistor)
R3 VOUT VLED 330
D1 VLED 0 DLED

* Component Models
.model SWMOD SW(VT=2.5 VH=0.2 RON=0.1 ROFF=100MEG)
.model DLED D(IS=1e-15 N=1.5 RS=10)

* XOR Gate Behavioural Subcircuit
* Continuous implementation to ensure robust convergence
.subckt GATE out in1 in2 gnd vcc
B1 out gnd V = V(vcc) * ( 1/(1+exp(-50*(V(in1)-2.5))) + 1/(1+exp(-50*(V(in2)-2.5))) - 2 * (1/(1+exp(-50*(V(in1)-2.5)))) * (1/(1+exp(-50*(V(in2)-2.5)))) )
.ends

* Simulation Directives
.tran 1u 400u
.print tran V(VA) V(VB) V(VOUT) V(VLED)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient simulation shows the XOR logic functioning correctly. When VA and VB are both low (~0V) or both high (~5V), VOUT is ~0V and VLED is ~0V (LED off). When VA and VB differ (one is ~5V, the other ~0V), VOUT goes to 5V and VLED reaches ~1.28V, indicating the LED is forward-biased and turned on, matching the truth table.
Show raw data table (562 rows)
Index   time            v(va)           v(vb)           v(vout)         v(vled)
0	0.000000e+00	4.999500e-04	4.999500e-04	5.297196e-54	9.094010e-30
1	1.000000e-08	4.999500e-04	4.999500e-04	5.297196e-54	7.969517e-41
2	2.000000e-08	4.999500e-04	4.999500e-04	5.297196e-54	-7.96952e-41
3	4.000000e-08	4.999500e-04	4.999500e-04	5.297196e-54	-3.48674e-51
4	8.000000e-08	4.999500e-04	4.999500e-04	5.297196e-54	1.402111e-51
5	1.600000e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
6	3.200000e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
7	3.637500e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
8	4.403125e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
9	4.615039e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
10	4.985889e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
11	5.088535e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
12	5.268165e-07	4.999500e-04	4.999500e-04	5.297196e-54	5.297196e-54
13	5.467041e-07	4.999950e+00	4.999950e+00	1.329451e-51	1.329451e-51
14	5.864794e-07	4.999950e+00	4.999950e+00	-2.81145e-68	3.383370e-62
15	6.660299e-07	4.999950e+00	4.999950e+00	-2.81145e-68	-2.26159e-62
16	8.251311e-07	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81157e-68
17	1.000000e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81143e-68
18	1.031820e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81145e-68
19	1.095461e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81145e-68
20	1.222742e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81145e-68
21	1.477303e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81145e-68
22	1.986427e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81145e-68
23	2.986427e-06	4.999950e+00	4.999950e+00	-2.81145e-68	-2.81145e-68
... (538 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: Sensor fault detector
.width out=256

* Main Power Supply
V1 VCC 0 DC 5

* Redundant Sensor A Simulator (Switch 1)
VCTRLA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
S1 VCC VA ctrlA 0 SWMOD

* Redundant Sensor B Simulator (Switch 2)
VCTRLB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)
S2 VCC VB ctrlB 0 SWMOD

* Pull-down Resistors for Inputs
R1 VA 0 10k
R2 VB 0 10k

* Fault Detection Logic (74LS86 XOR Gate)
XU1 VOUT VA VB 0 VCC GATE

* Visual Fault Alarm Indicator (LED and Current Limiting Resistor)
R3 VOUT VLED 330
D1 VLED 0 DLED

* Component Models
.model SWMOD SW(VT=2.5 VH=0.2 RON=0.1 ROFF=100MEG)
.model DLED D(IS=1e-15 N=1.5 RS=10)

* XOR Gate Behavioural Subcircuit
* Continuous implementation to ensure robust convergence
.subckt GATE out in1 in2 gnd vcc
B1 out gnd V = V(vcc) * ( 1/(1+exp(-50*(V(in1)-2.5))) + 1/(1+exp(-50*(V(in2)-2.5))) - 2 * (1/(1+exp(-50*(V(in1)-2.5)))) * (1/(1+exp(-50*(V(in2)-2.5)))) )
.ends

* Simulation Directives
.tran 1u 400u
.print tran V(VA) V(VB) V(VOUT) V(VLED)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient simulation shows the XOR logic functioning correctly. When VA and VB are both low (~0V) or both high (~5V), VOUT is ~0V and VLED is ~0V (LED off). When VA and VB differ (one is ~5V, the other ~0V), VOUT goes to 5V and VLED reaches ~1.28V, indicating the LED is forward-biased and turned on, matching the truth table.

Common mistakes and how to avoid them

  • Forgetting pull-down resistors: Connecting the switches directly to the IC without R1 and R2 leaves the inputs floating when the switches are open, causing unpredictable behavior and false alarms. Always use pull-down resistors.
  • LED polarity reversal: Putting the LED in backward (cathode to VLED, anode to 0) will prevent it from lighting up even when a fault is detected. Verify the flat edge or shorter leg is connected to ground.
  • Leaving unused inputs floating: The 74LS86 contains four XOR gates. Leaving the inputs of the unused gates disconnected can cause internal oscillation and increase power consumption. Tie unused inputs to ground (0).


Troubleshooting

  • Symptom: The LED never turns on under any switch combination.
    • Cause: Faulty LED, backward LED polarity, broken R3 connection, or missing VCC/GND to the chip.
    • Fix: Check D1 orientation. Verify 5 V at Pin 14 and 0 V at Pin 7 of U1.
  • Symptom: The LED is always on, even when both switches are open or both are closed.
    • Cause: One of the inputs is floating (missing pull-down resistor R1 or R2), or a switch is wired incorrectly.
    • Fix: Check continuity on R1 and R2 to ground. Verify the voltages at VA and VB correspond strictly to the truth table.
  • Symptom: The LED lights up correctly but is very dim.
    • Cause: The 74LS series has weak current sourcing capabilities compared to modern CMOS chips, or the value of R3 is too high.
    • Fix: Reduce R3 slightly (e.g., to 220 Ω), or see the extensions below for a better way to drive the LED.

Possible improvements and extensions

  • Active-low output configuration: Since TTL chips (like the 74LS series) are much better at sinking current than sourcing it, rewire the LED so the anode goes to 5 V (through R3) and the cathode goes to VOUT. Note: you will need to add a NOT gate (e.g., 74LS04) after the XOR to invert the logic so the LED still turns on only during a fault.
  • Audible alarm integration: Add an NPN transistor (like a 2N2222) connected to the XOR output via a base resistor. Use the transistor to drive a 5 V buzzer to provide both audible and visual alerts when the sensors disagree.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary purpose of the XOR gate circuit described in the text?




Question 2: Which specific logic gate IC is used in this circuit?




Question 3: What does it indicate when the LED alarm is activated?




Question 4: In which of the following practical scenarios is this circuit highly useful?




Question 5: What is the expected high output logic level (VOUT) required to trigger the LED?




Question 6: According to the circuit diagram, what is the resistance value of the pull-down resistors R1 and R2?




Question 7: What is the purpose of resistor R3 (330 Ω) in the circuit?




Question 8: Based on the truth table, what happens when Sensor A is 1 and Sensor B is 1?



Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Security alarm with NOR

Security alarm with NOR prototype (Maker Style)

Level: Basic | Objective: Verify the NOR gate truth table using an alarm circuit that activates only when no sensors detect movement.

Objective and use case

We will build a simple security alarm simulator using a 74HC02 NOR gate. In this system, the alarm (an LED) will illuminate only when all connected monitoring sensors (represented by switches) indicate a safe, undisturbed state (Logic 0).

Why it is useful:
* Demonstrates negative logic applications where the absence of inputs is required to trigger an action.
* Provides practical experience with CMOS logic gate behavior and logic-level thresholds.
* Mimics real-world safety interlocks, such as machine guards, where multiple conditions must be false for the system to operate.
* Introduces the essential use of pull-down resistors to ensure stable, predictable logic states.

Expected outcome:
* The output LED will illuminate only when both sensor switches are open (Logic 0, 0 V).
* The output LED will turn off immediately if either or both switches are closed (Logic 1, 5 V).
* Input voltages will measure close to 0 V when switches are open, and near 5 V when closed.
* The output voltage will strictly follow the theoretical truth table of a NOR logic gate.

Target audience: Beginners in digital electronics learning fundamental logic gates and basic control circuits.

Materials

  • V1: 5 V DC power supply
  • U1: 74HC02 Quad 2-Input NOR Gate
  • SW1: SPST switch, function: sensor A input
  • SW2: SPST switch, function: sensor B input
  • R1: 10 kΩ resistor, function: pull-down for VA
  • R2: 10 kΩ resistor, function: pull-down for VB
  • R3: 330 Ω resistor, function: LED current limiting
  • D1: Red LED, function: alarm active indicator

Pin-out of the IC used

IC Selected: 74HC02

Pin Name Logic function Connection in this case
1 1Y Output of Gate 1 Connects to VOUT
2 1 A Input A of Gate 1 Connects to VA
3 1B Input B of Gate 1 Connects to VB
7 GND Ground reference Connects to 0
14 VCC Positive supply voltage Connects to VCC

(Note: Pins 4, 5, 6, 8, 9, 10, 11, 12, and 13 belong to the unused gates in the IC package and should ideally have their inputs tied to ground in a permanent design to prevent CMOS floating states).

Wiring guide

  • V1: Connects between VCC and 0.
  • U1 (Pin 14): Connects to VCC.
  • U1 (Pin 7): Connects to 0.
  • SW1: Connects between VCC and VA.
  • SW2: Connects between VCC and VB.
  • R1: Connects between VA and 0.
  • R2: Connects between VB and 0.
  • U1 (Pin 2): Connects to VA.
  • U1 (Pin 3): Connects to VB.
  • U1 (Pin 1): Connects to VOUT.
  • R3: Connects between VOUT and D1_A.
  • D1: Connects between D1_A (anode) and 0 (cathode).

Conceptual block diagram

Conceptual block diagram — COMPUERTA 74HC02 NOR Logic
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

VCC   GND
                                           |     |
                                        (Pin14)(Pin7)
VCC --> [ SW1: Sensor A ] --(VA)--> [                   ]
[ VA ] ---> [ R1: 10 kΩ ] ---> GND   [ Pin 2             ]
                                    [ U1: 74HC02 NOR    ] --(Pin 1: VOUT)--> [ R3: 330 Ω ] --> [ D1: Red LED ] --> GND
VCC --> [ SW2: Sensor B ] --(VB)--> [ Pin 3             ]
[ VB ] ---> [ R2: 10 kΩ ] ---> GND   [                   ]
Electrical Schematic

Electrical diagram

Electrical diagram for case: Security alarm with NOR
Generated from the validated SPICE netlist for this case.

Truth table

Input A (VA) Input B (VB) Output Y (VOUT) Alarm State
0 0 1 LED ON
0 1 0 LED OFF
1 0 0 LED OFF
1 1 0 LED OFF

Measurements and tests

  1. Power verification: With the power supply connected, use a multimeter to measure the voltage between nodes VCC and 0. Ensure it is strictly 5 V.
  2. Idle state test (0, 0): Leave both SW1 and SW2 open. Measure nodes VA and VB with respect to ground; they should be 0 V. Measure VOUT; it should read near 5 V, and the LED should be ON.
  3. Single sensor test (1, 0 / 0, 1): Close SW1 (leaving SW2 open). Measure VA; it should be 5 V. Measure VOUT; it should immediately drop to 0 V, and the LED should turn OFF. Repeat by opening SW1 and closing SW2.
  4. Dual sensor test (1, 1): Close both SW1 and SW2. Confirm both VA and VB measure 5 V. Measure VOUT to verify it remains 0 V (LED OFF).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Security alarm with NOR
.width out=256

* Power supply
V1 VCC 0 DC 5

* Dynamic stimuli for user pressing the switches
VctrlA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
VctrlB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)

* Switches representing SW1 and SW2
SW1 VCC VA ctrlA 0 SWMOD
SW2 VCC VB ctrlB 0 SWMOD
.model SWMOD SW(VT=2.5 VH=0.2 RON=1 ROFF=100MEG)

* Pull-down resistors
R1 VA 0 10k
R2 VB 0 10k

* NOR Gate 74HC02 (U1)
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Practical case: Security alarm with NOR
.width out=256

* Power supply
V1 VCC 0 DC 5

* Dynamic stimuli for user pressing the switches
VctrlA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
VctrlB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)

* Switches representing SW1 and SW2
SW1 VCC VA ctrlA 0 SWMOD
SW2 VCC VB ctrlB 0 SWMOD
.model SWMOD SW(VT=2.5 VH=0.2 RON=1 ROFF=100MEG)

* Pull-down resistors
R1 VA 0 10k
R2 VB 0 10k

* NOR Gate 74HC02 (U1)
* Pins: 1=VOUT, 2=VA, 3=VB, 7=0, 14=VCC
XU1 VOUT VA VB 0 VCC NOR2

* Output components
R3 VOUT D1_A 330
D1 D1_A 0 DLED

* Models
.model DLED D(IS=1e-19 N=1.6 RS=10)

* Subcircuits
.subckt NOR2 out in1 in2 gnd vcc
* Robust continuous behavior for NOR logic
B1 out gnd V = V(vcc) * (1 / (1 + exp(20*(V(in1)-2.5)))) * (1 / (1 + exp(20*(V(in2)-2.5))))
.ends

* Analysis
.tran 1u 300u
.print tran V(VA) V(VB) V(VOUT) V(D1_A)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 300 us and captures the switching interval. Main ranges: v(vout) 1.9e-37 uV -> 5 V; v(va) 500 uV -> 5 V; v(vb) 500 uV -> 5 V.
Show raw data table (417 rows)
Index   time            v(va)           v(vb)           v(vout)         v(d1_a)
0	0.000000e+00	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
1	1.000000e-08	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
2	2.000000e-08	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
3	4.000000e-08	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
4	8.000000e-08	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
5	1.600000e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
6	3.200000e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
7	3.637500e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
8	4.403125e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
9	4.615039e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
10	4.985889e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
11	5.088535e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
12	5.268165e-07	4.999500e-04	4.999500e-04	5.000000e+00	1.719109e+00
13	5.467041e-07	4.999500e+00	4.999500e+00	1.897609e-43	8.840581e-30
14	5.864794e-07	4.999500e+00	4.999500e+00	1.897609e-43	3.298742e-17
15	6.660299e-07	4.999500e+00	4.999500e+00	1.897609e-43	7.028545e-34
16	8.251311e-07	4.999500e+00	4.999500e+00	1.897609e-43	7.526757e-34
17	1.000000e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897616e-43
18	1.031820e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897608e-43
19	1.095461e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897609e-43
20	1.222742e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897609e-43
21	1.477303e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897609e-43
22	1.986427e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897609e-43
23	2.986427e-06	4.999500e+00	4.999500e+00	1.897609e-43	1.897609e-43
... (393 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: Security alarm with NOR
.width out=256

* Power supply
V1 VCC 0 DC 5

* Dynamic stimuli for user pressing the switches
VctrlA ctrlA 0 PULSE(0 5 0 1u 1u 50u 100u)
VctrlB ctrlB 0 PULSE(0 5 0 1u 1u 100u 200u)

* Switches representing SW1 and SW2
SW1 VCC VA ctrlA 0 SWMOD
SW2 VCC VB ctrlB 0 SWMOD
.model SWMOD SW(VT=2.5 VH=0.2 RON=1 ROFF=100MEG)

* Pull-down resistors
R1 VA 0 10k
R2 VB 0 10k

* NOR Gate 74HC02 (U1)
* Pins: 1=VOUT, 2=VA, 3=VB, 7=0, 14=VCC
XU1 VOUT VA VB 0 VCC NOR2

* Output components
R3 VOUT D1_A 330
D1 D1_A 0 DLED

* Models
.model DLED D(IS=1e-19 N=1.6 RS=10)

* Subcircuits
.subckt NOR2 out in1 in2 gnd vcc
* Robust continuous behavior for NOR logic
B1 out gnd V = V(vcc) * (1 / (1 + exp(20*(V(in1)-2.5)))) * (1 / (1 + exp(20*(V(in2)-2.5))))
.ends

* Analysis
.tran 1u 300u
.print tran V(VA) V(VB) V(VOUT) V(D1_A)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 300 us and captures the switching interval. Main ranges: v(vout) 1.9e-37 uV -> 5 V; v(va) 500 uV -> 5 V; v(vb) 500 uV -> 5 V.

Common mistakes and how to avoid them

  1. Misinterpreting the 74HC02 pinout: Unlike standard AND/OR gates (where pins 1 and 2 are inputs and 3 is the output), the 74HC02 has its output on Pin 1, and inputs on Pins 2 and 3. Wiring it like a 74HC08 will result in short circuits and component failure.
  2. Floating inputs (Missing pull-down resistors): Omitting R1 or R2 leaves the CMOS inputs floating when the switches are open. This causes the output to oscillate or randomly toggle based on environmental electromagnetic noise. Always ensure your inputs have a defined path to ground.
  3. Reversing LED polarity: Connecting the LED backwards (anode to ground) will prevent it from lighting up, even if the gate outputs a correct 5 V Logic 1 state.


Troubleshooting

  • Symptom: LED is always OFF, even when both switches are open.
  • Cause: Floating inputs acting as logic HIGH, or an incorrect wiring to Pin 1 (Output).
  • Fix: Verify R1 and R2 are properly connected between the input nodes (VA, VB) and ground (0). Double-check that the LED is connected to Pin 1, not Pin 3.
  • Symptom: IC becomes excessively hot to the touch.
  • Cause: Power pins (VCC and 0) are reversed, or an output pin is directly shorted to ground or VCC.
  • Fix: Instantly disconnect power. Verify Pin 14 goes strictly to VCC and Pin 7 goes strictly to 0.
  • Symptom: The alarm triggers (LED turns ON) when any switch is closed, rather than when they are open.
  • Cause: Using an OR gate (74HC32) instead of a NOR gate (74HC02), or using pull-up resistors instead of pull-downs.
  • Fix: Check the markings on the IC package to ensure it is a 74HC02, and verify R1 and R2 are wired to ground (0).

Possible improvements and extensions

  1. Audible Alarm Integration: Replace or parallel the indicator LED with a low-current 5 V active piezo buzzer to create a more realistic security warning system.
  2. System Expansion: Cascade multiple NOR gates or combine them with OR gates to expand the system from a 2-sensor alarm to a 4-sensor setup, keeping the rule that no sensors must be active to trigger the output.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the main objective of the circuit described in the article?




Question 2: Which specific logic gate IC is used to build the security alarm simulator?




Question 3: Under what condition will the alarm (LED) illuminate in this circuit?




Question 4: What type of logic application does this circuit primarily demonstrate?




Question 5: What is the essential purpose of using pull-down resistors in this circuit?




Question 6: What real-world application is mimicked by this NOR gate circuit?




Question 7: What is the expected output state when both sensor switches are open?




Question 8: What happens to the output LED if either or both switches are closed?




Question 9: What is the approximate input voltage when a switch is closed?




Question 10: What is the approximate input voltage when a switch is open?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: NE555 Delay-On Timer for READY Indicator

NE555 Delay-On Timer for READY Indicator prototype (Maker Style)

Level: Basic – Build an RC-timed delay circuit to activate a READY indicator seconds after power is applied.

Objective and use case

In this practical case, you will build a delay-on timer using the versatile NE555 integrated circuit. Upon applying 5 V power, an RC network dictates a waiting period before the timer’s output activates and turns on a «READY» LED.

This timer topology is highly useful in real-world applications:
* Audio amplifiers: Delaying speaker connection until internal voltages stabilize to prevent loud popping noises.
* Power supply sequencing: Ensuring primary rails are fully powered before activating secondary logic circuits.
* Microcontroller resets: Holding a reset line active for a brief period during startup to guarantee clean initialization.

Expected outcome:
* At power-on ($t=0$), the LED will remain OFF.
* The voltage at the timing node (VCAP) will exponentially decay from 5 V down to 1.66 V (which is 1/3 VCC).
* Once VCAP crosses the 1.66 V threshold, the NE555 output (VOUT) will snap from 0 V to 5 V (HIGH), illuminating the LED.
* The delay time will be approximately 5.1 seconds.

Target audience and level: Beginners learning analog-digital timing and RC time constants.

Materials

  • U1: NE555 timer IC, function: timing controller
  • R1: 100 kΩ resistor, function: timing resistor
  • C1: 47 µF electrolytic capacitor, function: timing capacitor
  • R2: 330 Ω resistor, function: LED current limiting
  • C2: 10 nF ceramic capacitor, function: control voltage stabilization
  • D1: green LED, function: READY indicator
  • V1: 5 V DC supply

Pin-out of the IC used

NE555 Timer IC

Pin Name Logic/Analog function Connection in this case
1 GND Ground reference Node 0
2 TRIG Trigger input (active low, < 1/3 VCC) Node VCAP
3 OUT Output Node VOUT
4 RESET Reset input (active low) Node VCC
5 CTRL Control voltage access Node VCTRL
6 THR Threshold input (active high, > 2/3 VCC) Node VCAP
7 DISCH Discharge open-collector Not connected
8 VCC Supply voltage Node VCC

Wiring guide

  • V1: connects between VCC (+5 V) and 0 (GND).
  • C1: connects between VCC (positive leg) and VCAP (negative leg).
  • R1: connects between VCAP and 0.
  • U1 connections:
  • Pin 1 (GND) connects to 0.
  • Pin 2 (TRIG) connects to VCAP.
  • Pin 3 (OUT) connects to VOUT.
  • Pin 4 (RESET) connects to VCC.
  • Pin 5 (CTRL) connects to VCTRL.
  • Pin 6 (THR) connects to VCAP.
  • Pin 8 (VCC) connects to VCC.
  • C2: connects between VCTRL and 0.
  • R2: connects between VOUT and VLED.
  • D1: connects between VLED (anode) and 0 (cathode).

Conceptual block diagram

Conceptual block diagram — NE555 NE555 Timer
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

[ VCC: 5 V ] --> [ C1: 47µF ] --(VCAP)--> [ U1: NE555 Timer ] --(VOUT)--> [ R2: 330 Ω ] --(VLED)--> [ D1: Green LED ] --> GND
                                         [ Pin 2: TRIG     ]
[ VCAP Node ] -> [ R1: 100 kΩ ] -> GND    [ Pin 6: THR      ]
                                         [ Pin 4: RESET    ] <--- [ VCC: 5 V ]
                                         [ Pin 8: VCC      ] <--- [ VCC: 5 V ]
                                         [ Pin 5: CTRL     ] --(VCTRL)--> [ C2: 10nF ] --> GND
                                         [ Pin 1: GND      ] ---> GND
Electrical Schematic

Measurements and tests

To validate the transient behavior of this delay-on timer, perform the following steps:

  1. Initial State Verification: Ensure power is completely disconnected. Use a multimeter or oscilloscope to confirm that VCAP and VOUT are at 0 V.
  2. Apply Power: Turn on the 5 V supply (V1). Start a stopwatch immediately. Verify that VOUT is initially ~0 V and the LED is OFF.
  3. Transient Validation of VCAP: Measure the voltage at node VCAP with respect to ground (0). Because the capacitor C1 is tied to VCC, it acts as a short circuit at $t=0$, pulling VCAP to 5 V. As C1 charges through R1, observe VCAP exponentially decaying toward 0 V.
  4. Trigger Threshold: Monitor VCAP as it drops. Exactly as it crosses 1.66 V (1/3 of VCC), verify that VOUT instantly jumps to 5 V and the READY LED illuminates.
  5. Timing Calculation: Verify the elapsed time. The theoretical delay for this configuration is calculated as T ≈ 1.1 × R × C. With 100 kΩ and 47 µF, T ≈ 5.17 seconds. Check that your measured time aligns with this estimate.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: NE555 Delay-On Timer for READY Indicator
.width out=256

* Power Supply (Pulse to simulate power-on and provide dynamic stimulus)
V1 VCC 0 PULSE(0 5 0 100u 100u 10 10)

* Timing Capacitor and Resistor
C1 VCC VCAP 47uF
R1 VCAP 0 100k

* Control Voltage Stabilization Capacitor
C2 VCTRL 0 10nF

* Output Current Limiting Resistor and LED
R2 VOUT VLED 330
D1 VLED 0 DLED

* NE555 Timer IC Instantiation
* Wiring: Pin 1 (GND)=0, Pin 2 (TRIG)=VCAP, Pin 3 (OUT)=VOUT, Pin 4 (RESET)=VCC, Pin 5 (CTRL)=VCTRL, Pin 6 (THR)=VCAP, Pin 8 (VCC)=VCC
XU1 0 VCAP VOUT VCC VCTRL VCAP VCC NE555
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Practical case: NE555 Delay-On Timer for READY Indicator
.width out=256

* Power Supply (Pulse to simulate power-on and provide dynamic stimulus)
V1 VCC 0 PULSE(0 5 0 100u 100u 10 10)

* Timing Capacitor and Resistor
C1 VCC VCAP 47uF
R1 VCAP 0 100k

* Control Voltage Stabilization Capacitor
C2 VCTRL 0 10nF

* Output Current Limiting Resistor and LED
R2 VOUT VLED 330
D1 VLED 0 DLED

* NE555 Timer IC Instantiation
* Wiring: Pin 1 (GND)=0, Pin 2 (TRIG)=VCAP, Pin 3 (OUT)=VOUT, Pin 4 (RESET)=VCC, Pin 5 (CTRL)=VCTRL, Pin 6 (THR)=VCAP, Pin 8 (VCC)=VCC
XU1 0 VCAP VOUT VCC VCTRL VCAP VCC NE555

* LED Model
.model DLED D(IS=1e-15 N=2.0 RS=10)

* NE555 Subcircuit (Robust Continuous Behavioral Model)
.subckt NE555 GND TRIG OUT RESET CTRL THR VCC
* Internal voltage divider
R1 VCC CTRL 5k
R2 CTRL N1 5k
R3 N1 GND 5k

* Smooth Comparators using tanh to prevent convergence issues
B_TH COMP_TH GND V=0.5*(1+tanh((V(THR)-V(CTRL))*100))
B_TR COMP_TR GND V=0.5*(1+tanh((V(N1)-V(TRIG))*100))
B_RST RST_INT GND V=0.5*(1+tanh((0.7-V(RESET))*100))

* Continuous SR Latch State Equation
B_Q Q_IN GND V=V(COMP_TR) + V(Q_OUT)*(1-V(COMP_TH)) - V(RST_INT)
R4 Q_IN Q_NODE 1k
C3 Q_NODE GND 1nF
B_Q_OUT Q_OUT GND V=0.5*(1+tanh((V(Q_NODE)-0.5)*10))

* Output stage with small series resistance
B_OUT OUT_INT GND V=V(VCC)*V(Q_OUT)
R_OUT OUT_INT OUT 10
.ends

* Transient Analysis
.op
.tran 10m 10
.print tran V(VCC) V(VOUT) V(VCAP) V(VLED) V(VCTRL)

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 10 s and captures the switching interval. Main ranges: v(vout) -4.47e-08 uV -> 4.9 V; v(vctrl) 0 uV -> 3.33 V; v(vcap) 0 uV -> 5 V.
Show raw data table (1048 rows)
Index   time            v(vcc)          v(vout)         v(vcap)         v(vled)         v(vctrl)
0	0.000000e+00	0.000000e+00	4.832629e-31	0.000000e+00	1.643094e-29	0.000000e+00
1	1.000000e-06	5.000000e-02	2.776793e-25	4.999999e-02	2.777048e-25	9.708738e-04
2	1.084000e-06	5.420000e-02	5.111901e-13	5.419999e-02	5.111901e-13	1.059260e-03
3	1.252000e-06	6.260000e-02	2.888571e-13	6.259999e-02	2.888571e-13	1.249666e-03
4	1.588000e-06	7.940000e-02	1.193784e-13	7.939999e-02	1.193784e-13	1.711860e-03
5	2.260000e-06	1.130000e-01	3.159549e-15	1.130000e-01	3.159549e-15	2.957719e-03
6	3.604000e-06	1.802000e-01	-4.46777e-14	1.801999e-01	-4.46777e-14	6.703556e-03
7	5.753920e-06	2.876960e-01	1.153350e-14	2.876958e-01	1.153350e-14	1.602982e-02
8	8.529919e-06	4.264960e-01	3.920905e-14	4.264956e-01	3.920905e-14	3.378163e-02
9	1.323373e-05	6.616863e-01	6.229971e-14	6.616853e-01	6.229971e-14	7.714122e-02
10	1.776006e-05	8.880031e-01	7.679640e-08	8.880014e-01	7.679640e-08	1.330167e-01
11	2.207156e-05	1.103578e+00	4.718975e-04	1.103575e+00	4.718975e-04	1.975078e-01
12	2.551739e-05	1.275870e+00	3.176107e-05	1.275866e+00	3.176107e-05	2.560560e-01
13	2.635388e-05	1.317694e+00	4.676638e-05	1.317690e+00	4.676638e-05	2.711361e-01
14	2.687674e-05	1.343837e+00	5.278079e-05	1.343833e+00	5.278079e-05	2.807240e-01
15	2.751921e-05	1.375961e+00	5.781702e-05	1.375957e+00	5.781702e-05	2.926720e-01
16	2.815313e-05	1.407657e+00	6.142719e-05	1.407652e+00	6.142719e-05	3.046382e-01
17	2.880258e-05	1.440129e+00	6.412060e-05	1.440125e+00	6.412060e-05	3.170766e-01
18	2.949081e-05	1.474541e+00	6.629097e-05	1.474536e+00	6.629097e-05	3.304515e-01
19	3.016263e-05	1.508132e+00	6.813606e-05	1.508127e+00	6.813606e-05	3.436961e-01
20	3.083350e-05	1.541675e+00	6.982103e-05	1.541670e+00	6.982103e-05	3.571040e-01
21	3.149330e-05	1.574665e+00	7.140022e-05	1.574660e+00	7.140022e-05	3.704649e-01
22	3.216372e-05	1.608186e+00	7.296437e-05	1.608181e+00	7.296437e-05	3.842142e-01
23	3.283050e-05	1.641525e+00	7.449937e-05	1.641519e+00	7.449937e-05	3.980585e-01
... (1024 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: NE555 Delay-On Timer for READY Indicator
.width out=256

* Power Supply (Pulse to simulate power-on and provide dynamic stimulus)
V1 VCC 0 PULSE(0 5 0 100u 100u 10 10)

* Timing Capacitor and Resistor
C1 VCC VCAP 47uF
R1 VCAP 0 100k

* Control Voltage Stabilization Capacitor
C2 VCTRL 0 10nF

* Output Current Limiting Resistor and LED
R2 VOUT VLED 330
D1 VLED 0 DLED

* NE555 Timer IC Instantiation
* Wiring: Pin 1 (GND)=0, Pin 2 (TRIG)=VCAP, Pin 3 (OUT)=VOUT, Pin 4 (RESET)=VCC, Pin 5 (CTRL)=VCTRL, Pin 6 (THR)=VCAP, Pin 8 (VCC)=VCC
XU1 0 VCAP VOUT VCC VCTRL VCAP VCC NE555

* LED Model
.model DLED D(IS=1e-15 N=2.0 RS=10)

* NE555 Subcircuit (Robust Continuous Behavioral Model)
.subckt NE555 GND TRIG OUT RESET CTRL THR VCC
* Internal voltage divider
R1 VCC CTRL 5k
R2 CTRL N1 5k
R3 N1 GND 5k

* Smooth Comparators using tanh to prevent convergence issues
B_TH COMP_TH GND V=0.5*(1+tanh((V(THR)-V(CTRL))*100))
B_TR COMP_TR GND V=0.5*(1+tanh((V(N1)-V(TRIG))*100))
B_RST RST_INT GND V=0.5*(1+tanh((0.7-V(RESET))*100))

* Continuous SR Latch State Equation
B_Q Q_IN GND V=V(COMP_TR) + V(Q_OUT)*(1-V(COMP_TH)) - V(RST_INT)
R4 Q_IN Q_NODE 1k
C3 Q_NODE GND 1nF
B_Q_OUT Q_OUT GND V=0.5*(1+tanh((V(Q_NODE)-0.5)*10))

* Output stage with small series resistance
B_OUT OUT_INT GND V=V(VCC)*V(Q_OUT)
R_OUT OUT_INT OUT 10
.ends

* Transient Analysis
.op
.tran 10m 10
.print tran V(VCC) V(VOUT) V(VCAP) V(VLED) V(VCTRL)

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 10 s and captures the switching interval. Main ranges: v(vout) -4.47e-08 uV -> 4.9 V; v(vctrl) 0 uV -> 3.33 V; v(vcap) 0 uV -> 5 V.

Common mistakes and how to avoid them

  • Reversing the R and C positions: Connecting R1 to VCC and C1 to 0 creates a delay-off timer rather than a delay-on timer. Ensure C1 connects strictly to VCC and R1 to 0 to achieve the desired power-on delay.
  • Leaving the RESET pin floating: An unconnected Pin 4 can pick up ambient electrical noise, causing the timer to reset randomly and preventing the LED from turning on. Always tie Pin 4 directly to VCC.
  • Electrolytic capacitor reverse polarity: In this specific configuration, the positive terminal of C1 must go to VCC and the negative terminal to VCAP. Reversing this will cause high leakage current, drastically altering the delay time or destroying the capacitor.


Troubleshooting

  • Symptom: LED turns on instantly without delay.
    • Cause: C1 is internally shorted, or the R1/C1 components were swapped.
    • Fix: Double-check the wiring of nodes VCAP, VCC, and 0. Replace C1 if a short is suspected.
  • Symptom: LED never turns on.
    • Cause: VCAP never drops below 1.66 V. This usually happens if C1 has excessive leakage current, essentially forming a voltage divider with R1. It can also occur if the LED (D1) is inserted backwards.
    • Fix: Ensure LED polarity is correct (anode to R2, cathode to 0). Use a higher quality capacitor or decrease R1 (while correspondingly increasing C1 to maintain the same time constant) to overcome leakage.
  • Symptom: Delay time is significantly shorter or longer than 5 seconds.
    • Cause: Standard electrolytic capacitors have wide tolerances (often \pm 20\% or worse).
    • Fix: This is normal behavior for basic components. For precision timing, swap the electrolytic capacitor for a tantalum or film capacitor with a tighter tolerance.

Possible improvements and extensions

  • Adjustable Delay: Replace R1 with a 10 kΩ fixed resistor in series with a 500 kΩ potentiometer. This allows manual calibration of the wait time from a fraction of a second up to nearly 30 seconds.
  • Rapid Reset Capability: Add a diode (e.g., 1N4148) in parallel with C1 (anode to VCAP, cathode to VCC). If power is momentarily lost, the diode will instantly discharge the capacitor, ensuring the timer reliably restarts its full delay sequence upon immediate repowering.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the main objective of the circuit described in the article?




Question 2: What happens to the LED exactly at power-on (t=0)?




Question 3: What is the approximate delay time before the LED illuminates?




Question 4: According to the article, why is this delay timer useful in audio amplifiers?




Question 5: What dictates the waiting period before the timer's output activates?




Question 6: How is this timer topology useful for power supply sequencing?




Question 7: At what voltage threshold does the NE555 output snap from 0 V to 5 V?




Question 8: Why might this circuit be used for microcontroller resets?




Question 9: How does the voltage at the timing node (VCAP) behave before the LED turns on?




Question 10: What is the stated difficulty level of this practical case?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Alarm Lockout Logic with NAND

Alarm Lockout Logic with NAND prototype (Maker Style)

Level: Basic – Build an active-high alarm indicator using 74HC00 NAND gates to understand universal logic and signal inversion.

Objective and use case

You will build a digital logic circuit where an alarm sensor and an enable switch must both be triggered to turn on a warning LED, implemented entirely with a single 74HC00 NAND gate chip.

This circuit is highly useful for demonstrating fundamental digital concepts:
* It demonstrates the concept of «universal gates,» showing how a NAND gate can be wired as a NOT gate (inverter) to achieve an AND logic function.
* It illustrates how an «enable» signal works, which is an industry standard method to authorize or safely block system operations.
* It provides hands-on practice with handling CMOS logic levels and configuring pull-down networks for reliable switch operation.

Expected outcome:
* The intermediate signal (the output of the first NAND gate) will output a logic LOW (0 V) only when both inputs are HIGH (5 V).
* The final output will be logic HIGH (5 V) and will light the LED strictly when both the Alarm and Enable inputs are HIGH.
* You will practically verify the combined truth table of a NAND and a NOT gate.

Target audience: Beginners in digital electronics learning how to manipulate logic gates.

Materials

  • V1: 5 V DC supply
  • SW1: SPST switch, function: Alarm trigger
  • SW2: SPST switch, function: Enable signal
  • R1: 10 kΩ resistor, function: pull-down for ALARM node
  • R2: 10 kΩ resistor, function: pull-down for ENABLE node
  • R3: 330 Ω resistor, function: LED current limiting
  • U1: 74HC00 Quad 2-Input NAND Gate, function: logic evaluation and inversion
  • D1: Red LED, function: Alarm indicator

Pin-out of the IC used

74HC00 (Quad 2-Input NAND Gate)

Pin Name Logic function Connection in this case
1 1 A Input 1 of NAND A Node ALARM (from SW1)
2 1B Input 2 of NAND A Node ENABLE (from SW2)
3 1Y Output of NAND A Node INTERMEDIATE
4 2 A Input 1 of NAND B Node INTERMEDIATE
5 2B Input 2 of NAND B Node INTERMEDIATE
6 2Y Output of NAND B Node VOUT
7 GND Ground Node 0
14 VCC Supply Voltage Node VCC

(Note: The 74HC00 contains four independent NAND gates. In this circuit, we use gates A and B. Unused inputs on gates C and D should be tied to ground).

Wiring guide

  • V1: connects between VCC and 0.
  • SW1: connects between VCC and ALARM.
  • R1: connects between ALARM and 0.
  • SW2: connects between VCC and ENABLE.
  • R2: connects between ENABLE and 0.
  • U1 Pin 14 (VCC): connects to VCC.
  • U1 Pin 7 (GND): connects to 0.
  • U1 Pin 1 (1 A): connects to ALARM.
  • U1 Pin 2 (1B): connects to ENABLE.
  • U1 Pin 3 (1Y): connects to INTERMEDIATE.
  • U1 Pin 4 (2 A): connects to INTERMEDIATE.
  • U1 Pin 5 (2B): connects to INTERMEDIATE.
  • U1 Pin 6 (2Y): connects to VOUT.
  • D1: Anode connects to VOUT, Cathode connects to NODE_LED.
  • R3: connects between NODE_LED and 0.
  • Safety connection: Connect pins 9, 10, 12, and 13 of U1 to 0 (GND) to prevent unused gates from floating.

Conceptual block diagram

Conceptual block diagram — PIN Alarm Blocking Logic
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

VCC --> [ SW1 ] --(ALARM)--> [ U1: Pin 1 (1 A) ]
           |                      |
         [ R1 ]                   |
           |                 [ U1: Gate 1 (NAND) ] --(INTERMEDIATE)--> [ U1: Pins 4,5 (2 A,2B) ]
          GND                     |                                         |
                                  |                                    [ U1: Gate 2 (NAND) ] --(VOUT)--> [ D1: LED ] --(NODE_LED)--> [ R3 ] --> GND
VCC --> [ SW2 ] --(ENABLE)-> [ U1: Pin 2 (1B) ]
           |
         [ R2 ]
           |
          GND

* Power & Safety Connections:
VCC --> [ U1: Pin 14 (VCC) ]
GND <-- [ U1: Pin 7 (GND) ]
GND <-- [ U1: Pins 9, 10, 12, 13 (Unused) ]
Electrical Schematic

Truth table

Alarm (SW1) Enable (SW2) Intermediate Node (1Y) Output Node (2Y) LED State
0 0 1 0 OFF
0 1 1 0 OFF
1 0 1 0 OFF
1 1 0 1 ON

Measurements and tests

  1. Use a multimeter to verify the power supply is exactly 5 V across the VCC and 0 nodes.
  2. Probe the ALARM and ENABLE nodes relative to 0. Verify they read exactly 0 V when their respective switches are open, and 5 V when closed.
  3. Probe the INTERMEDIATE node. It should read ~5 V when either or both switches are open, and drop to ~0 V strictly when both switches are closed.
  4. Probe the VOUT node. It should always display the exact opposite logic level of the INTERMEDIATE node.
  5. Visually confirm that the LED turns on if and only if both switches are toggled to the closed (active) position.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Alarm Lockout Logic with NAND

* Main DC Supply
V1 VCC 0 DC 5

* Control signals to simulate user pressing the switches (Testing Truth Table)
V_ctrl1 ctrl1 0 PULSE(0 5 0 1u 1u 50u 100u)
V_ctrl2 ctrl2 0 PULSE(0 5 0 1u 1u 100u 200u)

* SW1: SPST switch (Alarm trigger)
S1 VCC ALARM ctrl1 0 SW_MODEL

* SW2: SPST switch (Enable signal)
S2 VCC ENABLE ctrl2 0 SW_MODEL
.model SW_MODEL SW(VT=2.5 VH=0.5 RON=0.1 ROFF=100MEG)

* Pull-down resistors for logic inputs
R1 ALARM 0 10k
R2 ENABLE 0 10k

* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Alarm Lockout Logic with NAND

* Main DC Supply
V1 VCC 0 DC 5

* Control signals to simulate user pressing the switches (Testing Truth Table)
V_ctrl1 ctrl1 0 PULSE(0 5 0 1u 1u 50u 100u)
V_ctrl2 ctrl2 0 PULSE(0 5 0 1u 1u 100u 200u)

* SW1: SPST switch (Alarm trigger)
S1 VCC ALARM ctrl1 0 SW_MODEL

* SW2: SPST switch (Enable signal)
S2 VCC ENABLE ctrl2 0 SW_MODEL
.model SW_MODEL SW(VT=2.5 VH=0.5 RON=0.1 ROFF=100MEG)

* Pull-down resistors for logic inputs
R1 ALARM 0 10k
R2 ENABLE 0 10k

* U1: 74HC00 Quad 2-Input NAND Gate
* Pinout: 1:1A, 2:1B, 3:1Y, 4:2A, 5:2B, 6:2Y, 7:GND, 8:3Y, 9:3A, 10:3B, 11:4Y, 12:4A, 13:4B, 14:VCC
XU1 ALARM ENABLE INTERMEDIATE INTERMEDIATE INTERMEDIATE VOUT 0 NC8 0 0 NC11 0 0 VCC HC00_DIP14

* D1: Red LED (Alarm indicator)
D1 VOUT NODE_LED DLED
.model DLED D(IS=1e-20 N=2.2 RS=15)

* R3: LED current limiting resistor
R3 NODE_LED 0 330

* Subcircuit for 74HC00 (Quad 2-Input NAND Gate)
.subckt HC00_DIP14 1 2 3 4 5 6 7 8 9 10 11 12 13 14
* Gate 1
B1 3_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(1)-2.5))))*(1/(1+exp(-50*(V(2)-2.5)))))
R1 3_int 3 50
* Gate 2
B2 6_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(4)-2.5))))*(1/(1+exp(-50*(V(5)-2.5)))))
R2 6_int 6 50
* Gate 3
B3 8_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(9)-2.5))))*(1/(1+exp(-50*(V(10)-2.5)))))
R3 8_int 8 50
* Gate 4
B4 11_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(12)-2.5))))*(1/(1+exp(-50*(V(13)-2.5)))))
R4 11_int 11 50
.ends

* Analysis directives
.tran 1u 500u
.print tran V(ALARM) V(ENABLE) V(VOUT) V(NODE_LED)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient simulation shows the output node (VOUT) and LED node (NODE_LED) going high (approx 4.66V and 2.22V respectively) only when both ALARM and ENABLE inputs are high (approx 5V). When either or both inputs are low, the output is near 0V. This matches the intended AND logic behavior created by using two NAND gates in series.
Show raw data table (691 rows)
Index   time            v(alarm)        v(enable)       v(vout)         v(node_led)
0	0.000000e+00	4.999500e-04	4.999500e-04	1.047185e-47	-6.91142e-47
1	1.000000e-08	4.999500e-04	4.999500e-04	7.268458e-64	-4.79767e-63
2	2.000000e-08	4.999500e-04	4.999500e-04	-7.26994e-64	4.797672e-63
3	4.000000e-08	4.999500e-04	4.999500e-04	-7.41841e-68	-2.28156e-77
4	8.000000e-08	4.999500e-04	4.999500e-04	-7.41841e-68	-2.51468e-77
5	1.600000e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
6	3.200000e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
7	3.750000e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
8	4.712500e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
9	4.978906e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
10	5.445117e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
11	5.574158e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
12	5.799979e-07	4.999500e-04	4.999500e-04	-7.41841e-68	-2.44808e-77
13	6.049995e-07	4.999950e+00	4.999950e+00	4.662865e+00	2.225088e+00
14	6.550027e-07	4.999950e+00	4.999950e+00	4.662939e+00	2.224602e+00
15	7.550091e-07	4.999950e+00	4.999950e+00	4.662792e+00	2.225571e+00
16	9.550219e-07	4.999950e+00	4.999950e+00	4.662792e+00	2.225574e+00
17	1.000000e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
18	1.040003e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
19	1.120008e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
20	1.280018e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
21	1.600038e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
22	2.240079e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
23	3.240079e-06	4.999950e+00	4.999950e+00	4.662786e+00	2.225611e+00
... (667 more rows) ...


Reference SPICE netlist (ngspice)

* Alarm Lockout Logic with NAND

* Main DC Supply
V1 VCC 0 DC 5

* Control signals to simulate user pressing the switches (Testing Truth Table)
V_ctrl1 ctrl1 0 PULSE(0 5 0 1u 1u 50u 100u)
V_ctrl2 ctrl2 0 PULSE(0 5 0 1u 1u 100u 200u)

* SW1: SPST switch (Alarm trigger)
S1 VCC ALARM ctrl1 0 SW_MODEL

* SW2: SPST switch (Enable signal)
S2 VCC ENABLE ctrl2 0 SW_MODEL
.model SW_MODEL SW(VT=2.5 VH=0.5 RON=0.1 ROFF=100MEG)

* Pull-down resistors for logic inputs
R1 ALARM 0 10k
R2 ENABLE 0 10k

* U1: 74HC00 Quad 2-Input NAND Gate
* Pinout: 1:1A, 2:1B, 3:1Y, 4:2A, 5:2B, 6:2Y, 7:GND, 8:3Y, 9:3A, 10:3B, 11:4Y, 12:4A, 13:4B, 14:VCC
XU1 ALARM ENABLE INTERMEDIATE INTERMEDIATE INTERMEDIATE VOUT 0 NC8 0 0 NC11 0 0 VCC HC00_DIP14

* D1: Red LED (Alarm indicator)
D1 VOUT NODE_LED DLED
.model DLED D(IS=1e-20 N=2.2 RS=15)

* R3: LED current limiting resistor
R3 NODE_LED 0 330

* Subcircuit for 74HC00 (Quad 2-Input NAND Gate)
.subckt HC00_DIP14 1 2 3 4 5 6 7 8 9 10 11 12 13 14
* Gate 1
B1 3_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(1)-2.5))))*(1/(1+exp(-50*(V(2)-2.5)))))
R1 3_int 3 50
* Gate 2
B2 6_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(4)-2.5))))*(1/(1+exp(-50*(V(5)-2.5)))))
R2 6_int 6 50
* Gate 3
B3 8_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(9)-2.5))))*(1/(1+exp(-50*(V(10)-2.5)))))
R3 8_int 8 50
* Gate 4
B4 11_int 7 V=V(14)*(1-(1/(1+exp(-50*(V(12)-2.5))))*(1/(1+exp(-50*(V(13)-2.5)))))
R4 11_int 11 50
.ends

* Analysis directives
.tran 1u 500u
.print tran V(ALARM) V(ENABLE) V(VOUT) V(NODE_LED)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient simulation shows the output node (VOUT) and LED node (NODE_LED) going high (approx 4.66V and 2.22V respectively) only when both ALARM and ENABLE inputs are high (approx 5V). When either or both inputs are low, the output is near 0V. This matches the intended AND logic behavior created by using two NAND gates in series.

Common mistakes and how to avoid them

  1. Leaving unused inputs floating: CMOS chips like the 74HC00 are highly sensitive to static and ambient noise. Unused gate inputs (pins 9, 10, 12, 13) must be explicitly tied to ground (0) or VCC.
  2. Omitting the pull-down resistors: Without R1 and R2, the input pins will float when the switches are open, leading to unpredictable, flickering behavior in the LED. Always ensure the 10 kΩ pull-downs are securely connected to ground.
  3. Connecting the LED without a series resistor: Connecting D1 directly between VOUT and 0 will draw excessive current, potentially destroying the LED and burning out the output stage of the 74HC00 chip. R3 is mandatory.


Troubleshooting

  • Symptom: The LED never turns off, regardless of switch positions.
  • Cause: One of the input pull-down resistors is loose, causing the chip to read a false HIGH, or the intermediate node isn’t wired correctly to both inputs of the second gate.
  • Fix: Verify connections for R1 and R2 to ground. Ensure U1 Pin 3 routes precisely to both Pin 4 and Pin 5.
  • Symptom: The LED brightness flickers when a hand is moved near the circuit.
  • Cause: A floating input is acting as an antenna and picking up environmental noise.
  • Fix: Check that all unused inputs on the IC are tied to ground, and ensure R1 and R2 are seated firmly in the breadboard.
  • Symptom: The IC becomes hot to the touch.
  • Cause: The power supply is connected backwards, or the output node is shorted directly to ground or VCC.
  • Fix: Disconnect power immediately. Verify that U1 Pin 14 goes strictly to +5 V and Pin 7 goes strictly to Ground.

Possible improvements and extensions

  1. Master Override switch: Introduce a third switch and utilize one of the spare NAND gates (e.g., Gate C) to create a «Master Override» that forces the LED off regardless of the Alarm and Enable signals.
  2. Add a delay circuit: Incorporate an RC network (a resistor and a capacitor) between one of the switches and its input pin. This requires the switch to be held closed for a specific duration before the logic gate registers a HIGH signal, preventing false alarms.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the main objective of the circuit described in the article?




Question 2: Which logic gate chip is used exclusively in this project?




Question 3: How is the AND logic function achieved in this circuit using only NAND gates?




Question 4: What is the purpose of the 'enable' signal in this system?




Question 5: What is the expected voltage of the intermediate signal (output of the first NAND gate) when both inputs are HIGH?




Question 6: Under what condition will the final output light the warning LED?




Question 7: Why are pull-down networks used in this circuit?




Question 8: What logic family's levels does this project provide hands-on practice with?




Question 9: What combined truth table will you practically verify in this project?




Question 10: What is the difficulty level of this project?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: 2-Bit Binary Counter with End-of-Cycle

2-Bit Binary Counter with End-of-Cycle prototype (Maker Style)

Level: Basic – Build a 0 to 3 binary counter with manual clock, reset, and a maximum count indicator.

Objective and use case

In this practical case, you will build a 2-bit digital counter using a 74HC393 IC and decode its maximum state (binary 11, decimal 3) using a 74HC08 AND gate. A simulated clock pushbutton increments the count, while a manual reset pushbutton forces the counter back to zero.

Why this is useful:
* Demonstrates how sequential logic (counters) tracks discrete events over time.
* Shows how combinational logic (AND gate) is used to decode specific binary states and trigger events.
* Provides a foundational understanding of clock edge triggering and asynchronous resets.
* Acts as a building block for state machines, timers, and step-sequencers in industrial or hobbyist electronics.

Expected outcome:
* Pressing and releasing the clock button will advance the binary state sequentially: 00 → 01 → 10 → 11.
* Two LEDs will display the current binary count (LSB and MSB).
* A third LED (end-of-cycle indicator) will light up strictly when the count reaches state 3.
* Pressing the reset button will immediately extinguish all LEDs, returning the circuit to state 00 regardless of the current count.
* Target audience: Electronics beginners learning digital logic and basic state tracking.

Materials

  • V1: 5 V DC supply
  • S1: normally open pushbutton, function: clock pulse generator
  • S2: normally open pushbutton, function: manual reset trigger
  • R1: 10 kΩ resistor, function: pull-down for CLK node
  • R2: 10 kΩ resistor, function: pull-down for MR node
  • R3: 330 Ω resistor, function: current limiting for QA LED
  • R4: 330 Ω resistor, function: current limiting for QB LED
  • R5: 330 Ω resistor, function: current limiting for MAX_VAL LED
  • D1: green LED, function: LSB indicator (QA)
  • D2: yellow LED, function: MSB indicator (QB)
  • D3: red LED, function: end-of-cycle indicator
  • U1: 74HC393 dual 4-bit binary counter, function: state counting
  • U2: 74HC08 quad 2-input AND gate, function: state decoding

Pin-out of the IC used

74HC393 (Dual 4-Bit Binary Counter – Only Half Used)

Pin Name Logic function Connection in this case
1 1CP Clock Input (Active Low / Falling Edge) CLK
2 1MR Master Reset (Active High) MR
3 1Q0 Output 0 (LSB) QA
4 1Q1 Output 1 (MSB) QB
7 GND Ground 0
14 VCC Positive Supply VCC

Note: Pins 5, 6, and 8 through 13 belong to the second counter and can be grounded in a real circuit to prevent floating inputs.

74HC08 (Quad 2-Input AND Gate – Only One Gate Used)

Pin Name Logic function Connection in this case
1 1 A Input A of Gate 1 QA
2 1B Input B of Gate 1 QB
3 1Y Output of Gate 1 MAX_VAL
7 GND Ground 0
14 VCC Positive Supply VCC

Wiring guide

  • V1: connects between VCC and 0.
  • S1: connects between VCC and CLK.
  • R1: connects between CLK and 0.
  • S2: connects between VCC and MR.
  • R2: connects between MR and 0.
  • U1: Pin 1 connects to CLK, Pin 2 connects to MR, Pin 3 connects to QA, Pin 4 connects to QB, Pin 7 connects to 0, Pin 14 connects to VCC.
  • U2: Pin 1 connects to QA, Pin 2 connects to QB, Pin 3 connects to MAX_VAL, Pin 7 connects to 0, Pin 14 connects to VCC.
  • R3: connects between QA and N_D1.
  • D1: connects between N_D1 and 0 (anode to N_D1, cathode to 0).
  • R4: connects between QB and N_D2.
  • D2: connects between N_D2 and 0 (anode to N_D2, cathode to 0).
  • R5: connects between MAX_VAL and N_D3.
  • D3: connects between N_D3 and 0 (anode to N_D3, cathode to 0).

Conceptual block diagram

Conceptual block diagram — CONTADOR Binary counter
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

[ S1 (Clock) + R1 ] --(CLK)--> [                       ] --(QA)--> [ R3 (330 Ω) ] --> [ D1 (Green LED) ] ---> GND
                               [                       ]
                               [                       ] --(QA)--> [                       ]
                               [ U1: 74HC393 Counter   ]           [ U2: 74HC08 AND Gate   ] --(MAX_VAL)--> [ R5 (330 Ω) ] --> [ D3 (Red LED) ] ---> GND
                               [                       ] --(QB)--> [                       ]
                               [                       ]
[ S2 (Reset) + R2 ] --(MR)---> [                       ] --(QB)--> [ R4 (330 Ω) ] --> [ D2 (Yellow LED) ] --> GND
Electrical Schematic

Measurements and tests

  1. Initial State Check: Power on the circuit. If any LEDs are lit, press and release S2 (Master Reset). The voltage at the MR node will spike to 5 V, clearing the counter. Measure QA, QB, and MAX_VAL; all should be 0 V. All LEDs must be OFF.
  2. First Clock Pulse (State 1): Press and hold S1. The CLK node goes to 5 V. Release S1. The 74HC393 triggers on the falling edge (high-to-low transition). D1 (QA) should turn on. D2 (QB) and D3 (MAX_VAL) remain off.
  3. Second Clock Pulse (State 2): Press and release S1 again. D1 turns off and D2 turns on. This represents binary 10 (decimal 2).
  4. Third Clock Pulse (State 3): Press and release S1 a third time. Both D1 (QA) and D2 (QB) turn on. Consequently, inputs 1 A and 1B on the 74HC08 are both HIGH. The MAX_VAL node will output 5 V, lighting up the end-of-cycle LED (D3).
  5. Rollover (State 0): Press and release S1 a fourth time. The counter overflows the 2-bit capacity represented by QA and QB. Both counting LEDs and the MAX_VAL LED will turn off.
  6. Asynchronous Reset Verification: Cycle the counter to state 2 or 3. Press the reset button S2. Observe that the counter immediately resets to 00 without waiting for a clock pulse.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: 2-Bit Binary Counter with End-of-Cycle

.width out=256

* --- Power Supply ---
V1 VCC 0 DC 5

* --- User Inputs (Pushbuttons modeled as Voltage-Controlled Switches) ---
* Clock Pushbutton (S1) connects VCC to CLK
S1 VCC CLK S1_ctrl 0 mySW
Vctrl1 S1_ctrl 0 PULSE(0 5 20u 1u 1u 40u 100u)
R1 CLK 0 10k

* Manual Reset Pushbutton (S2) connects VCC to MR
S2 VCC MR S2_ctrl 0 mySW
* Initialize reset at start, then trigger again at 280us to clear the MAX_VAL state
Vctrl2 S2_ctrl 0 PWL(0 5 10u 5 11u 0 280u 0 281u 5 290u 5 291u 0)
R2 MR 0 10k

.model mySW SW(Ron=1 Roff=100Meg Vt=2.5 Vh=0.5)
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Practical case: 2-Bit Binary Counter with End-of-Cycle

.width out=256

* --- Power Supply ---
V1 VCC 0 DC 5

* --- User Inputs (Pushbuttons modeled as Voltage-Controlled Switches) ---
* Clock Pushbutton (S1) connects VCC to CLK
S1 VCC CLK S1_ctrl 0 mySW
Vctrl1 S1_ctrl 0 PULSE(0 5 20u 1u 1u 40u 100u)
R1 CLK 0 10k

* Manual Reset Pushbutton (S2) connects VCC to MR
S2 VCC MR S2_ctrl 0 mySW
* Initialize reset at start, then trigger again at 280us to clear the MAX_VAL state
Vctrl2 S2_ctrl 0 PWL(0 5 10u 5 11u 0 280u 0 281u 5 290u 5 291u 0)
R2 MR 0 10k

.model mySW SW(Ron=1 Roff=100Meg Vt=2.5 Vh=0.5)
.model logic_sw SW(Ron=1k Roff=100Meg Vt=2.5 Vh=0.1)

* --- Subcircuits for Logic ---

* Falling-edge triggered T-Flip-Flop with active-high asynchronous reset
.subckt TFF_falling CLK CLR Q
B1 CLK_b 0 V=5-V(CLK)
S1 Q_b master CLK 0 logic_sw
C1 master 0 100p
R1 master 0 1G
S2 master slave CLK_b 0 logic_sw
C2 slave 0 100p
R2 slave 0 1G
* Asynchronous Reset Switches
S3 master 0 CLR 0 logic_sw
S4 slave 0 CLR 0 logic_sw
* Output formatting with RC filter to prevent timestep discontinuities
B2 Q_raw 0 V=V(slave)>2.5?5:0
R3 Q_raw Q 1k
C3 Q 0 100p
B4 Q_b 0 V=5-V(Q_raw)
.ends

* U1: 74HC393 Dual 4-bit Binary Counter (Only first 2 bits QA, QB modeled)
.subckt 74HC393 CLK MR QA QB GND VCC
X1 CLK MR QA TFF_falling
X2 QA MR QB TFF_falling
.ends

* U2: 74HC08 Quad 2-input AND Gate
.subckt 74HC08 A B Y GND VCC
B1 Y_raw 0 V=(V(A)>2.5)&&(V(B)>2.5)?5:0
R1 Y_raw Y 1k
C1 Y 0 100p
.ends

* --- Main Circuit ---

* U1: 74HC393 Dual 4-bit Binary Counter
XU1 CLK MR QA QB 0 VCC 74HC393

* U2: 74HC08 Quad 2-input AND gate
XU2 QA QB MAX_VAL 0 VCC 74HC08

* --- Output LEDs ---
R3 QA N_D1 330
D1 N_D1 0 LED_green

R4 QB N_D2 330
D2 N_D2 0 LED_yellow

R5 MAX_VAL N_D3 330
D3 N_D3 0 LED_red

.model LED_green D(IS=1e-19 N=1.8 RS=10)
.model LED_yellow D(IS=1e-19 N=1.7 RS=10)
.model LED_red D(IS=1e-19 N=1.6 RS=10)

* --- Simulation and Output ---
.op
.tran 1u 600u
.print tran V(CLK) V(MR) V(QA) V(QB) V(MAX_VAL)
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The simulation shows the clock signal toggling and the manual reset (MR) signal initializing high then pulsing later. The QA output toggles in response to the clock, but QB and MAX_VAL remain near zero throughout the sampled data, indicating the counter may not be fully reaching the higher states or the clock pulses are insufficient to trigger QB.
Show raw data table (1035 rows)
Index   time            v(clk)          v(mr)           v(qa)           v(qb)           v(max_val)
0	0.000000e+00	4.999500e-04	4.999500e+00	1.094960e-64	1.402927e-64	1.824146e-64
1	1.000000e-08	4.999500e-04	4.999500e+00	9.954179e-65	1.275388e-64	1.658315e-64
2	2.000000e-08	4.999500e-04	4.999500e+00	9.049254e-65	1.159444e-64	1.507559e-64
3	4.000000e-08	4.999500e-04	4.999500e+00	7.403935e-65	9.486357e-65	1.233457e-64
4	8.000000e-08	4.999500e-04	4.999500e+00	4.935957e-65	6.324238e-65	8.223048e-65
5	1.600000e-07	4.999500e-04	4.999500e+00	2.115410e-65	2.710388e-65	3.524164e-65
6	3.200000e-07	4.999500e-04	4.999500e+00	2.350456e-66	3.011542e-66	3.915737e-66
7	6.400000e-07	4.999500e-04	4.999500e+00	-5.42413e-67	-6.94971e-67	-9.03632e-67
8	1.280000e-06	4.999500e-04	4.999500e+00	2.841210e-67	3.640325e-67	4.733309e-67
9	2.280000e-06	4.999500e-04	4.999500e+00	-1.89414e-67	-2.42688e-67	-3.15554e-67
10	3.280000e-06	4.999500e-04	4.999500e+00	1.262760e-67	1.617922e-67	2.103693e-67
11	4.280000e-06	4.999500e-04	4.999500e+00	-8.41840e-68	-1.07861e-67	-1.40246e-67
12	5.280000e-06	4.999500e-04	4.999500e+00	5.612267e-68	7.190766e-68	9.349746e-68
13	6.280000e-06	4.999500e-04	4.999500e+00	-3.74151e-68	-4.79384e-68	-6.23316e-68
14	7.280000e-06	4.999500e-04	4.999500e+00	2.494341e-68	3.195896e-68	4.155443e-68
15	8.280000e-06	4.999500e-04	4.999500e+00	-1.66289e-68	-2.13060e-68	-2.77030e-68
16	9.280000e-06	4.999500e-04	4.999500e+00	1.108596e-68	1.420398e-68	1.846863e-68
17	1.000000e-05	4.999500e-04	4.999500e+00	-6.26598e-69	-8.02834e-69	-1.04388e-68
18	1.010000e-05	4.999500e-04	4.999500e+00	-3.13299e-69	-4.01417e-69	-5.21940e-69
19	1.030000e-05	4.999500e-04	4.999500e+00	1.566513e-78	2.007109e-78	2.609729e-78
20	1.035875e-05	4.999500e-04	4.999500e+00	8.551514e-79	1.095671e-78	1.424639e-78
21	1.046156e-05	4.999500e-04	4.999500e+00	2.744610e-79	3.516558e-79	4.572383e-79
22	1.049002e-05	4.999500e-04	4.999500e+00	2.060863e-79	2.640500e-79	3.433294e-79
23	1.053982e-05	4.999500e-04	4.999500e+00	1.239160e-79	1.587686e-79	2.064379e-79
... (1011 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: 2-Bit Binary Counter with End-of-Cycle

.width out=256

* --- Power Supply ---
V1 VCC 0 DC 5

* --- User Inputs (Pushbuttons modeled as Voltage-Controlled Switches) ---
* Clock Pushbutton (S1) connects VCC to CLK
S1 VCC CLK S1_ctrl 0 mySW
Vctrl1 S1_ctrl 0 PULSE(0 5 20u 1u 1u 40u 100u)
R1 CLK 0 10k

* Manual Reset Pushbutton (S2) connects VCC to MR
S2 VCC MR S2_ctrl 0 mySW
* Initialize reset at start, then trigger again at 280us to clear the MAX_VAL state
Vctrl2 S2_ctrl 0 PWL(0 5 10u 5 11u 0 280u 0 281u 5 290u 5 291u 0)
R2 MR 0 10k

.model mySW SW(Ron=1 Roff=100Meg Vt=2.5 Vh=0.5)
.model logic_sw SW(Ron=1k Roff=100Meg Vt=2.5 Vh=0.1)

* --- Subcircuits for Logic ---

* Falling-edge triggered T-Flip-Flop with active-high asynchronous reset
.subckt TFF_falling CLK CLR Q
B1 CLK_b 0 V=5-V(CLK)
S1 Q_b master CLK 0 logic_sw
C1 master 0 100p
R1 master 0 1G
S2 master slave CLK_b 0 logic_sw
C2 slave 0 100p
R2 slave 0 1G
* Asynchronous Reset Switches
S3 master 0 CLR 0 logic_sw
S4 slave 0 CLR 0 logic_sw
* Output formatting with RC filter to prevent timestep discontinuities
B2 Q_raw 0 V=V(slave)>2.5?5:0
R3 Q_raw Q 1k
C3 Q 0 100p
B4 Q_b 0 V=5-V(Q_raw)
.ends

* U1: 74HC393 Dual 4-bit Binary Counter (Only first 2 bits QA, QB modeled)
.subckt 74HC393 CLK MR QA QB GND VCC
X1 CLK MR QA TFF_falling
X2 QA MR QB TFF_falling
.ends

* U2: 74HC08 Quad 2-input AND Gate
.subckt 74HC08 A B Y GND VCC
B1 Y_raw 0 V=(V(A)>2.5)&&(V(B)>2.5)?5:0
R1 Y_raw Y 1k
C1 Y 0 100p
.ends

* --- Main Circuit ---

* U1: 74HC393 Dual 4-bit Binary Counter
XU1 CLK MR QA QB 0 VCC 74HC393

* U2: 74HC08 Quad 2-input AND gate
XU2 QA QB MAX_VAL 0 VCC 74HC08

* --- Output LEDs ---
R3 QA N_D1 330
D1 N_D1 0 LED_green

R4 QB N_D2 330
D2 N_D2 0 LED_yellow

R5 MAX_VAL N_D3 330
D3 N_D3 0 LED_red

.model LED_green D(IS=1e-19 N=1.8 RS=10)
.model LED_yellow D(IS=1e-19 N=1.7 RS=10)
.model LED_red D(IS=1e-19 N=1.6 RS=10)

* --- Simulation and Output ---
.op
.tran 1u 600u
.print tran V(CLK) V(MR) V(QA) V(QB) V(MAX_VAL)
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The simulation shows the clock signal toggling and the manual reset (MR) signal initializing high then pulsing later. The QA output toggles in response to the clock, but QB and MAX_VAL remain near zero throughout the sampled data, indicating the counter may not be fully reaching the higher states or the clock pulses are insufficient to trigger QB.

Common mistakes and how to avoid them

  • Ignoring switch bounce: Mechanical pushbuttons exhibit «bounce,» creating multiple rapid voltage transitions on a single press. This causes the counter to skip numbers. Avoid this in critical applications by using a hardware debounce circuit (like an RC filter followed by a Schmitt trigger).
  • Misunderstanding the clock edge: The 74HC393 increments on the falling edge of the clock signal. Beginners often expect the count to increase the moment the button is pressed, but it actually increases the moment the button is released (when the voltage drops from 5 V to 0 V).
  • Leaving unused logic inputs floating: While this basic test circuit focuses on the used gates, leaving the inputs of the unused gates on the 74HC393 and 74HC08 floating can cause internal oscillation and excessive power draw. Always tie unused inputs to GND or VCC.


Troubleshooting

  • Symptom: The counter jumps randomly (e.g., skips from 0 to 2 or 3).
  • Cause: Mechanical switch bounce on S1 is sending multiple clock pulses instantly.
  • Fix: Add a 100 nF capacitor in parallel with R1 to filter out the rapid mechanical bounces, or press the button very deliberately.
  • Symptom: The counter never increments; LEDs remain off.
  • Cause: The master reset pin is stuck HIGH, keeping the counter constantly cleared.
  • Fix: Check R2. Ensure it is firmly connected to GND to pull the MR node LOW when the reset button is not pressed.
  • Symptom: LEDs D1 and D2 count correctly, but D3 never turns on.
  • Cause: The 74HC08 AND gate is not receiving power, or its inputs are incorrectly wired.
  • Fix: Verify that pins 14 (VCC) and 7 (GND) of U2 are connected. Double-check that pin 1 connects to QA and pin 2 connects to QB.
  • Symptom: LEDs are very dim or burn out instantly.
  • Cause: Incorrect or missing current-limiting resistors.
  • Fix: Ensure R3, R4, and R5 (330 Ω) are properly placed in series with the respective LED anodes.

Possible improvements and extensions

  • Hardware Debouncing with a Schmitt Trigger: Replace the simple S1/R1 clock with an RC network fed into a 74HC14 Schmitt trigger inverter to completely eliminate switch bounce and provide perfectly clean clock edges.
  • Auto-Reset for Modulo-3 Counting: Connect the MAX_VAL output (pin 3 of U2) directly to the Master Reset input (MR, pin 2 of U1) instead of using the manual S2 switch. This will automatically clear the counter the instant it hits state 3, turning it into a 0-to-2 recurring cycle counter.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the main objective of this practical case?




Question 2: Which integrated circuit (IC) is used as the digital counter in this project?




Question 3: What is the specific purpose of the 74HC08 AND gate in this circuit?




Question 4: What happens when the clock pushbutton is pressed and released?




Question 5: What is the maximum decimal state this counter can reach before it wraps around or is reset?




Question 6: What is the function of the third LED in the circuit?




Question 7: What is the immediate effect of pressing the manual reset pushbutton?




Question 8: According to the text, what does sequential logic (counters) track?




Question 9: Which type of logic is demonstrated by using the AND gate to decode specific binary states?




Question 10: What is one of the applications this circuit acts as a building block for?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me: