Practical case: Production Line Fault Monitoring

Production Line Fault Monitoring prototype (Maker Style)

Level: Medium. Implement a safety system that stops a conveyor belt if either the temperature sensor OR the jam sensor detects an anomaly.

Objective and use case

You will build a logic control circuit using an OR gate to combine signals from two distinct safety sensors (Temperature and Optical Jam). When either sensor detects a fault (Logic High), the system will output an active signal to trigger an indicator or stop mechanism.

Why it is useful:
* Industrial Safety: Prevents machinery from operating under dangerous conditions.
* Equipment Protection: Stops motors immediately if they overheat to prevent permanent damage.
* Process Efficiency: Detects physical jams on conveyor belts automatically, reducing waste.
* Redundancy: Allows multiple different error types to trigger the same emergency stop routine.

Expected outcome:
* System Standby: When both sensors are Low (0V), the output LED is OFF.
* Temperature Fault: If the temperature sensor triggers (High/5V), the LED turns ON.
* Jam Fault: If the jam sensor triggers (High/5V), the LED turns ON.
* Critical Failure: If both sensors trigger simultaneously, the LED remains ON.

Target audience and level: Electronics students and hobbyists, Level Medium.

Materials

  • V1: 5 V DC power supply, function: Main circuit power.
  • U1: 74HC32, function: Quad 2-input OR gate IC.
  • S1: SPST Toggle Switch, function: Simulates Temperature Sensor (Open=Normal, Closed=Overheat).
  • S2: SPST Toggle Switch, function: Simulates Jam Sensor (Open=Clear, Closed=Jam).
  • R1: 10 kΩ resistor, function: Pull-down for Temperature Input.
  • R2: 10 kΩ resistor, function: Pull-down for Jam Input.
  • R3: 330 Ω resistor, function: Current limiting for indicator LED.
  • D1: Red LED, function: Visual Fault Indicator.

Pin-out of the IC used

Selected Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1A Input A Connected to Temperature Sensor (S1)
2 1B Input B Connected to Jam Sensor (S2)
3 1Y Output Connected to LED driver (R3 + D1)
7 GND Ground Connected to Power Supply Negative (0V)
14 VCC Power (+) Connected to Power Supply Positive (5V)

Wiring guide

  • VCC: Connect V1 positive terminal to U1 pin 14.
  • 0 (GND): Connect V1 negative terminal to U1 pin 7.
  • VA (Temp Signal): Connect S1 terminal 2 to U1 pin 1.
  • VA (Temp Signal): Connect R1 between U1 pin 1 and 0.
  • VCC: Connect S1 terminal 1 to VCC.
  • VB (Jam Signal): Connect S2 terminal 2 to U1 pin 2.
  • VB (Jam Signal): Connect R2 between U1 pin 2 and 0.
  • VCC: Connect S2 terminal 1 to VCC.
  • V_OUT: Connect U1 pin 3 to R3 terminal 1.
  • LED_NODE: Connect R3 terminal 2 to D1 Anode.
  • 0 (GND): Connect D1 Cathode to 0.

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

Title: Production Line Fault Monitoring (OR Logic)

      [ INPUT SENSORS ]                       [ LOGIC PROCESSING ]                 [ VISUAL OUTPUT ]

                                                 (Pin 14: VCC)
                                                       |
                                                       v
[ VCC ] --> [ S1: Temp Switch ] --+--(Pin 1)-->+---------------+
                                  |            |               |
                             [ R1: 10k ]       |   U1: 74HC32  |
                                  |            |   (OR Gate)   |--(Pin 3)--> [ R3: 330 ] --> [ D1: LED ] --> [ GND ]
                               [ GND ]         |               |
                                               |               |
[ VCC ] --> [ S2: Jam Switch  ] --+--(Pin 2)-->+---------------+
                                  |                    ^
                             [ R2: 10k ]               |
                                  |               (Pin 7: GND)
                               [ GND ]
Schematic (ASCII)

Truth table

This circuit utilizes positive logic (Active High).

Sensor A (Temp) Sensor B (Jam) Output (Fault Indicator) LED State
Low (0) Low (0) Low (0) OFF
Low (0) High (1) High (1) ON
High (1) Low (0) High (1) ON
High (1) High (1) High (1) ON

Measurements and tests

  1. Standby Check: Ensure both switches S1 and S2 are open. Measure voltage at U1 Pin 3 relative to GND. It should be ~0 V. LED should be OFF.
  2. Temperature Fault Simulation: Close S1 while keeping S2 open. Measure voltage at Pin 1 (Input A). It should be 5 V. The Output Pin 3 should go to High (~5 V) and the LED must light up.
  3. Jam Fault Simulation: Open S1 and close S2. Measure voltage at Pin 2 (Input B). It should be 5 V. The LED must light up.
  4. Simultaneous Fault: Close both S1 and S2. The LED must remain ON.

SPICE netlist and simulation

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

* Practical case: Production Line Fault Monitoring

* --- Component Models ---
* Generic Red LED Model
.model DLED D (IS=1e-14 N=2 RS=10 BV=5 IBV=10u CJO=10p)

* --- Subcircuits ---
* 74HC32 Quad 2-input OR Gate
* Pinout: 1=InputA, 2=InputB, 3=Output, 7=GND, 14=VCC
* Implemented using a robust behavioral source with continuous functions
.subckt 74HC32 1 2 3 7 14
* Logic: Output = VCC if (A > 2.5V OR B > 2.5V)
* Using sigmoid function for smooth convergence: S(x) = 1/(1+exp(-k*(x-thresh)))
* max(V(1), V(2)) selects the higher voltage to compare against threshold (2.5V)
B_OR 3 7 V = V(14) * (1 / (1 + exp(-20 * (max(V(1), V(2)) - 2.5))))
.ends

* --- Main Power Supply ---
* V1: 5V DC Supply
* Wiring: Positive -> Node 14 (VCC), Negative -> Node 0 (GND)
V1 14 0 DC 5

* --- Input Sensors (Simulated Switches) ---
* S1: Temperature Sensor Switch
* Wiring: Connects VCC to VA (Pin 1). Modeled as Pulse Source to simulate toggling.
* Logic Sequence: High (Overheat) / Low (Normal)
VS1 VA 0 PULSE(0 5 0 1u 1u 200u 400u)

* S2: Jam Sensor Switch
* Wiring: Connects VCC to VB (Pin 2). Modeled as Pulse Source with faster period.
* ... (truncated in public view) ...

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

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Production Line Fault Monitoring

* --- Component Models ---
* Generic Red LED Model
.model DLED D (IS=1e-14 N=2 RS=10 BV=5 IBV=10u CJO=10p)

* --- Subcircuits ---
* 74HC32 Quad 2-input OR Gate
* Pinout: 1=InputA, 2=InputB, 3=Output, 7=GND, 14=VCC
* Implemented using a robust behavioral source with continuous functions
.subckt 74HC32 1 2 3 7 14
* Logic: Output = VCC if (A > 2.5V OR B > 2.5V)
* Using sigmoid function for smooth convergence: S(x) = 1/(1+exp(-k*(x-thresh)))
* max(V(1), V(2)) selects the higher voltage to compare against threshold (2.5V)
B_OR 3 7 V = V(14) * (1 / (1 + exp(-20 * (max(V(1), V(2)) - 2.5))))
.ends

* --- Main Power Supply ---
* V1: 5V DC Supply
* Wiring: Positive -> Node 14 (VCC), Negative -> Node 0 (GND)
V1 14 0 DC 5

* --- Input Sensors (Simulated Switches) ---
* S1: Temperature Sensor Switch
* Wiring: Connects VCC to VA (Pin 1). Modeled as Pulse Source to simulate toggling.
* Logic Sequence: High (Overheat) / Low (Normal)
VS1 VA 0 PULSE(0 5 0 1u 1u 200u 400u)

* S2: Jam Sensor Switch
* Wiring: Connects VCC to VB (Pin 2). Modeled as Pulse Source with faster period.
* Logic Sequence: High (Jam) / Low (Clear)
VS2 VB 0 PULSE(0 5 0 1u 1u 100u 200u)

* --- Pull-down Resistors ---
* R1: 10k Pull-down for Temp Input
R1 VA 0 10k
* R2: 10k Pull-down for Jam Input
R2 VB 0 10k

* --- Logic IC U1 ---
* U1: 74HC32 Quad OR Gate
* Connections per wiring guide:
* Pin 1 (A) -> VA
* Pin 2 (B) -> VB
* Pin 3 (Y) -> V_OUT
* Pin 7 (GND) -> 0
* Pin 14 (VCC) -> 14
XU1 VA VB V_OUT 0 14 74HC32

* --- Output Indicator ---
* R3: 330 Ohm Current Limiting Resistor
R3 V_OUT LED_NODE 330

* D1: Red LED Visual Indicator
* Anode -> LED_NODE, Cathode -> GND
D1 LED_NODE 0 DLED

* --- Analysis Directives ---
* Transient analysis to capture truth table states (00, 01, 10, 11)
.tran 1u 400u

* Print required voltages for verification
.print tran V(VA) V(VB) V(V_OUT) V(LED_NODE)

* Calculate DC operating point
.op

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (906 rows)
Index   time            v(va)           v(vb)           v(v_out)
0	0.000000e+00	0.000000e+00	0.000000e+00	9.643749e-22
1	1.000000e-08	5.000000e-02	5.000000e-02	1.928750e-21
2	2.000000e-08	1.000000e-01	1.000000e-01	5.242886e-21
3	4.000000e-08	2.000000e-01	2.000000e-01	2.137746e-20
4	8.000000e-08	4.000000e-01	4.000000e-01	2.632654e-19
5	1.600000e-07	8.000000e-01	8.000000e-01	2.587285e-17
6	3.200000e-07	1.600000e+00	1.600000e+00	7.614990e-08
7	4.700575e-07	2.350288e+00	2.350288e+00	2.384318e-01
8	6.126008e-07	3.063004e+00	3.063004e+00	4.999936e+00
9	7.041960e-07	3.520980e+00	3.520980e+00	5.000000e+00
10	7.932149e-07	3.966074e+00	3.966074e+00	5.000000e+00
11	9.007723e-07	4.503862e+00	4.503862e+00	5.000000e+00
12	1.000000e-06	5.000000e+00	5.000000e+00	5.000000e+00
13	1.021511e-06	5.000000e+00	5.000000e+00	5.000000e+00
14	1.064534e-06	5.000000e+00	5.000000e+00	5.000000e+00
15	1.150580e-06	5.000000e+00	5.000000e+00	5.000000e+00
16	1.322672e-06	5.000000e+00	5.000000e+00	5.000000e+00
17	1.666856e-06	5.000000e+00	5.000000e+00	5.000000e+00
18	2.355224e-06	5.000000e+00	5.000000e+00	5.000000e+00
19	3.355224e-06	5.000000e+00	5.000000e+00	5.000000e+00
20	4.355224e-06	5.000000e+00	5.000000e+00	5.000000e+00
21	5.355224e-06	5.000000e+00	5.000000e+00	5.000000e+00
22	6.355224e-06	5.000000e+00	5.000000e+00	5.000000e+00
23	7.355224e-06	5.000000e+00	5.000000e+00	5.000000e+00
... (882 more rows) ...

Common mistakes and how to avoid them

  1. Leaving Inputs Floating: Failing to install pull-down resistors (R1, R2) causes the inputs to «float» and pick up noise, causing the LED to flicker or stay ON randomly. Solution: Always use 10kΩ pull-down resistors on CMOS inputs connected to switches.
  2. Missing Current Limiting Resistor: Connecting the LED directly to the 74HC32 output pin without R3. Solution: Ensure R3 (330Ω) is in series with the LED to prevent burning out the IC or the LED.
  3. Confusing Pinout: Treating the 74HC32 like a different logic chip (e.g., 74HC02 NOR) due to similar package shape. Solution: Always verify the datasheet pin diagram; Pin 3 is output for the first gate on the 74HC32.

Troubleshooting

  • LED is always ON: Check if pull-down resistors R1 and R2 are connected to Ground. If inputs are disconnected, they float High.
  • LED is very dim: The resistor R3 might be too high (e.g., 10kΩ instead of 330Ω) or the power supply voltage is below 3V.
  • Nothing happens when switches close: Verify that U1 Pin 14 is connected to 5V and Pin 7 is connected to GND. Check switch continuity.
  • Logic is inverted (LED OFF when fault occurs): You may have accidentally used a NOR gate or wired the LED active-low (Anode to VCC, Cathode to Output).

Possible improvements and extensions

  1. Latching Alarm: Add an SR Flip-Flop or a feedback loop so that once a fault is detected, the alarm stays ON until a manual «Reset» button is pressed, even if the sensor returns to normal.
  2. Audible Alert: Connect a transistor driver and a 5V active buzzer in parallel with the LED to provide an audio warning for noisy factory environments.

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 logic gate used in this safety system circuit?




Question 2: What happens to the output LED when both the temperature sensor and the jam sensor are Low (0V)?




Question 3: Which component is typically used to simulate the Temperature Sensor in a basic prototype of this project?




Question 4: What is the specific function of the 74HC32 IC in this circuit?




Question 5: Why are pull-down resistors typically used on the input switches in this logic circuit?




Question 6: If only the Jam Sensor triggers (High/5V), what is the expected state of the LED?




Question 7: What is the primary purpose of a resistor placed in series with the output LED?




Question 8: Which of the following is listed as a benefit of this system for 'Equipment Protection'?




Question 9: What is the standard logic voltage level (High) used for the sensors in this description?




Question 10: How does the system behave during a 'Critical Failure' where both sensors trigger simultaneously?




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: Redundant motor starter system

Redundant motor starter system prototype (Maker Style)

Level: Medium. Design a control circuit to start industrial machinery from a main panel or a remote safety remote.

Objective and use case

In this practical case, you will build a digital control circuit using an OR logic gate to operate a heavy-duty DC motor via a relay. The system allows the motor to be started from two distinct physical locations: the main control panel or a remote safety station.

  • Operational Redundancy: Ensures machinery can be activated from a secondary location if the primary panel is inaccessible.
  • Convenience: Allows operators to start a conveyor belt or fan from either end of a production line.
  • Signal Isolation: Uses low-voltage logic (5V) to safely switch a high-power inductive load (motor) via a relay driver.

Expected outcome:
* Pressing Button A (Main) starts the motor immediately.
* Pressing Button B (Remote) starts the motor immediately.
* Logic Output High ($V_{OH}$) measures approximately 5V when either button is pressed.
* The relay produces an audible «click» and the DC motor spins when the logic condition is met.

Target audience: Electronics students and hobbyists familiar with basic logic gates and relay driving.

Materials

  • V1: 5 V DC power supply, function: Main logic and relay power
  • U1: 74HC32, function: Quad 2-input OR gate
  • S1: Pushbutton (normally open), function: Main Start Panel
  • S2: Pushbutton (normally open), function: Remote Start Command
  • R1: 10 kΩ resistor, function: Pull-down for Input A
  • R2: 10 kΩ resistor, function: Pull-down for Input B
  • R3: 1 kΩ resistor, function: Transistor base current limiting
  • Q1: 2N2222 NPN Transistor, function: Relay driver switch
  • D1: 1N4007 Diode, function: Flyback protection for relay coil
  • K1: 5 V Relay (SPDT), function: High-current switching
  • M1: 5 V DC Motor, function: Industrial load simulation

Pin-out of the IC used

Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1A Input A Connected to Node START_MAIN
2 1B Input B Connected to Node START_REMOTE
3 1Y Output Connected to Node LOGIC_OUT
7 GND Ground Connected to Node 0
14 VCC Power Supply Connected to Node VCC

Wiring guide

  • V1 connects between node VCC and node 0 (GND).
  • S1 connects between node VCC and node START_MAIN.
  • R1 connects between node START_MAIN and node 0.
  • S2 connects between node VCC and node START_REMOTE.
  • R2 connects between node START_REMOTE and node 0.
  • U1 Pin 1 (1A) connects to node START_MAIN.
  • U1 Pin 2 (1B) connects to node START_REMOTE.
  • U1 Pin 3 (1Y) connects to node LOGIC_OUT.
  • U1 Pin 14 (VCC) connects to node VCC.
  • U1 Pin 7 (GND) connects to node 0.
  • R3 connects between node LOGIC_OUT and node BASE_DRIVE.
  • Q1 Base connects to node BASE_DRIVE.
  • Q1 Emitter connects to node 0.
  • Q1 Collector connects to node RELAY_COIL_LO.
  • K1 Coil Positive connects between node VCC and node RELAY_COIL_LO (Note: Coil connects VCC to Collector).
  • D1 connects between node RELAY_COIL_LO (Anode) and node VCC (Cathode) (Reverse biased).
  • K1 Common contact connects to node VCC.
  • K1 Normally Open (NO) contact connects to node MOTOR_PWR.
  • M1 connects between node MOTOR_PWR and node 0.

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

Practical case: Redundant motor starter system

      [ INPUTS ]                     [ LOGIC ]                     [ DRIVER ]                   [ OUTPUT / LOAD ]

 [ S1: Main Start ] --+
                      |
 [ R1: Pull-down  ] --+--(Pin 1)-->+------------+
                                   |            |
                                   | U1: 74HC32 |             (Base Sig)
                                   | (OR Gate)  |--(Pin 3)--> [ R3: 1k ] --> [ Q1: NPN ] --(Sink)--> [ K1: Relay Coil ]
                                   |            |                               |                    (w/ D1 Diode)
 [ S2: Remote Cmd ] --+--(Pin 2)-->+------------+                            [ GND ]                       |
                      |                                                                                (Magnetic)
 [ R2: Pull-down  ] --+                                                                                    |
                                                                                                           v
                                                                                                   [ K1: NO Contact ]
                                                                                                           |
                                                                                                     (Switched 5V)
                                                                                                           |
                                                                                                           v
                                                                                                    [ M1: DC Motor ]
                                                                                                           |
                                                                                                        [ GND ]
Schematic (ASCII)

Truth table

This system uses positive logic (active HIGH).

Input A (Main) Input B (Remote) Output Y (Logic) Relay State Motor State
0 (Open) 0 (Open) 0 (Low) OFF Stopped
0 (Open) 1 (Pressed) 1 (High) ON Running
1 (Pressed) 0 (Open) 1 (High) ON Running
1 (Pressed) 1 (Pressed) 1 (High) ON Running

Measurements and tests

  1. Input Validation ($V_{in_high}$): With neither button pressed, measure the voltage at START_MAIN and START_REMOTE. It should be 0V. Press S1 and verify the voltage rises to approx 5V.
  2. Logic Output Verification ($V_{out_logic}$): Place a multimeter probe on Pin 3 of U1. Press S1 OR S2. The voltage should jump from near 0V to $\approx$ 5V.
  3. Actuator Test (Motor RPM): Observe the motor. It should spin when the logic output is High. If using a tachometer, verify the Motor_RPM is consistent regardless of which button (S1 or S2) triggered the start.

SPICE netlist and simulation

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

* Redundant motor starter system
* Created based on BOM and Wiring Guide

* --- Power Supply ---
* V1: 5 V DC power supply
V1 VCC 0 DC 5

* --- Input Section ---
* S1: Pushbutton (Main Start)
* Wiring: Connects VCC to START_MAIN.
* Implementation: Voltage Controlled Switch driven by a Stimulus Pulse (V_ACT1)
* Timing: Period 200us, covers logic states 00, 10, 11, 01 combined with S2
V_ACT1 ACT1 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC START_MAIN ACT1 0 SW_PUSH

* R1: 10 kΩ resistor (Pull-down for Input A)
R1 START_MAIN 0 10k

* S2: Pushbutton (Remote Start)
* Wiring: Connects VCC to START_REMOTE.
* Implementation: Voltage Controlled Switch driven by a Stimulus Pulse (V_ACT2)
V_ACT2 ACT2 0 PULSE(0 5 10u 1u 1u 200u 400u)
S2 VCC START_REMOTE ACT2 0 SW_PUSH

* R2: 10 kΩ resistor (Pull-down for Input B)
R2 START_REMOTE 0 10k

* Model for Pushbuttons
.model SW_PUSH SW(Vt=2.5 Ron=0.1 Roff=10Meg)

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

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

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Redundant motor starter system
* Created based on BOM and Wiring Guide

* --- Power Supply ---
* V1: 5 V DC power supply
V1 VCC 0 DC 5

* --- Input Section ---
* S1: Pushbutton (Main Start)
* Wiring: Connects VCC to START_MAIN.
* Implementation: Voltage Controlled Switch driven by a Stimulus Pulse (V_ACT1)
* Timing: Period 200us, covers logic states 00, 10, 11, 01 combined with S2
V_ACT1 ACT1 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC START_MAIN ACT1 0 SW_PUSH

* R1: 10 kΩ resistor (Pull-down for Input A)
R1 START_MAIN 0 10k

* S2: Pushbutton (Remote Start)
* Wiring: Connects VCC to START_REMOTE.
* Implementation: Voltage Controlled Switch driven by a Stimulus Pulse (V_ACT2)
V_ACT2 ACT2 0 PULSE(0 5 10u 1u 1u 200u 400u)
S2 VCC START_REMOTE ACT2 0 SW_PUSH

* R2: 10 kΩ resistor (Pull-down for Input B)
R2 START_REMOTE 0 10k

* Model for Pushbuttons
.model SW_PUSH SW(Vt=2.5 Ron=0.1 Roff=10Meg)

* --- Logic Section ---
* U1: 74HC32 Quad 2-input OR gate
* Pins: 1(A), 2(B), 3(Y), 7(GND), 14(VCC)
* Implemented as a subcircuit to expose all pins
XU1 START_MAIN START_REMOTE LOGIC_OUT VCC 0 74HC32_OR

.subckt 74HC32_OR A B Y VCC GND
* Behavioral OR logic using continuous tanh function for convergence
* Logic: If (A + B) > Threshold(2.5V), Output High
* Function scales 0-1 range to 0-5V
B1 Y GND V = 5 * (tanh(10 * (V(A) + V(B) - 2.5)) + 1) / 2
.ends

* --- Driver Section ---
* R3: 1 kΩ resistor (Base current limiting)
R3 LOGIC_OUT BASE_DRIVE 1k

* Q1: 2N2222 NPN Transistor (Relay driver)
* Connections: Base=BASE_DRIVE, Collector=RELAY_COIL_LO, Emitter=0
Q1 RELAY_COIL_LO BASE_DRIVE 0 2N2222
.model 2N2222 NPN(IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8p CJE=25p TR=46n TF=411p ITF=0.6 VTF=1.7 XTF=3 RB=10 RC=0.3 RE=0.2)

* --- Relay Section ---
* K1: 5 V Relay (SPDT)
* Coil Connection: VCC to RELAY_COIL_LO
* Modeled as Inductor + Series Resistance
L_K1 VCC K1_INT 10m
R_K1_COIL K1_INT RELAY_COIL_LO 100

* D1: 1N4007 Diode (Flyback protection)
* Connections: Anode=RELAY_COIL_LO, Cathode=VCC
D1 RELAY_COIL_LO VCC 1N4007
.model 1N4007 D(IS=7n RS=0.034 N=1.26 BV=1000 IBV=5u CJO=10p)

* Relay Contact Switch
* Wiring: Common(VCC) to NO(MOTOR_PWR)
* Controlled by voltage across the coil (VCC - RELAY_COIL_LO)
* Threshold set to 3V (Energized state)
S_K1 VCC MOTOR_PWR VCC RELAY_COIL_LO SW_RELAY
.model SW_RELAY SW(Vt=3.0 Ron=0.05 Roff=100Meg)

* --- Motor Load ---
* M1: 5 V DC Motor
* Wiring: MOTOR_PWR to 0
* Modeled as resistive load with slight inductance
R_M1 MOTOR_PWR M1_INT 20
L_M1 M1_INT 0 1m

* --- Simulation Directives ---
.op
.tran 1u 500u

* Print directive for transient analysis
.print tran V(START_MAIN) V(START_REMOTE) V(LOGIC_OUT) V(BASE_DRIVE) V(RELAY_COIL_LO) V(MOTOR_PWR)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1304 rows)
Index   time            v(start_main)   v(start_remote) v(logic_out)
0	0.000000e+00	4.995005e-03	4.995005e-03	0.000000e+00
1	1.000000e-08	4.995005e-03	4.995005e-03	0.000000e+00
2	2.000000e-08	4.995005e-03	4.995005e-03	0.000000e+00
3	4.000000e-08	4.995005e-03	4.995005e-03	0.000000e+00
4	8.000000e-08	4.995005e-03	4.995005e-03	0.000000e+00
5	1.600000e-07	4.995005e-03	4.995005e-03	0.000000e+00
6	3.200000e-07	4.995005e-03	4.995005e-03	0.000000e+00
7	6.400000e-07	4.995005e-03	4.995005e-03	0.000000e+00
8	1.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
9	2.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
10	3.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
11	4.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
12	5.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
13	6.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
14	7.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
15	8.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
16	9.280000e-06	4.995005e-03	4.995005e-03	0.000000e+00
17	1.000000e-05	4.995005e-03	4.995005e-03	0.000000e+00
18	1.010000e-05	4.995005e-03	4.995005e-03	0.000000e+00
19	1.026000e-05	4.995005e-03	4.995005e-03	0.000000e+00
20	1.030750e-05	4.995005e-03	4.995005e-03	0.000000e+00
21	1.039062e-05	4.995005e-03	4.995005e-03	0.000000e+00
22	1.041363e-05	4.995005e-03	4.995005e-03	0.000000e+00
23	1.045390e-05	4.995005e-03	4.995005e-03	0.000000e+00
... (1280 more rows) ...

Common mistakes and how to avoid them

  1. Floating Inputs: Forgetting R1 or R2 allows the input pins to «float,» causing the motor to switch on randomly due to electrostatic noise. Always use pull-down resistors with the 74HC series.
  2. Missing Flyback Diode: Omitting D1 allows high-voltage spikes from the relay coil to destroy Q1 or reset U1 when the motor turns off. Always install the diode in reverse parallel to the coil.
  3. Driving Relay Directly: Trying to power the relay coil directly from U1 Pin 3 will damage the IC, as logic gates cannot supply enough current. Always use a transistor (Q1) as a driver.

Troubleshooting

  • Symptom: The motor runs continuously and never stops.
    • Cause: One input is floating or shorted to VCC.
    • Fix: Check R1/R2 connections and ensure buttons are not «Normally Closed» type.
  • Symptom: Logic Output goes High, but Relay does not click.
    • Cause: Transistor Q1 is not conducting or R3 is too high.
    • Fix: Check Q1 pinout (C-B-E) and ensure the emitter goes to Ground.
  • Symptom: The system resets or glitches when the relay turns off.
    • Cause: Inductive kickback noise.
    • Fix: Verify D1 is installed correctly (Cathode to VCC) and add a 100nF decoupling capacitor near U1 VCC.

Possible improvements and extensions

  1. Latch Circuit: Add a feedback loop so the motor stays on after the button is released (Start/Stop station).
  2. Safety Interlock: Add a 74HC08 (AND gate) in series with a «Safety Switch» so the motor only runs if the safety guard is closed AND a button is pressed.

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 logic gate used in this control circuit?




Question 2: What is the main purpose of the OR logic gate in this specific application?




Question 3: Which component is used to safely switch the high-power motor using the low-voltage logic signal?




Question 4: What is the function of the diode D1 (1N4007) typically found in relay driver circuits like this?




Question 5: What is the role of resistors R1 and R2 in this logic circuit context?




Question 6: Which transistor is commonly used as a general-purpose NPN switch for driving small relays?




Question 7: What is the expected Logic Output High (V_OH) voltage when a button is pressed?




Question 8: Why is this circuit considered to have 'Operational Redundancy'?




Question 9: What is the function of the base resistor (often 1 kΩ) connected to the transistor?




Question 10: What physical indication confirms the relay has activated?




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: Safety control with inverse logic

Safety control with inverse logic prototype (Maker Style)

Level: Medium. Design an emergency stop circuit where a high sensor signal halts a motor using a NOT gate.

Objective and use case

You will design and build a digital safety stop circuit using a 74HC04 inverter. In this configuration, the system defaults to an «ON» state (Motor running) and requires a logic HIGH signal from a sensor to force the system into an «OFF» state.

  • Industrial Automation: Used for emergency stop buttons (E-Stop) or limit switches where detecting an object must immediately cut power.
  • Fail-Safe Logic: Ensures that active intervention is required to stop the process, while the default idle state of the control logic keeps the machine running (assuming the physical actuator is wired to match).
  • Signal Inversion: Adapts sensors with active-high outputs to controllers or drivers requiring active-low disable signals.

Expected Outcome:
* Idle State: Input $0\text{ V}$ (Low) $\rightarrow$ Output $5\text{ V}$ (High) $\rightarrow$ Motor Simulator ON.
* Active State: Input $5\text{ V}$ (High) $\rightarrow$ Output $0\text{ V}$ (Low) $\rightarrow$ Motor Simulator OFF.
* Thresholds: Input voltages above $3.5\text{ V}$ are read as High; below $1.5\text{ V}$ are read as Low.

Target audience: Electronics students and hobbyists familiar with basic digital logic levels.

Materials

  • V1: 5 V DC supply, function: Main power source.
  • U1: 74HC04 Hex Inverter IC, function: Logic inversion.
  • S1: Push-button switch (NO), function: Simulates safety sensor activation.
  • R1: 10 kΩ resistor, function: Pull-down for sensor input.
  • R2: 330 Ω resistor, function: Current limiting for motor simulator.
  • D1: Green LED, function: DC-Motor-Sim (visual indicator of motor power).
  • C1: 100 nF capacitor, function: Decoupling for U1 power supply.

Pin-out of the IC used

Chip: 74HC04 (Hex Inverter)

Pin Name Logic function Connection in this case
1 1A Input Connected to Sensor Node (S1, R1)
2 1Y Output Connected to Motor Control Node (D1 via R2)
7 GND Ground Connected to 0 (GND)
14 VCC Power Connected to VCC (5 V)

Wiring guide

  • V1 connects between node VCC and node 0.
  • C1 connects between node VCC and node 0 (near U1).
  • S1 connects between node VCC and node SENSOR_IN.
  • R1 connects between node SENSOR_IN and node 0 (Pull-down).
  • U1 Pin 14 connects to VCC.
  • U1 Pin 7 connects to 0.
  • U1 Pin 1 connects to SENSOR_IN.
  • U1 Pin 2 connects to MOTOR_CTRL.
  • R2 connects between node MOTOR_CTRL and node LED_ANODE.
  • D1 connects between node LED_ANODE (Anode) and node 0 (Cathode).

Conceptual block diagram

Conceptual block diagram — 74HC04 NOT gate

Schematic

[ INPUT STAGE ]                     [ LOGIC STAGE ]                     [ OUTPUT STAGE ]

 (VCC)
   |
 [ S1: Button (NO) ] --+
                       |
                       +--(SENSOR_IN)-->+-----------------------+
                       |                |       U1: 74HC04      |
 [ R1: 10k Resistor ] -+                |     (Hex Inverter)    |
   |                                    | Pin 1           Pin 2 | --(MOTOR_CTRL)--> [ R2: 330R ] --> [ D1: Green LED ] --> (GND)
 (GND)                                  |                       |
                                        | Power: [ V1: 5V ]     |
                                        | Filter: [ C1: 100nF ] |
                                        +-----------------------+
Schematic (ASCII)

Truth table

In this safety logic, $0$ represents $0\text{ V}$ (Ground) and $1$ represents $5\text{ V}$ (VCC).

Sensor Input (Pin 1) Motor Command Output (Pin 2) System State
0 (Low) 1 (High) RUNNING (Default)
1 (High) 0 (Low) STOPPED (Emergency)

Measurements and tests

  1. Idle State Validation:

    • Ensure S1 is not pressed.
    • Measure voltage at SENSOR_IN relative to 0. Expected: $\approx 0\text{ V}$.
    • Measure voltage at MOTOR_CTRL. Expected: $\approx 5\text{ V}$.
    • Verify D1 (Motor Sim) is lit.
  2. Active Stop Validation:

    • Press and hold S1.
    • Measure voltage at SENSOR_IN. Expected: $5\text{ V}$.
    • Measure voltage at MOTOR_CTRL. Expected: $\approx 0\text{ V}$.
    • Verify D1 (Motor Sim) turns OFF immediately.
  3. Propagation Delay (Optional):

    • If using an oscilloscope, connect Channel 1 to SENSOR_IN and Channel 2 to MOTOR_CTRL.
    • Trigger on the rising edge of Channel 1.
    • Measure the time difference between the input reaching 50% and the output falling to 50%. Typical values for 74HC04 are in the nanosecond range ($7\text{–}15\text{ ns}$).

SPICE netlist and simulation

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

* Practical case: Safety control with inverse logic

* --- Power Supply ---
* V1 connects between node VCC and node 0
V1 VCC 0 DC 5

* --- Decoupling ---
* C1 connects between node VCC and node 0 (near U1)
C1 VCC 0 100n

* --- Input Stage: Sensor (Push Button) ---
* S1 connects between node VCC and node SENSOR_IN
* Implemented as a Voltage-Controlled Switch to simulate the physical connection
S1 VCC SENSOR_IN S1_CTRL 0 SW_PUSH
.model SW_PUSH SW(Vt=2.5 Ron=0.1 Roff=100Meg)

* Control source for S1 (Simulates user pressing the button)
* Pulse: Press at 200us, hold for 300us, release (Total simulation 1ms)
V_S1_ACT S1_CTRL 0 PULSE(0 5 200u 1u 1u 300u 1ms)

* R1 connects between node SENSOR_IN and node 0 (Pull-down)
R1 SENSOR_IN 0 10k

* --- Logic Stage: U1 (74HC04 Hex Inverter) ---
* U1 Pin 14 connects to VCC
* U1 Pin 7 connects to 0
* U1 Pin 1 connects to SENSOR_IN
* U1 Pin 2 connects to MOTOR_CTRL
* Implemented using a Behavioral Source (B-Source) for robust logic simulation
* Logic: Inverts SENSOR_IN. Uses sigmoid function for convergence.
* ... (truncated in public view) ...

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

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Safety control with inverse logic

* --- Power Supply ---
* V1 connects between node VCC and node 0
V1 VCC 0 DC 5

* --- Decoupling ---
* C1 connects between node VCC and node 0 (near U1)
C1 VCC 0 100n

* --- Input Stage: Sensor (Push Button) ---
* S1 connects between node VCC and node SENSOR_IN
* Implemented as a Voltage-Controlled Switch to simulate the physical connection
S1 VCC SENSOR_IN S1_CTRL 0 SW_PUSH
.model SW_PUSH SW(Vt=2.5 Ron=0.1 Roff=100Meg)

* Control source for S1 (Simulates user pressing the button)
* Pulse: Press at 200us, hold for 300us, release (Total simulation 1ms)
V_S1_ACT S1_CTRL 0 PULSE(0 5 200u 1u 1u 300u 1ms)

* R1 connects between node SENSOR_IN and node 0 (Pull-down)
R1 SENSOR_IN 0 10k

* --- Logic Stage: U1 (74HC04 Hex Inverter) ---
* U1 Pin 14 connects to VCC
* U1 Pin 7 connects to 0
* U1 Pin 1 connects to SENSOR_IN
* U1 Pin 2 connects to MOTOR_CTRL
* Implemented using a Behavioral Source (B-Source) for robust logic simulation
* Logic: Inverts SENSOR_IN. Uses sigmoid function for convergence.
* Vout = VCC if Vin < 2.5V, else 0V.
B_U1 MOTOR_CTRL 0 V = V(VCC) * (1 / (1 + exp(50 * (V(SENSOR_IN) - 2.5))))

* --- Output Stage: Motor Simulator (LED) ---
* R2 connects between node MOTOR_CTRL and node LED_ANODE
R2 MOTOR_CTRL LED_ANODE 330

* D1 connects between node LED_ANODE (Anode) and node 0 (Cathode)
D1 LED_ANODE 0 LED_GREEN
.model LED_GREEN D(IS=1e-22 RS=5 N=1.5 BV=5 IBV=10u CJO=10p)

* --- Simulation Directives ---
* Perform a transient analysis to observe the button press event
.op
.tran 1u 1ms

* Print required nodes for verification
.print tran V(SENSOR_IN) V(MOTOR_CTRL) V(LED_ANODE)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1061 rows)
Index   time            v(sensor_in)    v(motor_ctrl)   v(led_anode)
0	0.000000e+00	4.999500e-04	5.000000e+00	1.833072e+00
1	1.000000e-08	4.999500e-04	5.000000e+00	1.833072e+00
2	2.000000e-08	4.999500e-04	5.000000e+00	1.833072e+00
3	4.000000e-08	4.999500e-04	5.000000e+00	1.833072e+00
4	8.000000e-08	4.999500e-04	5.000000e+00	1.833072e+00
5	1.600000e-07	4.999500e-04	5.000000e+00	1.833072e+00
6	3.200000e-07	4.999500e-04	5.000000e+00	1.833072e+00
7	6.400000e-07	4.999500e-04	5.000000e+00	1.833072e+00
8	1.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
9	2.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
10	3.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
11	4.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
12	5.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
13	6.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
14	7.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
15	8.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
16	9.280000e-06	4.999500e-04	5.000000e+00	1.833072e+00
17	1.028000e-05	4.999500e-04	5.000000e+00	1.833072e+00
18	1.128000e-05	4.999500e-04	5.000000e+00	1.833072e+00
19	1.228000e-05	4.999500e-04	5.000000e+00	1.833072e+00
20	1.328000e-05	4.999500e-04	5.000000e+00	1.833072e+00
21	1.428000e-05	4.999500e-04	5.000000e+00	1.833072e+00
22	1.528000e-05	4.999500e-04	5.000000e+00	1.833072e+00
23	1.628000e-05	4.999500e-04	5.000000e+00	1.833072e+00
... (1037 more rows) ...

Common mistakes and how to avoid them

  1. Floating Input: Omitting R1 (Pull-down) causes the input to float, making the motor toggle randomly or oscillate based on electromagnetic noise. Fix: Always ensure inputs have a defined path to ground or VCC when the switch is open.
  2. Overloading the Output: Connecting a real DC motor directly to the 74HC04 output. The chip can only source $\approx 20\text{ mA}$. Fix: Use the output to drive a transistor (BJT or MOSFET) which then switches the actual motor.
  3. Confusing Logic Families: Using a 74LS04 with high-value resistors or incorrect voltage levels. Fix: Stick to the 74HC series for 5 V CMOS compatibility and high impedance inputs.

Troubleshooting

  • Symptom: The Motor (LED) is always OFF.
    • Cause: Input pin stuck HIGH or damaged IC.
    • Fix: Check voltage at Pin 1. If 0 V, replace U1.
  • Symptom: The Motor (LED) is always ON, even when button is pressed.
    • Cause: Input shorted to GND or button S1 not making contact.
    • Fix: Use a multimeter to verify continuity across S1 when pressed.
  • Symptom: LED flickers when touching the wire.
    • Cause: Missing pull-down resistor R1.
    • Fix: Verify R1 is connected securely between Pin 1 and Ground.

Possible improvements and extensions

  1. Latching Safety Circuit: Add a feedback loop or an SR Latch so that once the emergency stop is triggered, the motor remains off even if the button is released (requires a manual reset).
  2. Status Indicators: Add a Red LED connected to the input side (buffered) to indicate «EMERGENCY STATE» visually alongside the motor shutdown.

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 74HC04 IC in the described emergency stop circuit?




Question 2: In the 'Idle State' of this circuit (Input 0 V), what is the status of the Motor Simulator?




Question 3: What input signal is required to force the system into an 'OFF' state?




Question 4: Which component is typically used to simulate the safety sensor activation in this type of lab setup?




Question 5: What is the purpose of a pull-down resistor (like R1) in this sensor input circuit?




Question 6: According to the expected outcome, what output voltage corresponds to an input of 0 V?




Question 7: What is the voltage threshold above which the input is definitely recognized as High?




Question 8: Which component acts as the visual indicator for the 'Motor Simulator' in this design?




Question 9: What is a typical industrial use case mentioned for this specific circuit logic?




Question 10: Why is this logic configuration described as 'Fail-Safe' regarding the machine's operation?




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: Signal inverter with indicator LED

Signal inverter with indicator LED prototype (Maker Style)

Level: Basic – Understand the logic of a NOT gate (inverter) by observing opposite input and output states via light indicators.

Objective and use case

In this practical case, you will build a digital logic circuit using a 74HC04 Hex Inverter IC. The circuit will demonstrate the fundamental inversion function where a HIGH input signal results in a LOW output signal, visually confirmed by two LEDs operating in alternate states.

Why it is useful:
* Safety Interlocks: Used in machinery to ensure a system stops (logic LOW) when a sensor is activated (logic HIGH).
* Status Indicators: Allows creating «Standby» lights that turn ON only when the main power switch is OFF.
* Logic Level Adaptation: Essential for interfacing active-high sensors with active-low microcontroller inputs.
* Signal Conditioning: Cleans up noisy digital signals and ensures distinct logic levels.

Expected outcome:
* Input LED (Green): Turns ON when the switch is pressed (Logic 1).
* Output LED (Red): Turns OFF when the switch is pressed (Logic 0).
* Inverse Relationship: When the switch is released (Logic 0), the Red LED turns ON.
* Voltage Levels: Input at 0V $\rightarrow$ Output $\approx$ 5V; Input at 5V $\rightarrow$ Output $\approx$ 0V.

Target audience: Students and hobbyists (Level: Basic).

Materials

  • V1: 5 V DC supply (battery or regulated power supply)
  • S1: SPST toggle or tactile switch, function: Input signal generator
  • U1: 74HC04 (Hex Inverter IC), function: Logic inversion
  • R1: 10 kΩ resistor, function: Pull-down resistor for input VA
  • R2: 330 Ω resistor, function: Current limiting for input LED (D1)
  • R3: 330 Ω resistor, function: Current limiting for output LED (D2)
  • D1: Green LED, function: Input state indicator (Active High)
  • D2: Red LED, function: Output state indicator (Active High)

Pin-out of the IC used

Chip Selected: 74HC04 (Hex Inverter)

Pin Name Logic function Connection in this case
1 1A Input Connected to Switch S1 and Pull-down R1
2 1Y Output Connected to Output LED (D2) via R3
7 GND Ground Connected to Power Supply Negative (0V)
14 VCC Power Connected to Power Supply Positive (5V)

Note: Pins 3, 4, 5, 6, 8, 9, 10, 11, 12, and 13 are unused in this single-gate demonstration. In a permanent circuit, unused inputs on CMOS chips should be tied to GND.

Wiring guide

  • VCC: Connect positive terminal of V1, Pin 14 of U1, and one side of S1.
  • 0 (GND): Connect negative terminal of V1, Pin 7 of U1, one side of R1, cathode of D1, and cathode of D2.
  • VA (Input Node): Connect the other side of S1, the other side of R1, Pin 1 of U1, and one side of R2.
  • Input Indicator: Connect the other side of R2 to the anode of D1.
  • VOUT (Output Node): Connect Pin 2 of U1 to one side of R3.
  • Output Indicator: Connect the other side of R3 to the anode of D2.

Conceptual block diagram

Conceptual block diagram — 74HC04 NOT gate

Schematic

[ INPUT GENERATION ]               [ LOGIC & MONITORING ]               [ OUTPUT STAGE ]

    [ VCC ] -> [ Switch S1 ] --+
                               |
                               V
                           (Node VA) --(Pin 1)--> [ U1: 74HC04 ] --(Pin 2)--> [ R3: 330 ] -> [ D2: Red ] -> GND
                               |                  (Hex Inverter)
                               |
    [ GND ] <- [ R1: 10k ] <---+
                               |
                               +----(Monitor)---> [ R2: 330 ] --> [ D1: Green ] -> GND
Schematic (ASCII)

Truth table

The 74HC04 contains six independent NOT gates. We are using one.

Input (VA) Switch State Output (VOUT) Green LED (D1) Red LED (D2)
0 (Low) Open 1 (High) OFF ON
1 (High) Closed 0 (Low) ON OFF

Measurements and tests

To validate the circuit, perform the following steps using a multimeter and visual observation:

  1. Default State Check:

    • Ensure S1 is open (not pressed).
    • Measure voltage at VA relative to GND. It should be 0V.
    • Measure voltage at VOUT relative to GND. It should be close to 5V.
    • Visual: Red LED (D2) is ON; Green LED (D1) is OFF.
  2. Active State Check:

    • Close (press) S1.
    • Measure voltage at VA. It should be close to 5V.
    • Measure voltage at VOUT. It should be close to 0V.
    • Visual: Red LED (D2) turns OFF; Green LED (D1) turns ON.
  3. Transition Threshold (Optional):

    • If using a variable voltage source instead of S1, slowly increase voltage at VA. The output state will flip when the input crosses approximately half of VCC (approx. 2.5V for 74HC series).

SPICE netlist and simulation

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

* Practical case: Signal inverter with indicator LED

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

* --- Input Signal Generator (Switch S1) ---
* S1 connects VCC to VA (Input Node) when pressed.
* R1 pulls VA to Ground when S1 is open.
* V_S1_ACT simulates the user pressing the button (Active High).
* Pulse timing: Wait 10u, Press for 100u, Repeat every 200u.
V_S1_ACT S_ACT 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC VA S_ACT 0 SW_IDEAL

* --- Input Circuit Components ---
R1 VA 0 10k
R2 VA N_D1_A 330
D1 N_D1_A 0 LED_GREEN

* --- Logic Inverter (U1: 74HC04) ---
* Wiring: Pin1=VA, Pin2=VOUT, Pin7=GND, Pin14=VCC
* Implemented as a behavioral subcircuit to match pinout
XU1 VA VOUT 0 VCC 74HC04_1G

* --- Output Circuit Components ---
R3 VOUT N_D2_A 330
D2 N_D2_A 0 LED_RED

* --- Models ---
* Voltage Controlled Switch Model
.model SW_IDEAL SW(Vt=2.5 Ron=1 Roff=10Meg)
* ... (truncated in public view) ...

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

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Signal inverter with indicator LED

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

* --- Input Signal Generator (Switch S1) ---
* S1 connects VCC to VA (Input Node) when pressed.
* R1 pulls VA to Ground when S1 is open.
* V_S1_ACT simulates the user pressing the button (Active High).
* Pulse timing: Wait 10u, Press for 100u, Repeat every 200u.
V_S1_ACT S_ACT 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC VA S_ACT 0 SW_IDEAL

* --- Input Circuit Components ---
R1 VA 0 10k
R2 VA N_D1_A 330
D1 N_D1_A 0 LED_GREEN

* --- Logic Inverter (U1: 74HC04) ---
* Wiring: Pin1=VA, Pin2=VOUT, Pin7=GND, Pin14=VCC
* Implemented as a behavioral subcircuit to match pinout
XU1 VA VOUT 0 VCC 74HC04_1G

* --- Output Circuit Components ---
R3 VOUT N_D2_A 330
D2 N_D2_A 0 LED_RED

* --- Models ---
* Voltage Controlled Switch Model
.model SW_IDEAL SW(Vt=2.5 Ron=1 Roff=10Meg)

* LED Models (Generic)
.model LED_GREEN D(IS=1e-22 RS=5 N=1.5 CJO=50p)
.model LED_RED D(IS=1e-22 RS=5 N=1.5 CJO=50p)

* --- Subcircuits ---
* 74HC04 Hex Inverter (Single Gate Representation)
* Pins: 1=Input, 2=Output, 7=GND, 14=VCC
.subckt 74HC04_1G 1 2 7 14
* Behavioral source implementing Inverter Logic: Vout = NOT(Vin)
* Uses sigmoid function for convergence: 1 / (1 + exp(k*(Vin - Vth)))
* Multiplied by V(14) to track supply voltage
B1 2 7 V = V(14) * (1 / (1 + exp(50 * (V(1) - 2.5))))
.ends

* --- Analysis Directives ---
* Transient analysis for 500us to capture pulse cycles
.tran 1u 500u

* Output data for plotting/logging
.print tran V(VA) V(VOUT) V(N_D1_A) V(N_D2_A)

.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1334 rows)
Index   time            v(va)           v(vout)         v(n_d1_a)
0	0.000000e+00	4.995005e-03	5.000000e+00	4.995005e-03
1	1.000000e-08	4.995005e-03	5.000000e+00	4.995005e-03
2	2.000000e-08	4.995005e-03	5.000000e+00	4.995005e-03
3	4.000000e-08	4.995005e-03	5.000000e+00	4.995005e-03
4	8.000000e-08	4.995005e-03	5.000000e+00	4.995005e-03
5	1.600000e-07	4.995005e-03	5.000000e+00	4.995005e-03
6	3.200000e-07	4.995005e-03	5.000000e+00	4.995005e-03
7	6.400000e-07	4.995005e-03	5.000000e+00	4.995005e-03
8	1.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
9	2.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
10	3.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
11	4.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
12	5.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
13	6.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
14	7.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
15	8.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
16	9.280000e-06	4.995005e-03	5.000000e+00	4.995005e-03
17	1.000000e-05	4.995005e-03	5.000000e+00	4.995005e-03
18	1.010000e-05	4.995005e-03	5.000000e+00	4.995005e-03
19	1.026000e-05	4.995005e-03	5.000000e+00	4.995005e-03
20	1.030750e-05	4.995005e-03	5.000000e+00	4.995005e-03
21	1.039062e-05	4.995005e-03	5.000000e+00	4.995005e-03
22	1.041363e-05	4.995005e-03	5.000000e+00	4.995005e-03
23	1.045390e-05	4.995005e-03	5.000000e+00	4.995005e-03
... (1310 more rows) ...

Common mistakes and how to avoid them

  1. Floating Inputs:
    • Error: Omitting the pull-down resistor (R1). The input floats when the switch is open, causing the output LED to flicker or oscillate due to electromagnetic noise.
    • Solution: Always ensure the input has a defined path to GND (via R1) when the switch is open.
  2. Missing Current Limiting Resistors:
    • Error: Connecting LEDs directly to the IC output or VCC without R2 or R3.
    • Solution: Always use series resistors (330 Ω to 1 kΩ) to prevent burning out the LED or damaging the 74HC04 output stage.
  3. Confusing Pin Numbering:
    • Error: Wiring the IC upside down or counting pins from the wrong side.
    • Solution: Identify the notch/dot on the package. Pin 1 is to the left of the notch when the notch faces up.

Troubleshooting

  • Both LEDs remain OFF:
    • Cause: Power supply disconnected or IC inserted backwards.
    • Fix: Check VCC (Pin 14) and GND (Pin 7) connections. Ensure 5V is present.
  • Output LED (Red) never turns OFF:
    • Cause: The input VA is not reaching Logic High (5V) effectively, or the IC is damaged.
    • Fix: Check the continuity of Switch S1. Measure voltage at Pin 1 while pressing the switch.
  • Output LED (Red) is dim:
    • Cause: Resistor R3 is too high in value, or the supply voltage is too low.
    • Fix: Verify R3 is 330 Ω. Check if V1 is actually 5V.

Possible improvements and extensions

  1. Buffer Circuit: Connect the output of the first inverter (Pin 2) into the input of a second inverter (Pin 3). The output of the second inverter (Pin 4) will now match the original input state, acting as a non-inverting buffer.
  2. Square Wave Oscillator: Use three NOT gates in a ring loop (Logic Ring Oscillator) to create a circuit that blinks the LEDs automatically without a switch.

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 74HC04 IC used in this circuit?




Question 2: Which logic gate behavior is demonstrated in this practical case?




Question 3: If the input signal to the inverter is HIGH, what is the resulting output signal?




Question 4: What is the function of the 10 kΩ resistor (R1) in the circuit?




Question 5: When the switch is pressed (Logic 1), what is the state of the Input LED (Green)?




Question 6: When the switch is released (Logic 0), what happens to the Output LED (Red)?




Question 7: What is a practical use case for this circuit mentioned in the text?




Question 8: Assuming a 5V supply, what is the approximate output voltage when the input is at 0V?




Question 9: Why are the 330 Ω resistors (R2 and R3) used in the circuit?




Question 10: Which component acts as the input signal generator in this setup?




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: Emergency water pump activation

Emergency water pump activation prototype (Maker Style)

Level: Basic. Design a control system that activates a drainage pump if either of two water level sensors is triggered.

Objective and use case

You will build a logic control circuit using a 74HC32 (OR Gate) to drive a DC motor via a transistor driver whenever water is detected by at least one sensor.

Why it is useful:
* Flood Prevention: Automatically activates a sump pump in a basement when water rises to a critical level.
* Industrial Safety: Prevents tank overflows by draining liquid if primary or secondary high-level sensors are triggered.
* Marine Applications: Activates a boat’s bilge pump if water enters the hull from either the port or starboard side.
* Redundancy: Ensures the pump starts even if one sensor fails (provided the other detects the water).

Expected outcome:
* The motor turns ON if Sensor A is HIGH.
* The motor turns ON if Sensor B is HIGH.
* The motor turns ON if both sensors are HIGH.
* The logic output at the gate pin reads ~5 V (Logic 1) when active.
* Target audience: Basic electronics students and hobbyists.

Materials

  • V1: 5 V DC supply, function: Main circuit power.
  • S1: SPST Switch, function: Simulates Water Level Sensor A.
  • S2: SPST Switch, function: Simulates Water Level Sensor B.
  • R1: 10 kΩ resistor, function: Pull-down for Sensor A.
  • R2: 10 kΩ resistor, function: Pull-down for Sensor B.
  • U1: 74HC32 Quad 2-Input OR Gate.
  • R3: 1 kΩ resistor, function: Transistor base current limiting.
  • Q1: 2N2222 NPN Transistor, function: Motor driver switch.
  • D1: 1N4007 Diode, function: Flyback protection (snubber).
  • M1: 5 V DC Motor, function: Drainage pump simulation.

Pin-out of the IC used

Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1A Input A Connected to Node SENS_A
2 1B Input B Connected to Node SENS_B
3 1Y Output Connected to Node GATE_OUT
7 GND Ground Connected to Node 0 (GND)
14 VCC Power (+5V) Connected to Node VCC

Wiring guide

Construct the circuit following these node connections:

  • VCC: Connect positive terminal of V1, one side of S1, one side of S2, Pin 14 of U1, and the positive terminal of M1.
  • 0 (GND): Connect negative terminal of V1, Pin 7 of U1, Emitter of Q1, bottom of R1, and bottom of R2.
  • SENS_A: Connect other side of S1, top of R1, and Pin 1 of U1.
  • SENS_B: Connect other side of S2, top of R2, and Pin 2 of U1.
  • GATE_OUT: Connect Pin 3 of U1 to one side of R3.
  • BASE_NODE: Connect the other side of R3 to the Base of Q1.
  • MOTOR_DRIVE: Connect the Collector of Q1, the negative terminal of M1, and the Anode of D1.
  • PROTECTION: Connect the Cathode of D1 to VCC (Across the motor).

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

[ INPUTS / SENSORS ]                 [ LOGIC CONTROL ]                   [ ACTUATOR / OUTPUT ]

                                          +----------------+
    [ Switch S1 ]                         |                |
    [ + R1 (PD) ] --(SENS_A / Pin 1)----->|   U1: 74HC32   |
                                          |   (OR Gate)    |
                                          |                |--(GATE_OUT / Pin 3)--> [ Resistor R3 ]
                                          |   Logic:       |                            |
    [ Switch S2 ]                         |   If A OR B    |                            |
    [ + R2 (PD) ] --(SENS_B / Pin 2)----->|   Then HIGH    |                            |
                                          |                |                      (BASE_NODE)
                                          +----------------+                            |
                                                                                        v
                                                                               [ Q1 NPN Transistor ]
                                                                               (Electronic Switch)
                                                                                        |
                                                                                        | (Switches GND)
                                                                                        |
                                                                                  (MOTOR_DRIVE)
                                                                                        |
                                                                                        v
                                                                             [ Motor M1 + Diode D1 ]
                                                                             (Connected to VCC)
Schematic (ASCII)

Truth table

This table describes the logic state of the 74HC32 and the resulting physical action of the pump.

Sensor A (Input 1A) Sensor B (Input 1B) Logic Output (Pin 1Y) Transistor State Pump Status
Low (0) Low (0) Low (0) OFF (Open) OFF
Low (0) High (1) High (1) ON (Saturation) ON
High (1) Low (0) High (1) ON (Saturation) ON
High (1) High (1) High (1) ON (Saturation) ON

Measurements and tests

  1. Power Check: Before connecting the motor, measure the voltage between VCC and GND. It should be stable at 5 V.
  2. Idle State: Ensure both switches are open. Measure voltage at Pin 3 (GATE_OUT). It should be ~0 V. The motor should be stopped.
  3. Sensor A Activation: Close S1. Measure voltage at Pin 1 (Input A). It should be 5 V. Pin 3 should go High, and the motor should spin.
  4. Sensor B Activation: Open S1 and close S2. Verify the motor spins.
  5. Simultaneous Activation: Close both S1 and S2. The motor should remain spinning.
  6. Current Draw: Place an ammeter in series with the motor. Note the current consumption (typically 50mA to 200mA for small hobby motors).

SPICE netlist and simulation

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

* Emergency water pump activation fixed

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

* --- Switches & Sensors ---
* S1: Simulates Water Level Sensor A
V_ACT_A ACT_A 0 PULSE(0 5 0 1u 1u 1m 2m)
S1 VCC SENS_A ACT_A 0 SW_MOD

* R1: Pull-down for Sensor A
R1 SENS_A 0 10k

* S2: Simulates Water Level Sensor B
V_ACT_B ACT_B 0 PULSE(0 5 0 1u 1u 0.5m 1m)
S2 VCC SENS_B ACT_B 0 SW_MOD

* R2: Pull-down for Sensor B
R2 SENS_B 0 10k

* --- Logic Gate U1: 74HC32 (Quad OR) ---
* Pin 1: SENS_A, Pin 2: SENS_B, Pin 3: GATE_OUT, Pin 7: GND, Pin 14: VCC
XU1 SENS_A SENS_B GATE_OUT 0 VCC 74HC32_GATE

* --- Driver Stage ---
* R3: Base resistor
R3 GATE_OUT BASE_NODE 1k

* Q1: NPN Transistor Switch
* Collector: MOTOR_DRIVE, Base: BASE_NODE, Emitter: 0 (GND)
* ... (truncated in public view) ...

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

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Emergency water pump activation fixed

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

* --- Switches & Sensors ---
* S1: Simulates Water Level Sensor A
V_ACT_A ACT_A 0 PULSE(0 5 0 1u 1u 1m 2m)
S1 VCC SENS_A ACT_A 0 SW_MOD

* R1: Pull-down for Sensor A
R1 SENS_A 0 10k

* S2: Simulates Water Level Sensor B
V_ACT_B ACT_B 0 PULSE(0 5 0 1u 1u 0.5m 1m)
S2 VCC SENS_B ACT_B 0 SW_MOD

* R2: Pull-down for Sensor B
R2 SENS_B 0 10k

* --- Logic Gate U1: 74HC32 (Quad OR) ---
* Pin 1: SENS_A, Pin 2: SENS_B, Pin 3: GATE_OUT, Pin 7: GND, Pin 14: VCC
XU1 SENS_A SENS_B GATE_OUT 0 VCC 74HC32_GATE

* --- Driver Stage ---
* R3: Base resistor
R3 GATE_OUT BASE_NODE 1k

* Q1: NPN Transistor Switch
* Collector: MOTOR_DRIVE, Base: BASE_NODE, Emitter: 0 (GND)
Q1 MOTOR_DRIVE BASE_NODE 0 2N2222MOD

* --- Output Load (Motor) ---
* M1: 5V DC Motor simulation (Inductive Load)
* Fixed: Subcircuit name changed from DC_MOTOR_MODEL to DC_MOTOR to match definition
XM1 VCC MOTOR_DRIVE DC_MOTOR

* --- Protection ---
* D1: Flyback Diode
D1 MOTOR_DRIVE VCC 1N4007MOD

* --- Models and Subcircuits ---

* Switch Model
.model SW_MOD SW(Vt=2.5 Vh=0.1 Ron=0.1 Roff=10Meg)

* Transistor Model (Generic 2N2222)
.model 2N2222MOD NPN(Is=14.34f Xti=3 Eg=1.11 Vaf=74.03 Bf=255.9 Ne=1.307 Ise=14.34f Ikf=.2847 Xtb=1.5 Br=6.092 Nc=2 Isc=0 Ikr=0 Rc=1 Cjc=7.306p Mjc=.3416 Vjc=.75 Fc=.5 Cje=22.01p Mje=.377 Vje=.75 Tr=46.91n Tf=411.1p Itf=.6 Vtf=1.7 Xtf=3 Rb=10)

* Diode Model (Generic 1N4007)
.model 1N4007MOD D(IS=7.027n RS=0.03415 N=1.267 EG=1.11 XTI=3 BV=1000 IBV=10m CJO=10p VJ=0.7 M=0.5 FC=0.5 TT=100n)

* Motor Model (Simple RL series)
.subckt DC_MOTOR POS NEG
Rcoil POS INT 50
Lcoil INT NEG 5m
.ends

* 74HC32 Logic Gate Model (Behavioral)
* Implements OR logic: OUT = 1 if (IN1=1 OR IN2=1)
.subckt 74HC32_GATE IN1 IN2 OUT GND VCC
B_OR OUT GND V=V(VCC) * ( (1/(1+exp(-20*(V(IN1)-2.5)))) + (1/(1+exp(-20*(V(IN2)-2.5)))) - ( (1/(1+exp(-20*(V(IN1)-2.5)))) * (1/(1+exp(-20*(V(IN2)-2.5)))) ) )
.ends

* --- Simulation Directives ---
.tran 10u 2.5m

* Print required nodes for validation
.print tran V(SENS_A) V(SENS_B) V(GATE_OUT) V(BASE_NODE) V(MOTOR_DRIVE)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (2750 rows)
Index   time            v(sens_a)       v(sens_b)       v(gate_out)
0	0.000000e+00	4.995005e-03	4.995005e-03	2.131385e-21
1	1.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
2	2.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
3	4.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
4	8.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
5	1.600000e-07	4.995005e-03	4.995005e-03	2.131385e-21
6	3.200000e-07	4.995005e-03	4.995005e-03	2.131385e-21
7	3.600000e-07	4.995005e-03	4.995005e-03	2.131385e-21
8	4.300000e-07	4.995005e-03	4.995005e-03	2.131385e-21
9	4.493750e-07	4.995005e-03	4.995005e-03	2.131385e-21
10	4.832812e-07	4.995005e-03	4.995005e-03	2.131385e-21
11	5.162979e-07	4.999950e+00	4.999950e+00	5.000000e+00
12	5.395702e-07	4.999950e+00	4.999950e+00	5.000000e+00
13	5.611432e-07	4.999950e+00	4.999950e+00	5.000000e+00
14	5.884211e-07	4.999950e+00	4.999950e+00	5.000000e+00
15	6.429769e-07	4.999950e+00	4.999950e+00	5.000000e+00
16	7.520886e-07	4.999950e+00	4.999950e+00	5.000000e+00
17	9.703119e-07	4.999950e+00	4.999950e+00	5.000000e+00
18	1.000000e-06	4.999950e+00	4.999950e+00	5.000000e+00
19	1.030157e-06	4.999950e+00	4.999950e+00	5.000000e+00
20	1.090472e-06	4.999950e+00	4.999950e+00	5.000000e+00
21	1.211102e-06	4.999950e+00	4.999950e+00	5.000000e+00
22	1.452361e-06	4.999950e+00	4.999950e+00	5.000000e+00
23	1.934879e-06	4.999950e+00	4.999950e+00	5.000000e+00
... (2726 more rows) ...

Common mistakes and how to avoid them

  1. Floating Inputs: Forgetting the pull-down resistors (R1, R2).
    • Solution: Always connect inputs to ground via a resistor (10kΩ) so they default to 0 V when switches are open.
  2. Missing Flyback Diode: Omitting D1 across the motor.
    • Solution: Inductive loads generate voltage spikes when turned off. Always place a diode in reverse bias across the motor to protect the transistor.
  3. Overloading the Gate: Connecting the motor directly to the 74HC32 output pin.
    • Solution: Logic gates can only supply small currents (~20mA). Use a transistor (Q1) to handle the higher current required by the motor.

Troubleshooting

  • Symptom: Motor runs continuously even when switches are open.
    • Cause: Inputs are floating or the transistor is shorted.
    • Fix: Check R1/R2 connections or replace Q1.
  • Symptom: IC gets very hot immediately.
    • Cause: VCC and GND pins are reversed or shorted.
    • Fix: Disconnect power immediately and verify Pin 14 and Pin 7 wiring.
  • Symptom: Logic output is High (5V), but motor does not spin.
    • Cause: Base resistor (R3) too high or transistor gain too low.
    • Fix: Verify R3 is 1kΩ. Ensure the motor power supply is adequate.

Possible improvements and extensions

  1. Visual Indicators: Add an LED with a current-limiting resistor in parallel with the motor to provide a visual warning when the pump is active.
  2. Hysteresis/Latching: Replace the OR gate with an SR Latch logic. This would keep the pump running even if the water level drops momentarily, ensuring a full drain cycle until a bottom sensor resets it.

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 objective of the control system described?




Question 2: Which logic gate IC is used to process the sensor inputs in this project?




Question 3: What component is typically used to simulate the digital input of water level sensors in this basic circuit?




Question 4: What is the function of the 1N4007 Diode (D1) placed across the motor?




Question 5: Under which condition will the motor turn ON?




Question 6: What is the purpose of the 10 kΩ resistors (R1 and R2) connected to the switches?




Question 7: Which component acts as the driver switch to handle the current for the DC motor?




Question 8: What is the expected logic output voltage at the gate pin when the system is active?




Question 9: Why is this system useful for marine applications like a bilge pump?




Question 10: What is the specific function of the resistor R3 (1 kΩ) connected to the transistor?




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: Car Door Open Warning System

Car Door Open Warning System prototype (Maker Style)

Level: Basic – Implement a logic circuit that triggers an indicator when any door is left ajar.

Objective and use case

In this session, you will build a digital monitoring circuit using a 74HC32 OR gate to detect if any vehicle door is not fully closed. The circuit uses «Normally Closed» (NC) switches to simulate the door mechanics, ensuring that the alarm activates (LED turns ON) when a door opens.

  • Why it is useful:

    • Automotive Safety: Alerts drivers if a door is not latched before driving, preventing accidents.
    • Security Systems: Monitors multiple entry points (windows/doors) and triggers a central alarm if any single one is breached.
    • Industrial Enclosures: Ensures safety guards on dangerous machinery are closed before operation is allowed.
    • Access Control: Simple logic aggregation for multiple sensors.
  • Expected outcome:

    • Both Doors Closed: Inputs are Logic 0 (0 V); LED is OFF.
    • Door A Open: Input A becomes Logic 1 (5 V); LED turns ON.
    • Door B Open: Input B becomes Logic 1 (5 V); LED turns ON.
    • Both Open: Both inputs Logic 1; LED remains ON.
  • Target audience: Basic electronics students and automotive hobbyists.

Materials

  • V1: 5 V DC power supply, function: main circuit power.
  • S1: NC (Normally Closed) Pushbutton, function: Door A sensor (Released = Door Open).
  • S2: NC (Normally Closed) Pushbutton, function: Door B sensor (Released = Door Open).
  • R1: 10 kΩ resistor, function: pull-down for Input A.
  • R2: 10 kΩ resistor, function: pull-down for Input B.
  • U1: 74HC32, function: Quad 2-input OR gate IC.
  • R3: 330 Ω resistor, function: LED current limiting.
  • D1: Red LED, function: Open door warning indicator.
  • C1: 100 nF capacitor, function: decoupling for U1 power supply.

Pin-out of the IC used

Selected Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1A Input A Connected to Node DOOR_A
2 1B Input B Connected to Node DOOR_B
3 1Y Output Connected to Node V_ALARM
7 GND Ground Connected to Node 0
14 VCC Power Connected to Node VCC

Wiring guide

Follow these connections to create the SPICE-compatible netlist logic:

  • Power Supply

    • V1 connects between node VCC and node 0 (GND).
    • C1 connects between node VCC and node 0 (near the IC).
  • Input Stage (Door Sensors)

    • S1 connects between node VCC and node DOOR_A.
    • R1 connects between node DOOR_A and node 0. (Ensures Logic 0 when door is closed/switch pressed).
    • S2 connects between node VCC and node DOOR_B.
    • R2 connects between node DOOR_B and node 0.
  • Logic Processing (74HC32)

    • U1 Pin 14 connects to VCC.
    • U1 Pin 7 connects to 0.
    • U1 Pin 1 (Input 1A) connects to node DOOR_A.
    • U1 Pin 2 (Input 1B) connects to node DOOR_B.
    • U1 Pin 3 (Output 1Y) connects to node V_ALARM.
  • Output Stage (Indicator)

    • R3 connects between node V_ALARM and node LED_ANODE.
    • D1 anode connects to LED_ANODE.
    • D1 cathode connects to node 0.

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

[ INPUT STAGE ]                      [ LOGIC STAGE ]                  [ OUTPUT STAGE ]

(VCC 5V)
   |
[ S1: Door A Switch (NC) ]
   |
   +---> [ Node: DOOR_A ] --(Pin 1)---->+------------------+
   |                                    |                  |
[ R1: 10k Pull-Down ] -> GND            |    U1: 74HC32    |
                                        |    (OR Gate)     |
                                        |                  |--(Pin 3)---> [ R3: 330 Ohm ]
                                        |    Logic:        |                   |
(VCC 5V)                                |    A + B = Y     |                   v
   |                                    |                  |             [ D1: Red LED ]
[ S2: Door B Switch (NC) ]              |                  |                   |
   |                                    |                  |                  GND
   +---> [ Node: DOOR_B ] --(Pin 2)---->+------------------+
   |                                            ^
[ R2: 10k Pull-Down ] -> GND                    |
                                          [ C1: 100nF ]
                                          (Decoupling)
Schematic (ASCII)

Truth table

The 74HC32 behaves according to the standard OR logic. In this scenario:
* Logic 0 = 0 V (Door Closed / Switch Pressed).
* Logic 1 = 5 V (Door Open / Switch Released).

Door A (Input 1) Door B (Input 2) Output (LED) State Description
0 (Closed) 0 (Closed) 0 (OFF) Secure
0 (Closed) 1 (Open) 1 (ON) Warning
1 (Open) 0 (Closed) 1 (ON) Warning
1 (Open) 1 (Open) 1 (ON) Warning

Measurements and tests

  1. Supply Verification: Measure the voltage between VCC and 0. It should be stable at 5 V.
  2. Default State (Safe): Press and hold both S1 and S2 (simulating closed doors). Measure voltage at DOOR_A and DOOR_B. Both should be ~0 V. The LED should be OFF.
  3. Door A Test: Release S1 while holding S2. The voltage at DOOR_A should jump to ~5 V. The voltage at V_ALARM should go High (~5 V), and the LED should light up.
  4. Door B Test: Release S2 while holding S1. The voltage at DOOR_B should jump to ~5 V. The LED should light up.
  5. Logic Threshold Verification: If using a variable supply, verify that the 74HC32 registers a «High» signal once the input voltage crosses approximately 3.5 V (for 5 V VCC).

SPICE netlist and simulation

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

* Car Door Open Warning System
* Practical case implementation for ngspice

* --- Component Models ---
* Generic Red LED Model
.model DLED D(IS=10n N=2 RS=10 CJO=20p)
* Voltage Controlled Switch Model
* Vt=2.5V: Threshold voltage
* Ron=0.1: Resistance when ON (Closed)
* Roff=100Meg: Resistance when OFF (Open)
.model MYSW SW(Vt=2.5 Ron=0.1 Roff=100Meg)

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

* --- Decoupling ---
C1 VCC 0 100n

* --- Input Stage: Door Sensors ---
* Logic: 
* S1/S2 are NC (Normally Closed) Pushbuttons.
* Function: Released = Door Open. Pressed = Door Closed.
* Wiring: S1 connects VCC to DOOR_A. R1 pulls DOOR_A to GND.
* Simulation Logic:
* We use Voltage Controlled Switches (S1, S2) to simulate the physical contacts.
* Control Pulses (V_ACT_A, V_ACT_B) simulate the "Door Open" state.
* High Pulse = Door Open = Switch Released (Closed contacts) -> VCC connected.
* Low Pulse = Door Closed = Switch Pressed (Open contacts) -> Pulled to 0V.

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

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

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Car Door Open Warning System
* Practical case implementation for ngspice

* --- Component Models ---
* Generic Red LED Model
.model DLED D(IS=10n N=2 RS=10 CJO=20p)
* Voltage Controlled Switch Model
* Vt=2.5V: Threshold voltage
* Ron=0.1: Resistance when ON (Closed)
* Roff=100Meg: Resistance when OFF (Open)
.model MYSW SW(Vt=2.5 Ron=0.1 Roff=100Meg)

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

* --- Decoupling ---
C1 VCC 0 100n

* --- Input Stage: Door Sensors ---
* Logic: 
* S1/S2 are NC (Normally Closed) Pushbuttons.
* Function: Released = Door Open. Pressed = Door Closed.
* Wiring: S1 connects VCC to DOOR_A. R1 pulls DOOR_A to GND.
* Simulation Logic:
* We use Voltage Controlled Switches (S1, S2) to simulate the physical contacts.
* Control Pulses (V_ACT_A, V_ACT_B) simulate the "Door Open" state.
* High Pulse = Door Open = Switch Released (Closed contacts) -> VCC connected.
* Low Pulse = Door Closed = Switch Pressed (Open contacts) -> Pulled to 0V.

* Door A
S1 VCC DOOR_A CTRL_A 0 MYSW
R1 DOOR_A 0 10k

* Door B
S2 VCC DOOR_B CTRL_B 0 MYSW
R2 DOOR_B 0 10k

* --- Control Signals (User Stimuli) ---
* Timing Sequence:
* 0us - 100us: Both Doors Closed (Low)
* 100us - 200us: Door A Open (High)
* 200us - 300us: Both Doors Open (High)
* 300us - 400us: Door B Open (High)
* 400us - 600us: Both Doors Closed (Low)
V_ACT_A CTRL_A 0 PULSE(0 5 100u 1u 1u 200u 1000u)
V_ACT_B CTRL_B 0 PULSE(0 5 200u 1u 1u 200u 1000u)

* --- Logic Processing: U1 (74HC32) ---
* Quad 2-input OR gate
* Connections per wiring guide:
* Pin 1 (A) -> DOOR_A
* Pin 2 (B) -> DOOR_B
* Pin 3 (Y) -> V_ALARM
* Pin 7 (GND) -> 0
* Pin 14 (VCC) -> VCC
XU1 DOOR_A DOOR_B V_ALARM 0 VCC 74HC32

* --- Output Stage: Indicator ---
R3 V_ALARM LED_ANODE 330
D1 LED_ANODE 0 DLED

* --- Subcircuits ---
.subckt 74HC32 InA InB OutY GND VCC
* Behavioral OR Gate implementation
* Uses tanh for continuous, robust switching
* Logic: Out = VCC if (A > 2.5) OR (B > 2.5)
* Formula: Vout = VCC * ( 1 - (NOT A * NOT B) )
* NOT A is approximated by 0.5 * (1 - tanh(10*(V(InA)-2.5)))
B1 OutY GND V = V(VCC) * (1 - ( (0.5*(1-tanh(10*(V(InA)-2.5)))) * (0.5*(1-tanh(10*(V(InB)-2.5)))) ))
.ends

* --- Analysis Directives ---
.tran 1u 600u
.print tran V(DOOR_A) V(DOOR_B) V(V_ALARM) V(LED_ANODE)
.op

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1382 rows)
Index   time            v(door_a)       v(door_b)       v(v_alarm)
0	0.000000e+00	4.999500e-04	4.999500e-04	1.110223e-15
1	1.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
2	2.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
3	4.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
4	8.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
5	1.600000e-07	4.999500e-04	4.999500e-04	1.110223e-15
6	3.200000e-07	4.999500e-04	4.999500e-04	1.110223e-15
7	6.400000e-07	4.999500e-04	4.999500e-04	1.110223e-15
8	1.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
9	2.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
10	3.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
11	4.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
12	5.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
13	6.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
14	7.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
15	8.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
16	9.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
17	1.028000e-05	4.999500e-04	4.999500e-04	1.110223e-15
18	1.128000e-05	4.999500e-04	4.999500e-04	1.110223e-15
19	1.228000e-05	4.999500e-04	4.999500e-04	1.110223e-15
20	1.328000e-05	4.999500e-04	4.999500e-04	1.110223e-15
21	1.428000e-05	4.999500e-04	4.999500e-04	1.110223e-15
22	1.528000e-05	4.999500e-04	4.999500e-04	1.110223e-15
23	1.628000e-05	4.999500e-04	4.999500e-04	1.110223e-15
... (1358 more rows) ...

Common mistakes and how to avoid them

  1. Leaving Inputs Floating: Failing to install R1 or R2 will cause the inputs to «float» when the switch is open (pressed). This leads to erratic LED behavior. Always use pull-down resistors with this switch configuration.
  2. Confusing NC vs NO Switches: If you use NO (Normally Open) switches with this specific wiring, the logic reverses (LED ON when doors are closed). Ensure you understand the mechanical state of the switch when the door is physically closed.
  3. Missing LED Resistor: Connecting the LED directly to the IC output (Pin 3) without R3 will damage the LED or the 74HC32 chip due to excessive current.

Troubleshooting

  • LED is always ON:
    • Check if S1 or S2 are wired incorrectly (e.g., shorting VCC to Input constantly).
    • Verify R1 and R2 are connected to Ground, not VCC.
    • Ensure the IC is a 74HC32 (OR) and not a 74HC00 (NAND) or similar.
  • LED never turns ON:
    • Check power supply connections to Pin 14 and Pin 7.
    • Ensure the LED polarity is correct (Anode to resistor, Cathode to GND).
    • Verify the switches are actually passing 5 V when released.
  • LED is dim:
    • The value of R3 might be too high (e.g., 10 kΩ instead of 330 Ω).
    • The power supply voltage might be below 3 V.

Possible improvements and extensions

  1. Audible Alarm: Connect a 5 V active buzzer in parallel with the LED (driven by a transistor if current exceeds 20 mA) to provide sound feedback.
  2. Interior Light Control: Add a delay circuit (using a capacitor and resistor or a 555 timer) so the light stays on for 10 seconds after the doors are closed, simulating a modern car courtesy light.

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 objective of the circuit described in the text?




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




Question 3: What type of switches are used to simulate the door mechanics?




Question 4: What is the state of the LED when both doors are fully closed?




Question 5: What happens to the input signal when Door A is opened?




Question 6: What is the logic level of the inputs when both doors are closed?




Question 7: Why is this circuit useful for automotive safety?




Question 8: Besides automotive safety, what is another listed use case for this circuit?




Question 9: If both Door A and Door B are open, what is the status of the LED?




Question 10: What is the target audience level mentioned for 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: