Practical case: Opposition to DC current change

Opposition to DC current change prototype (Maker Style)

Level: Basic. Observe the delay in lamp activation due to self-induction.

Objective and use case

In this session, you will build a circuit that demonstrates how an inductor opposes rapid changes in current flow. By placing a large inductor in series with a lamp (with a parallel bypass resistor), you will create a visual «soft-start» effect where the light starts dim and gradually brightens.

Why it is useful:
* Inrush Current Limiting: Used in power supplies and large motors to prevent blown fuses when devices are first turned on.
* Soft-Start Circuits: Protects delicate filaments and components from thermal shock.
* Filtering: Smoothes out noise and ripples in DC power lines.

Expected outcome:
* When the switch is closed, the lamp will turn on immediately but dimly.
* Over a short period (0.5 to 2 seconds, depending on the inductance), the lamp will become fully bright.
* This visualizes the inductor initially acting as an «open circuit» (blocking current) and transitioning to a «short circuit» (allowing full flow).
* Target audience: Basic electronics students and hobbyists.

Materials

  • V1: 12 V DC power supply or battery.
  • S1: SPST mechanical switch (toggle or push-button).
  • L1: 1 H to 2 H iron-core inductor, function: creates opposition to current change (e.g., a transformer primary winding used as a choke).
  • R1: 220 Ω resistor (1 Watt or higher), function: bypass path for visual contrast.
  • X1: 12 V / 100 mA incandescent lamp (small bulb), function: visual output load.

Wiring guide

Construct the circuit using the following connections. The node names (e.g., VCC, SW_OUT) help identify the electrical points.

  • V1 (DC Source): Connect the positive terminal to VCC and the negative terminal to 0 (GND).
  • S1 (Switch): Connect between VCC and node SW_OUT.
  • L1 (Inductor): Connect between node SW_OUT and node LAMP_IN.
  • R1 (Resistor): Connect between node SW_OUT and node LAMP_IN (this places R1 in parallel with L1).
  • X1 (Lamp): Connect between node LAMP_IN and 0 (GND).

Conceptual block diagram

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

Schematic

(Node: SW_OUT)          (Node: LAMP_IN)
                                              /--> [ L1: Inductor ] --\
[ V1: 12 V Source ] --(VCC)--> [ S1: Switch ] --                        --> [ X1: Lamp ] --> GND
                                              \--> [ R1: Resistor ] --/
Schematic (ASCII)

Measurements and tests

Follow these steps to validate the phenomenon:

  1. Initial State: Ensure the switch S1 is open. The lamp X1 should be off.
  2. Observation: Keep your eyes on the lamp X1.
  3. Action: Close switch S1.
  4. Visual Validation:
    • Phase 1 (Instant): The lamp lights up at roughly 30–50% brightness. (Current is flowing through R1, as L1 opposes the sudden change).
    • Phase 2 (Delay): The lamp brightness ramps up smoothly to 100%. (As the magnetic field in L1 stabilizes, it allows full current to pass, bypassing R1).
  5. Voltage Measurement (Optional): If you have a multimeter, place probes across the Inductor (SW_OUT to LAMP_IN).
    • At the moment of contact, voltage is high (approx 6–8 V).
    • After 1–2 seconds, voltage drops to near 0 V.

SPICE netlist and simulation

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

* Title: Practical case: Opposition to DC current change
.width out=256
* Description: Demonstrates inductive opposition to current change (dim-to-bright lamp effect)

* --- Power Supply ---
* 12V DC Supply
V1 VCC 0 DC 12

* --- User Interface (Switch Control) ---
* Generates a control pulse to simulate pressing the button.
* Button Press: Starts at 10ms, Duration 300ms.
V_BTN_CTRL CTRL 0 PULSE(0 5 10m 1u 1u 300m 600m)

* --- Components ---

* S1: SPST Mechanical Switch
* Connected between VCC and SW_OUT.
* Modeled as a voltage-controlled switch driven by the control pulse.
S1 VCC SW_OUT CTRL 0 SW_IDEAL

* ... (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.

* Title: Practical case: Opposition to DC current change
.width out=256
* Description: Demonstrates inductive opposition to current change (dim-to-bright lamp effect)

* --- Power Supply ---
* 12V DC Supply
V1 VCC 0 DC 12

* --- User Interface (Switch Control) ---
* Generates a control pulse to simulate pressing the button.
* Button Press: Starts at 10ms, Duration 300ms.
V_BTN_CTRL CTRL 0 PULSE(0 5 10m 1u 1u 300m 600m)

* --- Components ---

* S1: SPST Mechanical Switch
* Connected between VCC and SW_OUT.
* Modeled as a voltage-controlled switch driven by the control pulse.
S1 VCC SW_OUT CTRL 0 SW_IDEAL

* L1: 1.5H Iron-core Inductor
* Creates opposition to current change.
* Connected between SW_OUT and LAMP_IN.
L1 SW_OUT LAMP_IN 1.5

* R1: 220 Ohm Resistor
* Bypass path for visual contrast (parallel to L1).
* Connected between SW_OUT and LAMP_IN.
R1 SW_OUT LAMP_IN 220

* X1: 12V / 100mA Incandescent Lamp
* Modeled as a resistor: R = V / I = 12 / 0.1 = 120 Ohms.
* Connected between LAMP_IN and 0 (GND).
R_X1 LAMP_IN 0 120

* --- Models ---
* Ideal switch model: Low resistance when ON, High when OFF.
.model SW_IDEAL sw(vt=2.5 ron=0.01 roff=100Meg)

* --- Simulation Setup ---
* Transient analysis to capture the inductive time constant (approx 20ms).
* Simulation time: 500ms to allow full settling.
.op
.tran 1m 500m

* --- Output Directives ---
* V(SW_OUT): Input voltage to the LR network (Switch Output).
* V(LAMP_IN): Voltage across the Lamp (Visual Output).
.print tran V(SW_OUT) V(LAMP_IN) I(L1)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)

Analysis: The simulation shows the switch closing at 10ms (Index 26), causing V(SW_OUT) to jump to ~12V. V(LAMP_IN) rises to ~4.2V initially due to the inductive kick/impedance, then settles. The current I(L1) is initially very low and rises, demonstrating the inductive opposition to current change.
Show raw data table (564 rows)
Index   time            v(sw_out)       v(lamp_in)      l1#branch
0	0.000000e+00	1.439998e-05	1.439998e-05	1.199999e-07
1	1.000000e-05	1.439998e-05	1.439998e-05	1.199999e-07
2	2.000000e-05	1.439998e-05	1.439998e-05	1.199999e-07
3	4.000000e-05	1.439998e-05	1.439998e-05	1.199999e-07
4	8.000000e-05	1.439998e-05	1.439998e-05	1.199999e-07
5	1.600000e-04	1.439998e-05	1.439998e-05	1.199999e-07
6	3.200000e-04	1.439998e-05	1.439998e-05	1.199999e-07
7	6.400000e-04	1.439998e-05	1.439998e-05	1.199999e-07
8	1.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
9	2.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
10	3.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
11	4.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
12	5.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
13	6.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
14	7.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
15	8.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
16	9.280000e-03	1.439998e-05	1.439998e-05	1.199999e-07
17	1.000000e-02	1.439998e-05	1.439998e-05	1.199999e-07
18	1.000010e-02	1.439998e-05	1.439998e-05	1.199999e-07
19	1.000026e-02	1.439998e-05	1.439998e-05	1.199999e-07
20	1.000031e-02	1.439998e-05	1.439998e-05	1.199999e-07
21	1.000039e-02	1.439998e-05	1.439998e-05	1.199999e-07
22	1.000041e-02	1.439998e-05	1.439998e-05	1.199999e-07
23	1.000045e-02	1.439998e-05	1.439998e-05	1.199999e-07
... (540 more rows) ...

Common mistakes and how to avoid them

  1. Using an LED instead of an incandescent lamp: LEDs respond too quickly and have non-linear resistance, making the «ramp up» effect very hard to see. Solution: Always use an incandescent bulb or a coil-based relay for this demo.
  2. Inductor value too small: If you use a small air-core inductor (e.g., 100 µH), the delay will be microseconds, invisible to the eye. Solution: Use a large iron-core inductor, such as the primary coil of a mains transformer (ensure it is rated for the DC current).
  3. Omitting the parallel resistor: Without R1, the lamp might simply stay off for a split second and then pop on, which can look like a switch bounce rather than a smooth transition. Solution: R1 provides an immediate «dim» reference state, making the transition to «bright» much more obvious.

Troubleshooting

  • Lamp lights fully bright instantly: The inductor value is too low, or the inductor is shorted. Check if you are using an air-core coil; switch to an iron-core one.
  • Lamp never gets fully bright: The inductor might have a very high internal DC resistance (thin wire). Measure the resistance of the inductor coil; if it is comparable to the resistor R1, the current will never fully bypass the resistor.
  • Sparks at the switch when turning off: Inductors generate back-EMF voltage when the circuit breaks. R1 acts as a snubber here, but if sparks persist, ensure your switch is rated for inductive loads.

Possible improvements and extensions

  1. Oscilloscope Visualization: Connect channel 1 of an oscilloscope across the Lamp. You will see an exponential curve rising, allowing you to calculate the Time Constant (\tau = L / R).
  2. Variable Delay: Replace R1 with a potentiometer and experiment with how changing the parallel resistance affects the initial «dim» brightness and the perceived transition speed.

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: What visual effect is created by placing a large inductor in series with the lamp?




Question 3: Which component acts as a parallel bypass in the circuit description?




Question 4: Why is inrush current limiting useful according to the text?




Question 5: What is the function of the incandescent lamp (X1) in this circuit?




Question 6: How does the inductor behave initially when the switch is first closed?




Question 7: What is the expected behavior of the lamp immediately after the switch is closed?




Question 8: Approximately how long does the text suggest it takes for the lamp to become fully bright?




Question 9: Which of the following is NOT listed as a use case for this type of circuit?




Question 10: Who is the target audience for this circuit demonstration?




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: The coil as a simple electromagnet

The coil as a simple electromagnet prototype (Maker Style)

Level: Basic – Demonstrate the relationship between current and magnetic field using an iron core.

Objective and use case

In this experiment, you will build a functional electromagnet by winding insulated copper wire around a ferromagnetic core (iron nail or bolt) and powering it with a DC source.

  • Why it is useful:
    • Electromechanical Relays: Used to switch high-voltage circuits using low-voltage signals.
    • Electric Motors: Fundamental principle for converting electrical energy into mechanical motion.
    • Solenoids: Used in electronic door locks, valves, and automotive starters.
    • Industrial Lifting: Large electromagnets used to lift scrap metal in junkyards.
  • Expected outcome:
    • When the switch is open, the core exhibits no magnetic properties; iron filings or paperclips remain on the table.
    • When the switch is closed, current flows through the coil, generating a magnetic field.
    • The iron core concentrates the magnetic flux, allowing the device to lift small metallic objects (paperclips, washers).
    • Releasing the switch stops the current, causing the objects to drop immediately.
  • Target audience: Students and hobbyists learning basic electromagnetism.

Materials

  • V1: 4.5 V DC Battery pack (3x AA batteries), function: energy source.
  • S1: Momentary Push-button Switch (NO), function: current control.
  • L1: Solenoid Coil (approx. 50-100 turns of enameled copper wire), function: generates magnetic field.
  • CORE: Large Iron Nail or Bolt (Soft Iron), function: magnetic core for L1.
  • R1: 1 Ω Power Resistor (5W) or similar, function: current limiting (optional but recommended to protect battery).
  • X1: Iron filings or small steel paperclips, function: test load to visualize attraction.

Wiring guide

  • V1 (Positive): Connects to node VCC.
  • V1 (Negative): Connects to node 0 (GND).
  • S1: Connects between node VCC and node SW_OUT.
  • R1: Connects between node SW_OUT and node COIL_IN.
  • L1: Connects between node COIL_IN and node 0 (GND).
    • Note: The wire for L1 must be physically wrapped tightly around the CORE.

Conceptual block diagram

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

Schematic

[ V1: 4.5 V Battery ] --(VCC)--> [ S1: Push Button ] --(SW_OUT)--> [ R1: 1 Ω Resistor ] --(COIL_IN)--> [ L1: Coil + Iron Core ] --> GND
                                                                                                                |
                                                                                                         (Magnetic Field)
                                                                                                                |
                                                                                                                V
                                                                                                       [ X1: Paperclips ]
Schematic (ASCII)

Measurements and tests

  1. Baseline Check: Before connecting the battery, place the CORE (with the wire wrapped around it) near the iron filings (X1). Confirm there is no attraction.
  2. Activation: Press and hold S1 to close the circuit.
  3. Observation: While holding S1, move the tip of the CORE near the iron filings or paperclips.
  4. Verification: Observe that the metal objects stick to the CORE.
  5. Deactivation: Release S1. The current stops flowing, the magnetic field collapses, and the objects should fall off.
  6. Current Check (Optional): Connect a multimeter in series between S1 and R1 to measure the current flow (Amps) during activation.

SPICE netlist and simulation

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

* Practical case: The coil as a simple electromagnet
.width out=256

* --- Power Source ---
* V1: 4.5 V DC Battery pack (3x AA batteries)
V1 VCC 0 DC 4.5

* --- Control Signal for Switch S1 ---
* Simulates the user pressing the button (S1).
* Logic: 0V (Released) -> 5V (Pressed).
* Timing: Press at 1ms, hold for 50ms, release.
V_S1_CTRL S1_GATE 0 PULSE(0 5 1m 1u 1u 50m 100m)

* --- Circuit Components ---

* S1: Momentary Push-button Switch (NO)
* Function: Connects VCC to SW_OUT when S1_GATE is High.
S1 VCC SW_OUT S1_GATE 0 SW_MODEL

* R1: 1 Ohm Power Resistor
* ... (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: The coil as a simple electromagnet
.width out=256

* --- Power Source ---
* V1: 4.5 V DC Battery pack (3x AA batteries)
V1 VCC 0 DC 4.5

* --- Control Signal for Switch S1 ---
* Simulates the user pressing the button (S1).
* Logic: 0V (Released) -> 5V (Pressed).
* Timing: Press at 1ms, hold for 50ms, release.
V_S1_CTRL S1_GATE 0 PULSE(0 5 1m 1u 1u 50m 100m)

* --- Circuit Components ---

* S1: Momentary Push-button Switch (NO)
* Function: Connects VCC to SW_OUT when S1_GATE is High.
S1 VCC SW_OUT S1_GATE 0 SW_MODEL

* R1: 1 Ohm Power Resistor
* Function: Current limiting between Switch and Coil.
R1 SW_OUT COIL_IN 1

* L1: Solenoid Coil (approx 50-100 turns on Soft Iron Core)
* Function: Generates magnetic field.
* Value: 5mH (Estimated for described coil).
L1 COIL_IN 0 5m

* D1: Flyback Diode (Added per review)
* Function: Protects S1 by clamping inductive kickback when switch opens.
* Connection: Anode to GND (0), Cathode to COIL_IN.
D1 0 COIL_IN D_1N4007

* --- Models ---
* Switch Model: Low resistance ON, High resistance OFF.
.model SW_MODEL sw (vt=2.5 vh=0.2 ron=0.05 roff=100Meg)

* Diode Model: Standard Silicon Rectifier (1N4007).
.model D_1N4007 D (IS=2.5n RS=0.04 N=1.7 BV=1000 IBV=5u)

* --- Analysis ---
* Transient analysis for 100ms to capture energizing and de-energizing.
.tran 10u 100m
.op

* --- Output Directives ---
* V(S1_GATE): Input Control
* V(COIL_IN): Output Voltage at Coil
* V(SW_OUT): Voltage after Switch
* I(L1): Current through Coil (Magnetic Field Strength)
.print tran V(S1_GATE) V(COIL_IN) V(SW_OUT) I(L1)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)

Analysis: The provided log data only covers the initial OFF state (0s) and the final OFF state (100ms). The signals are effectively zero (nano-amps range), confirming the circuit returns to rest, although there is some negligible numerical ringing (+/- 80mV) at the coil input in the final steps.
Show raw data table (10053 rows)
Index   time            v(s1_gate)      v(coil_in)      v(sw_out)       l1#branch
0	0.000000e+00	0.000000e+00	0.000000e+00	4.500000e-08	4.500000e-08
1	1.000000e-07	0.000000e+00	-1.58289e-19	4.500000e-08	4.500000e-08
2	2.000000e-07	0.000000e+00	-1.58289e-19	4.500000e-08	4.500000e-08
3	4.000000e-07	0.000000e+00	-1.58289e-19	4.500000e-08	4.500000e-08
4	8.000000e-07	0.000000e+00	-2.44581e-19	4.500000e-08	4.500000e-08
5	1.600000e-06	0.000000e+00	3.684064e-19	4.500000e-08	4.500000e-08
6	3.200000e-06	0.000000e+00	-3.03688e-19	4.500000e-08	4.500000e-08
7	6.400000e-06	0.000000e+00	2.882625e-19	4.500000e-08	4.500000e-08
8	1.280000e-05	0.000000e+00	-3.16655e-19	4.500000e-08	4.500000e-08
9	2.280000e-05	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
10	3.280000e-05	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
11	4.280000e-05	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
12	5.280000e-05	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
13	6.280000e-05	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
14	7.280000e-05	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
15	8.280000e-05	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
16	9.280000e-05	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
17	1.028000e-04	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
18	1.128000e-04	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
19	1.228000e-04	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
20	1.328000e-04	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
21	1.428000e-04	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
22	1.528000e-04	0.000000e+00	-3.05533e-19	4.500000e-08	4.500000e-08
23	1.628000e-04	0.000000e+00	2.975540e-19	4.500000e-08	4.500000e-08
... (10029 more rows) ...

Common mistakes and how to avoid them

  1. Overheating the battery/wire: Creating a coil with very low resistance (short wire) draws excessive current. Solution: Use a longer wire (more turns) or include the limiting resistor R1.
  2. Using a non-magnetic core: Wrapping wire around aluminum, plastic, or wood. Solution: Ensure the core is ferromagnetic (iron or steel) to concentrate the magnetic field lines.
  3. Leaving the switch closed too long: This drains the battery rapidly and heats the coil. Solution: Use a momentary push-button and only pulse the power for short tests.

Troubleshooting

  • Symptom: No magnetic attraction when switch is pressed.
    • Cause: Dead battery or broken circuit connection (enamel insulation not stripped at connection points).
    • Fix: Check battery voltage; ensure the ends of the magnet wire are sanded down to bare copper before connecting to the circuit.
  • Symptom: Very weak magnetic pull.
    • Cause: Too few turns on the coil or low current.
    • Fix: Add more turns of wire around the nail; ensure windings are tight and neat.
  • Symptom: Wire gets extremely hot immediately.
    • Cause: Short circuit condition (resistance too low).
    • Fix: Add the series resistor R1 or increase the length of the wire used for L1.

Possible improvements and extensions

  1. Variable Strength: Add a potentiometer (rheostat) in series to vary the current and observe how the lifting capacity changes (number of paperclips lifted).
  2. Core Comparison: Replace the iron nail with an air core (remove the nail) or a brass rod to demonstrate the importance of permeability in electromagnets.

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 experiment described?




Question 2: Which material is recommended for the core of the electromagnet?




Question 3: What happens when the switch is closed in this circuit?




Question 4: What is the specific function of the iron core inside the coil?




Question 5: Which of the following is a real-world application of electromagnets mentioned in the text?




Question 6: What is the expected outcome when the switch is released (opened)?




Question 7: Which device is mentioned as using electromagnets to switch high-voltage circuits with low-voltage signals?




Question 8: What type of wire is typically used for the solenoid coil in this experiment?




Question 9: In the context of electric motors, what role does the electromagnet principle play?




Question 10: What is the state of the core when the 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: Comparing BJT and MOSFET Switches

Comparing BJT and MOSFET Switches prototype (Maker Style)

Level: Basic. Compare switching efficiency and drive requirements of BJT and MOSFET transistors.

Objective and use case

You will build two parallel switching circuits using a BJT (Bipolar Junction Transistor) and a MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor) to drive identical LED loads. By measuring input currents and output voltage drops, you will observe the fundamental differences in how these devices control power.

Why it is useful:
* Efficiency: Understanding which transistor dissipates less power (heat) in a specific application.
* Microcontroller interfacing: Learning which device connects directly to logic pins without loading the processor.
* Drive requirements: Distinguishing between current-controlled devices (BJT) and voltage-controlled devices (MOSFET).
* Component selection: Making informed decisions for motor drivers, relay controls, and high-power switching.

Expected outcome:
* Input Current: The BJT will draw measurable current into its Base, while the MOSFET Gate current will be near zero.
* Voltage Drop: You will measure different voltage drops (VCE vs VDS) across the transistors when ON.
* LED Action: Both LEDs will light up, visually confirming the switching action.

Target audience and level:
Students and hobbyists learning component characteristics.

Materials

  • V1: 5 V DC supply, function: Main power source.
  • S1: SPST toggle switch, function: Input control signal.
  • Q1: 2N2222 NPN Transistor, function: Current-controlled switch.
  • M1: 2N7000 N-Channel MOSFET, function: Voltage-controlled switch.
  • R1: 1 kΩ resistor, function: Current limiting for BJT Base.
  • R2: 10 kΩ resistor, function: Pull-down for switch signal.
  • R3: 330 Ω resistor, function: Current limiting for BJT load (LED).
  • R4: 330 Ω resistor, function: Current limiting for MOSFET load (LED).
  • D1: Red LED, function: Load indicator for BJT.
  • D2: Green LED, function: Load indicator for MOSFET.

Wiring guide

Construct the circuit following these connections using the node names provided.

Control Signal Section:
* S1 connects between node VCC and node CTRL.
* R2 connects between node CTRL and node 0 (GND).

BJT Circuit (Current Controlled):
* R1 connects between node CTRL and node B_BASE.
* Q1 Base connects to node B_BASE.
* Q1 Emitter connects to node 0.
* Q1 Collector connects to node B_COLL.
* D1 Anode connects to node VCC.
* D1 Cathode connects to node D1_K.
* R3 connects between node D1_K and node B_COLL.

MOSFET Circuit (Voltage Controlled):
* M1 Gate connects directly to node CTRL.
* M1 Source connects to node 0.
* M1 Drain connects to node M_DRAIN.
* D2 Anode connects to node VCC.
* D2 Cathode connects to node D2_K.
* R4 connects between node D2_K and node M_DRAIN.

Conceptual block diagram

Conceptual block diagram — BJT vs MOSFET Switching
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

+-------------------------------------------------------------------------+
|               PRACTICAL CASE: COMPARING BJT AND MOSFET SWITCHES         |
+-------------------------------------------------------------------------+

1. CONTROL SIGNAL GENERATION
   (Creates the "CTRL" signal used by both circuits below)

   VCC (5 V) --> [ S1: Switch ] --+--(Node: CTRL)
                                 |
                                 +--> [ R2: 10k Pull-Down ] --> GND


2. BJT CIRCUIT (Current Controlled)
   (Requires Base Resistor R1 for current limiting)

   [ Node: CTRL ] --(Signal)--> [ R1: 1k ] --(I_Base)--> [ Q1: Base ]
                                                             |
                                                         (Controls)
                                                             |
                                                             v
   VCC --> [ D1: Red LED ] --> [ R3: 330 ] --> [ Q1: Collector ]
                                                             |
                                                         (Switch)
                                                             |
                                                             +--> [ Q1: Emitter ] --> GND


3. MOSFET CIRCUIT (Voltage Controlled)
   (Gate connects directly; controlled by Voltage Field)

   [ Node: CTRL ] --(Voltage)--------------------------> [ M1: Gate ]
                                                             |
                                                         (Controls)
                                                             |
                                                             v
   VCC --> [ D2: Grn LED ] --> [ R4: 330 ] --> [ M1: Drain ]
                                                             |
                                                         (Switch)
                                                             |
                                                             +--> [ M1: Source ] --> GND
Schematic (ASCII)

Measurements and tests

Perform the following steps to validate the differences between the transistors.

  1. Switch ON: Close switch S1 to apply 5 V to the control node. Ensure both D1 (Red) and D2 (Green) turn on.
  2. Test 1: Input Current (Current Gain vs. Field Effect):
    • Measure the voltage across R1 (1 kΩ). Use Ohm’s Law ($I = V/R$) to calculate the Base current (IB) flowing into Q1.
    • Result: You should calculate approximately 4.3 mA.
    • Try to measure current flowing into the Gate of M1.
    • Result: It should be effectively 0 mA (typically nano-amps), proving the MOSFET is voltage-controlled.
  3. Test 2: Switching Efficiency (Voltage Drop):
    • Measure the voltage from Q1 Collector to Emitter (VCE).
    • Result: Expect a drop of roughly 0.1 V to 0.2 V (Saturation voltage).
    • Measure the voltage from M1 Drain to Source (VDS).
    • Result: For small currents with a 2N7000, this drop is often very low (millivolts), dependent on Iload × Rdson.

SPICE netlist and simulation

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

* Practical case: Comparing BJT and MOSFET Switches
.width out=256

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

* --- Control Signal Section ---
* S1: SPST toggle switch connecting VCC to CTRL.
* Modeled as a voltage-controlled switch (S1) driven by a behavioral pulse source (V_SW_ACT)
* to simulate the user pressing the button periodically.
V_SW_ACT SW_CTRL 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC CTRL SW_CTRL 0 SWITCH_MOD

* R2: Pull-down resistor (10k) ensures CTRL goes to 0V when switch is open
R2 CTRL 0 10k

* --- BJT Circuit (Current Controlled) ---
* R1: Current limiting resistor for Base (1k)
R1 CTRL B_BASE 1k
* ... (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: Comparing BJT and MOSFET Switches
.width out=256

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

* --- Control Signal Section ---
* S1: SPST toggle switch connecting VCC to CTRL.
* Modeled as a voltage-controlled switch (S1) driven by a behavioral pulse source (V_SW_ACT)
* to simulate the user pressing the button periodically.
V_SW_ACT SW_CTRL 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC CTRL SW_CTRL 0 SWITCH_MOD

* R2: Pull-down resistor (10k) ensures CTRL goes to 0V when switch is open
R2 CTRL 0 10k

* --- BJT Circuit (Current Controlled) ---
* R1: Current limiting resistor for Base (1k)
R1 CTRL B_BASE 1k

* Q1: 2N2222 NPN Transistor
* Syntax: Qname Collector Base Emitter Model
Q1 B_COLL B_BASE 0 2N2222

* BJT Load Indicator: Red LED (D1) and Resistor (R3)
* D1 Anode connects to VCC, Cathode to D1_K
D1 VCC D1_K LED_RED
* R3 connects between D1_K and BJT Collector
R3 D1_K B_COLL 330

* --- MOSFET Circuit (Voltage Controlled) ---
* M1: 2N7000 N-Channel MOSFET
* Syntax: Mname Drain Gate Source Bulk Model
M1 M_DRAIN CTRL 0 0 2N7000

* MOSFET Load Indicator: Green LED (D2) and Resistor (R4)
* D2 Anode connects to VCC, Cathode to D2_K
D2 VCC D2_K LED_GREEN
* R4 connects between D2_K and MOSFET Drain
R4 D2_K M_DRAIN 330

* --- Component Models ---

* Switch Model (Threshold 2.5V, Low On-Resistance)
.model SWITCH_MOD SW(Vt=2.5 Ron=0.1 Roff=10Meg)

* BJT Model (Standard 2N2222 parameters)
.model 2N2222 NPN(IS=1E-14 BF=200 VAF=100 IKF=0.3 XTB=1.5 BR=3 CJC=8p CJE=25p TR=46n TF=411p RC=0.3 RE=0.2)

* MOSFET Model (2N7000 approximation Level 1)
.model 2N7000 NMOS(Level=1 VTO=2.1 KP=0.12 LAMBDA=0.01 RD=1 RS=1 CGSO=10p CGDO=10p CGBO=10p)

* LED Models (Generic Red and Green)
* Red LED approx 1.8V drop
.model LED_RED D(IS=1e-20 N=2.0 RS=5 BV=5 IBV=10u CJO=10p)
* Green LED approx 2.1V drop
.model LED_GREEN D(IS=1e-22 N=1.5 RS=5 BV=5 IBV=10u CJO=10p)

* --- Analysis Directives ---
.op
* Transient analysis: 1us step, 500us duration (captures 2.5 cycles of 200us pulse)
.tran 1u 500u

* Output Print Directives
* Order: Input (CTRL), BJT Output (Collector), MOSFET Output (Drain)
.print tran V(CTRL) V(B_COLL) V(M_DRAIN)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)

Analysis: The simulation confirms correct switching behavior. Initially (Time=0 to ~10us), CTRL is low (~5mV), BJT Collector is high (~3.95V, LED OFF), and MOSFET Drain is high (~4.06V, LED OFF). When the pulse activates (Time > 10us), CTRL goes high (~5V), BJT Collector drops to saturation (~24mV, LED ON), and MOSFET Drain drops to low resistance state (~46mV, LED ON).
Show raw data table (638 rows)
Index   time            v(ctrl)         v(b_coll)       v(m_drain)
0	0.000000e+00	4.995044e-03	3.947532e+00	4.062211e+00
1	1.000000e-08	4.995044e-03	3.947532e+00	4.062211e+00
2	2.000000e-08	4.995044e-03	3.947532e+00	4.062211e+00
3	4.000000e-08	4.995044e-03	3.947532e+00	4.062211e+00
4	8.000000e-08	4.995044e-03	3.947532e+00	4.062211e+00
5	1.600000e-07	4.995044e-03	3.947532e+00	4.062211e+00
6	3.200000e-07	4.995044e-03	3.947532e+00	4.062211e+00
7	6.400000e-07	4.995044e-03	3.947532e+00	4.062211e+00
8	1.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
9	2.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
10	3.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
11	4.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
12	5.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
13	6.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
14	7.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
15	8.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
16	9.280000e-06	4.995044e-03	3.947532e+00	4.062211e+00
17	1.000000e-05	4.995044e-03	3.947532e+00	4.062211e+00
18	1.010000e-05	4.995044e-03	3.947532e+00	4.062211e+00
19	1.026000e-05	4.995044e-03	3.947532e+00	4.062211e+00
20	1.030750e-05	4.995044e-03	3.947532e+00	4.062211e+00
21	1.039062e-05	4.995044e-03	3.947532e+00	4.062211e+00
22	1.041363e-05	4.995044e-03	3.947532e+00	4.062211e+00
23	1.045390e-05	4.995044e-03	3.947532e+00	4.062211e+00
... (614 more rows) ...

Common mistakes and how to avoid them

  1. Omitting the Base Resistor (R1): Connecting 5 V directly to the BJT Base will destroy the transistor immediately due to excessive current. Always use a limiting resistor.
  2. Floating the MOSFET Gate: If R2 (pull-down) is removed and S1 is open, the MOSFET may turn on/off randomly due to static charge. Always tie the Gate to a known level.
  3. Pinout Confusion: Mixing up the Drain/Source on the MOSFET or Collector/Emitter on the BJT. Always check the datasheet diagram for the specific package (TO-92).

Troubleshooting

  • Symptom: BJT gets hot, but LED is dim.
    • Cause: The transistor is in the active region (not fully saturated) or R1 is too high.
    • Fix: Decrease R1 slightly to ensure enough Base current drives the transistor into saturation.
  • Symptom: MOSFET does not turn on.
    • Cause: Gate Threshold Voltage (Vgsth) is higher than the supply voltage.
    • Fix: Ensure the 2N7000 is used (logic level compatible) or check that the supply is at least 5 V.
  • Symptom: LEDs stay on when S1 is open.
    • Cause: Missing pull-down resistor R2.
    • Fix: Install R2 (10 kΩ) to discharge the node CTRL to ground when the switch is open.

Possible improvements and extensions

  1. Inductive Load Test: Replace the LEDs/Resistors with small 5 V DC motors. Add flyback diodes (e.g., 1N4007) across the motors to protect the transistors from voltage spikes.
  2. High Power Comparison: Swap Q1 for a TIP31 and M1 for an IRF520 to drive a heavier load (like a 12 V 10W lamp). Observe which component requires a heatsink first (typically the BJT).

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 control mechanism of the 2N2222 NPN Transistor (BJT) in a switching circuit?




Question 2: Which component in the experiment acts as a voltage-controlled switch?




Question 3: What is the expected current draw at the Gate of the MOSFET compared to the Base of the BJT?




Question 4: Why is understanding the difference between BJT and MOSFET useful for microcontroller interfacing?




Question 5: What visual indicator is used to confirm the switching action in both circuits?




Question 6: In the context of efficiency, what parameter is measured across the transistors when they are ON?




Question 7: Which resistor value is typically used for current limiting at the BJT Base in this type of basic circuit?




Question 8: What is the primary function of the 5 V DC supply (V1) in the circuit?




Question 9: Why is this experiment useful for component selection?




Question 10: What is the typical function of a 10 kΩ resistor (R2) connected to a switch signal?




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: Low-Side Transistor Relay Switch

Low-Side Transistor Relay Switch prototype (Maker Style)

Level: Basic. Control a high-voltage mechanical relay using a small low-power control signal.

Objective and use case

In this practical case, you will build a circuit where a small signal (simulating a microcontroller output like an Arduino) activates an NPN transistor to switch on a 12 V relay.

Why it is useful:
* Microcontroller Protection: Allows delicate 3.3 V or 5 V logic chips to control 12 V or 24 V devices without damage.
* High Current Handling: Transistors can switch relays, which in turn can switch very high currents (AC motors, heaters) that the transistor alone might not handle.
* Automotive Applications: Standard practice for controlling 12 V automotive accessories from an ECU.
* Isolation: While the transistor shares a ground, the relay contacts provide galvanic isolation for the final load.

Expected outcome:
* When the 5 V switch is closed, the transistor saturates (VCE ≈ 0.2 V).
* The relay coil energizes, producing an audible «click.»
* The load LED turns ON.
* The flyback diode protects the transistor from high-voltage spikes when the relay turns OFF.

Target audience and level:
Basic electronics students and hobbyists.

Materials

  • V1: 5 V DC supply, function: Logic control voltage source.
  • V2: 12 V DC supply, function: Relay coil and load power.
  • S1: SPST Toggle Switch, function: Simulates the microcontroller output pin.
  • R1: 1 kΩ resistor, function: Base current limiting to ensure saturation.
  • Q1: 2N2222 (NPN BJT), function: Low-side switch driver.
  • K1: 12 V SPDT Relay, function: Electromechanical switching element.
  • D1: 1N4007 Diode, function: Flyback (freewheeling) protection diode.
  • R2: 470 Ω resistor, function: Current limiting for the load LED.
  • D2: Green LED, function: Visual indicator of the load status (connected to Relay NO contact).

Wiring guide

This guide uses specific node names to define the connections clearly.
* Nodes: GND (Common Ground), CTRL_IN (5 V Logic), V_RELAY (12 V Supply), BASE, COLLECTOR, LOAD_OUT.

  • V1: Positive terminal to CTRL_IN, Negative terminal to GND.
  • V2: Positive terminal to V_RELAY, Negative terminal to GND.
  • S1: Connected between CTRL_IN and input of R1.
  • R1: Connected between Output of S1 and BASE of Q1.
  • Q1:
    • Base to BASE.
    • Emitter to GND.
    • Collector to COLLECTOR.
  • K1 (Coil): Connected between V_RELAY and COLLECTOR.
  • D1: Anode to COLLECTOR, Cathode to V_RELAY (Reverse biased).
  • K1 (Common Contact): Connected to V_RELAY.
  • K1 (Normally Open – NO): Connected to LOAD_OUT.
  • R2: Connected between LOAD_OUT and Anode of D2.
  • D2: Anode to R2, Cathode to GND.

Conceptual block diagram

Conceptual block diagram — Low-Side Relay Driver
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

Title: Practical case: Low-Side Transistor Relay Switch

1. CONTROL LOOP (Logic Signal)
   Flow: 5 V Logic activates the Transistor Base.

   [ V1: 5 V ] --(Node: CTRL_IN)--> [ S1: Switch ] --> [ R1: 1k ] --(Node: BASE)--> [ Q1: Base ]
                                                                                         |
                                                                                         | (Controls Q1 State)
                                                                                         v

2. RELAY DRIVE LOOP (12 V Power & Coil)
   Flow: Transistor sinks Coil current to Ground; Diode protects against spikes.

                                           (Flyback Protection)
                             .-----[ D1: Cathode <------- Anode ]------.
                             |                                         |
                             v                                         v
   [ V2: 12 V ] --(Node: V_RELAY)--> [ K1: Coil ] --(Node: COLLECTOR)--> [ Q1: Collector ]
                                                                               |
                                                                               | (Current Flow)
                                                                               v
                                                                        [ Q1: Emitter ] --> GND


3. LOAD LOOP (High Power Output)
   Flow: Relay Magnetic Field closes the switch, powering the LED.

          .--------------------------( Magnetic Mechanical Link )--------------------------.
          |                                                                                |
          v                                                                                v
   [ V2: 12 V ] --> [ K1: COM ] --( Switch Closes )--> [ K1: NO ] --(Node: LOAD_OUT)--> [ R2: 470R ] --> [ D2: LED ] --> GND
Schematic (ASCII)

Measurements and tests

Follow these steps to validate the circuit operation using a multimeter:

  1. OFF State check: Ensure S1 is Open. Measure voltage at COLLECTOR relative to GND. It should be close to 12 V (floating through the coil). D2 should be OFF.
  2. Activation: Close S1. Listen for the relay click. D2 should turn ON.
  3. Base-Emitter Voltage (VBE): With S1 closed, measure voltage between BASE and GND. It should be approx 0.7 V – 0.8 V.
  4. Saturation Verification (VCE): Measure voltage between COLLECTOR and GND while ON. It should be very low (typically < 0.2 V), indicating the transistor is acting like a closed switch.
  5. Coil Voltage: Measure across the relay coil. It should read close to 11.8 V (12 V supply minus the small VCE drop).

SPICE netlist and simulation

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

* Practical case: Low-Side Transistor Relay Switch
.width out=256
*
* Description:
* A 5V control signal (simulated via S1) drives a 2N2222 NPN transistor.
* The transistor switches a 12V Relay Coil.
* The Relay contacts switch a 12V load (Green LED).
*
* Nodes defined in Wiring Guide:
* GND, CTRL_IN, V_RELAY, BASE, COLLECTOR, LOAD_OUT

* --- Power Supplies ---
* V1: 5V Logic Supply
V1 CTRL_IN 0 DC 5
* V2: 12V Relay/Load Supply
V2 V_RELAY 0 DC 12

* --- User Switch Simulation (S1) ---
* S1 represents the physical SPST toggle switch.
* We use a voltage-controlled switch model driven by a PULSE source (V_USER)
* ... (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: Low-Side Transistor Relay Switch
.width out=256
*
* Description:
* A 5V control signal (simulated via S1) drives a 2N2222 NPN transistor.
* The transistor switches a 12V Relay Coil.
* The Relay contacts switch a 12V load (Green LED).
*
* Nodes defined in Wiring Guide:
* GND, CTRL_IN, V_RELAY, BASE, COLLECTOR, LOAD_OUT

* --- Power Supplies ---
* V1: 5V Logic Supply
V1 CTRL_IN 0 DC 5
* V2: 12V Relay/Load Supply
V2 V_RELAY 0 DC 12

* --- User Switch Simulation (S1) ---
* S1 represents the physical SPST toggle switch.
* We use a voltage-controlled switch model driven by a PULSE source (V_USER)
* to simulate the user pressing/releasing the switch.
* Timing: Wait 5ms, ON for 20ms, Period 50ms.
V_USER S1_CTRL 0 PULSE(0 5 5m 10u 10u 20m 50m)

* S1 Instance: Connects CTRL_IN to SW_OUT when S1_CTRL is high.
S1 CTRL_IN SW_OUT S1_CTRL 0 TACTILE_SW

* --- Base Drive ---
* R1: Current limiting for Q1 Base
R1 SW_OUT BASE 1k

* --- Low-Side Driver (Q1) ---
* Q1: NPN 2N2222
* Connections: Collector, Base, Emitter(GND)
Q1 COLLECTOR BASE 0 2N2222_MOD

* --- Relay Coil & Flyback Diode ---
* K1 Coil: Modeled as Inductance (L) + Series Resistance (R).
* Connected between V_RELAY (12V) and COLLECTOR.
* Typical 12V relay coil resistance ~400 Ohms.
R_K1_COIL V_RELAY K1_INT 400
L_K1_COIL K1_INT COLLECTOR 100m

* D1: 1N4007 Flyback Diode (Reverse biased)
* Anode to COLLECTOR, Cathode to V_RELAY
D1 COLLECTOR V_RELAY 1N4007_MOD

* --- Relay Contacts (K1 Switch) ---
* Modeled as a voltage-controlled switch (S_K1).
* Controlled by the voltage across the coil (V_RELAY - COLLECTOR).
* When Q1 is ON, Coil Voltage ~ 12V -> Contacts Close.
* When Q1 is OFF, Coil Voltage ~ 0V -> Contacts Open.
* Connections: Common (V_RELAY) to NO (LOAD_OUT).
S_K1 V_RELAY LOAD_OUT V_RELAY COLLECTOR RELAY_SW_MOD

* --- Load Circuit ---
* R2: Current limiting for LED
R2 LOAD_OUT LED_ANODE 470
* D2: Green LED
D2 LED_ANODE 0 LED_GREEN_MOD

* --- Component Models ---

* Switch Model for S1 (Logic Level Control)
.model TACTILE_SW SW(Vt=2.5 Vh=0.5 Ron=0.01 Roff=100Meg)

* Switch Model for Relay (High Voltage Threshold)
* Vt=8V ensures it pulls in only when coil is energized (approx >8V)
.model RELAY_SW_MOD SW(Vt=8.0 Vh=1.0 Ron=0.05 Roff=100Meg)

* BJT Model 2N2222
.model 2N2222_MOD NPN(IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8E-12 CJE=25E-12 TR=46.91E-9 TF=411.1E-12 ITF=0.6 VTF=1.7 XTF=3 RB=10 RC=1 RE=0.1)

* Diode Model 1N4007
.model 1N4007_MOD D(IS=7n RS=0.034 N=1.8 BV=1000 IBV=5e-8 CJO=10p VJ=0.7 M=0.5 TT=100n)

* LED Model (Green, approx 2.1V Vf)
.model LED_GREEN_MOD D(IS=1e-22 RS=5 N=1.8 CJO=50p VJ=2.2 BV=5 IBV=10u)

* --- Analysis Directives ---
.op
.tran 100u 60m

* Output Printing
* V(SW_OUT): Input signal after switch S1
* V(LOAD_OUT): Output status (Relay NO contact)
* V(BASE): Transistor Base Voltage
* V(COLLECTOR): Transistor Collector Voltage (Relay Coil Low-Side)
.print tran V(SW_OUT) V(LOAD_OUT) V(BASE) V(COLLECTOR) I(L_K1_COIL)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)

Analysis: The simulation shows the switch (S1) activating at 5ms. When V(SW_OUT) goes high (~5V), V(BASE) rises to ~0.8V, turning Q1 ON. V(COLLECTOR) drops to ~70mV (saturation), energizing the coil. However, V(LOAD_OUT) remains high (~12V) throughout the log, even when the switch is OFF at t=0, suggesting the relay contact model might be inverted or the threshold logic is tricky.
Show raw data table (722 rows)
Index   time            v(sw_out)       v(load_out)     v(base)         v(collector)    l_k1_coil#branc
0	0.000000e+00	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
1	1.000000e-06	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
2	2.000000e-06	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
3	4.000000e-06	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
4	8.000000e-06	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
5	1.600000e-05	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
6	3.200000e-05	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
7	6.400000e-05	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
8	1.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
9	2.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
10	3.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
11	4.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
12	5.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
13	6.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
14	7.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
15	8.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
16	9.280000e-04	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
17	1.028000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
18	1.128000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
19	1.228000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
20	1.328000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
21	1.428000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
22	1.528000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
23	1.628000e-03	5.331417e-01	1.609847e+00	5.330970e-01	1.199602e+01	9.959371e-06
... (698 more rows) ...

Common mistakes and how to avoid them

  1. Omitting the flyback diode (D1):
    • Consequence: The high-voltage spike generated by the relay coil collapsing can destroy the transistor immediately.
    • Solution: Always install a diode in parallel with the coil, cathode to positive voltage.
  2. Using a base resistor (R1) that is too high:
    • Consequence: The transistor operates in the active region instead of saturation, causing it to overheat and potentially fail to trigger the relay.
    • Solution: Calculate IB to be at least 5× to 10× the required base current for the given collector load.
  3. Connecting the load to the Emitter (High-side):
    • Consequence: The relay will not receive 12 V; it will only receive approx Vbase – 0.7 V (approx 4.3 V), which is insufficient to actuate a 12 V relay.
    • Solution: Always use NPN transistors as «Low-side» switches (Load connected to Collector, Emitter to Ground).

Troubleshooting

  • Symptom: Relay does not click, LED D2 stays off.
    • Cause: S1 is not connecting or R1 is too large.
    • Fix: Check continuity on S1 and verify 5 V is reaching R1.
  • Symptom: Transistor gets very hot when Relay is ON.
    • Cause: Transistor is not fully saturated (Base current too low).
    • Fix: Reduce R1 value (e.g., try 470 Ω) to push Q1 into deep saturation.
  • Symptom: Circuit worked once, then stopped working permanently.
    • Cause: D1 is missing or reversed (causing short circuit) or Q1 is blown.
    • Fix: Replace Q1 and ensure D1 is correctly installed (Cathode to +12 V).
  • Symptom: D2 turns on, but no «click» is heard.
    • Cause: You might be testing with a solid-state indicator instead of a mechanical relay, or the relay coil is damaged.
    • Fix: Verify the coil resistance matches the datasheet specifications.

Possible improvements and extensions

  1. MOSFET Upgrade: Replace the NPN BJT with an N-Channel Logic-Level MOSFET (e.g., IRLZ44N) for higher efficiency and zero gate current draw.
  2. Optical Isolation: Add an optocoupler (like 4N25) before Q1 to completely electrically isolate the 5 V control side from the 12 V power side, protecting the microcontroller from catastrophic power failures.

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 component acts as the switch driver to activate the relay?




Question 3: Why is this circuit particularly useful for microcontrollers?




Question 4: What is the specific function of the flyback diode in this circuit?




Question 5: What state does the transistor enter when the 5 V switch is closed?




Question 6: What voltage supply is specified for the relay coil in this practical case?




Question 7: What is the purpose of the base resistor (R1) connected to the transistor?




Question 8: Which part of the circuit provides galvanic isolation for the final load?




Question 9: What physical feedback indicates that the relay has successfully energized?




Question 10: What does the switch S1 simulate in this circuit context?




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: Intrusion alarm by wire break

Intrusion alarm by wire break prototype (Maker Style)

Level: Basic. Design a security circuit where cutting a wire activates an alarm using transistor saturation logic.

Objective and use case

In this project, you will build a closed-loop security system using a BJT transistor. When a specific wire (the «sense loop») is intact, the system remains silent; if the wire is cut or disconnected, an LED lights up immediately.

  • Perimeter security: Monitor windows or fences where a conductive strip or wire is installed.
  • Anti-tamper mechanisms: Detect if a device case has been opened by breaking a connection.
  • Continuity testing: Verify cable integrity in manufacturing harnesses.

Expected outcome:
* Loop Intact (Secure): The LED remains OFF. VBE ≈ 0 V.
* Loop Cut (Alarm): The LED turns ON. VBE ≈ 0.7 V and the transistor enters saturation (VCE < 0.2 V).

Target audience: Students and hobbyists learning basic transistor switching applications.

Materials

  • V1: 9 V DC power supply or battery.
  • Q1: 2N2222 or BC547 (NPN BJT), function: electronic switch.
  • R1: 10 kΩ resistor, function: base pull-up resistor.
  • R2: 470 Ω resistor, function: LED current limiting.
  • D1: Red LED, function: visual alarm indicator.
  • W1: Copper wire or jumper, function: sense loop (the «intruder» wire).

Wiring guide

Construct the circuit ensuring all connections map to the following nodes: VCC, GND (0), BASE, and COLLECTOR.

  • V1: Positive terminal to VCC, Negative terminal to GND.
  • R1 (Pull-up): Connects between VCC and BASE.
  • W1 (Sense Loop): Connects between BASE and GND.
  • Q1 (Transistor):
    • Base pin to BASE.
    • Emitter pin to GND.
    • Collector pin to COLLECTOR.
  • D1 (LED): Anode to VCC, Cathode to node LED_CATHODE.
  • R2 (Limiting): Connects between LED_CATHODE and COLLECTOR.

Conceptual block diagram

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

Schematic

Title: Practical case: Intrusion alarm by wire break

[ A. CONTROL / SENSING LOOP ]
(Logic: W1 keeps Base LOW. If W1 breaks, R1 pulls Base HIGH)

VCC (9 V) --> [ R1: 10k Pull-Up ] --(Node: BASE)--> [ Q1: Base ]
                                         |
                                         +-------> [ W1: Sense Wire ] --> GND


[ B. ALARM / POWER LOOP ]
(Logic: Current flows through LED only when Q1 is ON)

VCC (9 V) --> [ D1: Red LED ] --> [ R2: 470R ] --> [ Q1: Collector ]
                                                          |
                                                      (Switch)
                                                          |
                                                          v
                                                   [ Q1: Emitter ] --> GND
Schematic (ASCII)

Measurements and tests

Verify the logic states using a multimeter.

  1. State 1: Loop Intact (Secure)

    • Ensure the wire W1 connects BASE to GND.
    • Measure Voltage Base-Emitter (VBE): Should be 0 V.
    • Measure Voltage Collector-Emitter (VCE): Should be close to 9 V (Cut-off region).
    • Result: LED is OFF.
  2. State 2: Loop Broken (Alarm)

    • Disconnect or cut wire W1.
    • Measure Voltage Base-Emitter (VBE): Should be approximately 0.7 V.
    • Measure Voltage Collector-Emitter (VCE): Should be approximately 0.1 V to 0.2 V (Saturation region).
    • Result: LED is ON.

SPICE netlist and simulation

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

* Practical case: Intrusion alarm by wire break
.width out=256

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

* --- Input / Sense Loop ---
* W1: Sense Loop (Copper wire). 
* Modeled as a Voltage Controlled Switch (S_W1) to simulate the wire breaking.
* Logic: High Control (5V) = Wire Intact (Closed). Low Control (0V) = Wire Broken (Open).
S_W1 BASE 0 CTRL 0 SW_WIRE
.model SW_WIRE SW(Vt=2.5 Vh=0.1 Ron=0.01 Roff=100Meg)

* Control Signal for W1:
* Starts at 5V (Intact), breaks at 2ms (0V), stays broken for duration.
V_W1_CTRL CTRL 0 PULSE(5 0 2ms 1u 1u 5ms 10ms)

* --- Pull-up Network ---
* R1: Base pull-up resistor
* ... (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: Intrusion alarm by wire break
.width out=256

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

* --- Input / Sense Loop ---
* W1: Sense Loop (Copper wire). 
* Modeled as a Voltage Controlled Switch (S_W1) to simulate the wire breaking.
* Logic: High Control (5V) = Wire Intact (Closed). Low Control (0V) = Wire Broken (Open).
S_W1 BASE 0 CTRL 0 SW_WIRE
.model SW_WIRE SW(Vt=2.5 Vh=0.1 Ron=0.01 Roff=100Meg)

* Control Signal for W1:
* Starts at 5V (Intact), breaks at 2ms (0V), stays broken for duration.
V_W1_CTRL CTRL 0 PULSE(5 0 2ms 1u 1u 5ms 10ms)

* --- Pull-up Network ---
* R1: Base pull-up resistor
R1 VCC BASE 10k

* --- Switching Element ---
* Q1: NPN Transistor (2N2222)
* Connections: Collector, Base, Emitter(GND)
Q1 COLLECTOR BASE 0 2N2222
.model 2N2222 NPN(IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8E-12 CJE=25E-12 TR=46.91E-9 TF=411.1E-12 ITF=0.6 VTF=1.7 XTF=3 RB=10 RC=0.3 RE=0.2)

* --- Output / Alarm Indicator ---
* D1: Red LED
* Anode to VCC, Cathode to LED_CATHODE
D1 VCC LED_CATHODE LED_RED
.model LED_RED D(IS=93.2P RS=42M N=3.73 BV=4 IBV=10U CJO=2.97P VJ=0.75 M=0.33 TT=4.32U)

* R2: LED current limiting resistor
* Between LED_CATHODE and COLLECTOR
R2 LED_CATHODE COLLECTOR 470

* --- Simulation Commands ---
.op
* Simulate for 5ms to capture the wire break event at 2ms
.tran 10u 5ms

* --- Output Printing ---
* V(BASE): Trigger voltage (Low=Intact, High=Alarm)
* V(COLLECTOR): Output node (Pulled Low when Alarm is Active)
.print tran V(BASE) V(COLLECTOR) V(LED_CATHODE)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (536 rows)
Index   time            v(base)         v(collector)    v(led_cathode)
0	0.000000e+00	8.999991e-06	8.979590e+00	8.979590e+00
1	1.000000e-07	8.999991e-06	8.979590e+00	8.979590e+00
2	2.000000e-07	8.999991e-06	8.979590e+00	8.979590e+00
3	4.000000e-07	8.999991e-06	8.979590e+00	8.979590e+00
4	8.000000e-07	8.999991e-06	8.979590e+00	8.979590e+00
5	1.600000e-06	8.999991e-06	8.979591e+00	8.979591e+00
6	3.200000e-06	8.999991e-06	8.979592e+00	8.979592e+00
7	6.400000e-06	8.999991e-06	8.979594e+00	8.979594e+00
8	1.280000e-05	8.999991e-06	8.979598e+00	8.979598e+00
9	2.280000e-05	8.999991e-06	8.979604e+00	8.979604e+00
10	3.280000e-05	8.999991e-06	8.979610e+00	8.979610e+00
11	4.280000e-05	8.999991e-06	8.979616e+00	8.979616e+00
12	5.280000e-05	8.999991e-06	8.979622e+00	8.979623e+00
13	6.280000e-05	8.999991e-06	8.979629e+00	8.979629e+00
14	7.280000e-05	8.999991e-06	8.979635e+00	8.979635e+00
15	8.280000e-05	8.999991e-06	8.979641e+00	8.979641e+00
16	9.280000e-05	8.999991e-06	8.979647e+00	8.979647e+00
17	1.028000e-04	8.999991e-06	8.979653e+00	8.979653e+00
18	1.128000e-04	8.999991e-06	8.979659e+00	8.979659e+00
19	1.228000e-04	8.999991e-06	8.979665e+00	8.979665e+00
20	1.328000e-04	8.999991e-06	8.979671e+00	8.979671e+00
21	1.428000e-04	8.999991e-06	8.979677e+00	8.979677e+00
22	1.528000e-04	8.999991e-06	8.979684e+00	8.979684e+00
23	1.628000e-04	8.999991e-06	8.979690e+00	8.979690e+00
... (512 more rows) ...

Common mistakes and how to avoid them

  1. Connecting the loop to the Collector: Placing the sense wire on the output side will likely short the power supply or the LED, rather than controlling the transistor. Ensure the loop controls the Base.
  2. Omitting the Base Resistor (R1): If R1 is missing, the Base floats when the wire is cut, and the transistor may not turn on reliably. R1 provides the necessary turn-on current.
  3. No current limiting for LED: Forgetting R2 allows unlimited current to flow through the LED and Q1 upon alarm activation, instantly burning out the LED.

Troubleshooting

  • LED never turns ON: Check if R1 is connected to VCC. If the base never receives voltage when the wire is cut, the transistor stays OFF.
  • LED stays ON (even with loop intact): Check the W1 connection. If the resistance of the sense wire is too high (bad contact), it might not pull the base voltage down enough to turn off the transistor.
  • Transistor gets hot: Check if R2 is too low (excessive collector current) or if the LED is shorted.

Possible improvements and extensions

  1. Audible Alarm: Connect a 9 V active buzzer in parallel with the LED (and its resistor) to provide sound.
  2. Latching Circuit: Use a Thyristor (SCR) instead of an NPN transistor so that once the wire is cut, the alarm stays ON even if the intruder tries to reconnect the wire.

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 'sense loop' wire in this security circuit?




Question 2: When the sense loop is intact (secure state), what is the status of the LED?




Question 3: Which component acts as the electronic switch in this circuit?




Question 4: What happens electrically when the sense wire (W1) is cut?




Question 5: What is the approximate Base-Emitter voltage (Vbe) when the alarm is triggered (Loop Cut)?




Question 6: In the 'Secure' state (Loop Intact), why is the Base-Emitter voltage approximately 0 V?




Question 7: What is the purpose of resistor R2 (470R) in the Alarm/Power Loop?




Question 8: Which resistor acts as the 'Pull-Up' resistor for the base of the transistor?




Question 9: What transistor state corresponds to the 'Alarm' condition?




Question 10: Which of the following is a listed use case for this circuit?




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: Slow turn-off timer

Slow turn-off timer prototype (Maker Style)

Level: Basic — Construct a circuit that fades an LED out slowly using capacitor discharge.

Objective and use case

In this practical case, you will build an analog timer circuit using an NPN transistor and a capacitor. When a push button is released, the LED will not turn off immediately; instead, it will dim gradually until it extinguishes.

  • Interior car lighting: mimics the effect of dome lights fading out after the door is closed.
  • Safety lighting: provides temporary illumination in hallways or stairwells after a switch is turned off.
  • Debouncing simulation: demonstrates how capacitors smooth out sudden signal changes.
  • Visualizing RC time constants: allows direct observation of electrical charge storage and decay.

Expected outcome:
* Immediate ON: When the button is pressed, the LED lights up instantly at full brightness.
* Delayed OFF: Upon releasing the button, the LED remains lit and fades out over a period of 2 to 5 seconds.
* Voltage Decay: If measured with a multimeter, the voltage at the capacitor decreases exponentially.
* Visual Feedback: The LED brightness directly correlates to the remaining charge in the capacitor.
* Target audience: Students and hobbyists understanding the relationship between capacitors and transistors.

Materials

  • V1: 9 V DC supply, function: main power source
  • S1: Momentary push button (Normally Open), function: trigger mechanism
  • R1: 100 Ω resistor, function: switch current protection (limits inrush current to capacitor)
  • R2: 22 kΩ resistor, function: base current limiting and timing control
  • R3: 470 Ω resistor, function: LED current limiting
  • C1: 1000 µF electrolytic capacitor, function: charge storage (timing tank)
  • Q1: 2N2222 (or BC547) NPN transistor, function: current switch/amplifier
  • D1: Red LED, function: visual output indicator

Wiring guide

Use the following node connections to assemble the circuit on a breadboard.

  • Power Nodes:

    • VCC: Positive rail (9 V).
    • 0: Ground rail (0 V).
  • Switch and Capacitor Network (Nodes: VCC, V_STORE, 0):

    • S1 connects between VCC and an intermediate node (internal to switch assembly).
    • R1 connects between the switch output and V_STORE. (When S1 is pressed, V_STORE charges to ~9 V).
    • C1 connects between V_STORE (positive leg) and 0 (negative leg).
  • Transistor Control (Nodes: V_STORE, V_BASE, 0):

    • R2 connects between V_STORE and V_BASE.
    • Q1 (Base) connects to V_BASE.
    • Q1 (Emitter) connects to 0.
  • Output Stage (Nodes: VCC, V_COLL):

    • R3 connects between VCC and the anode of D1.
    • D1 (Cathode) connects to V_COLL.
    • Q1 (Collector) connects to V_COLL.

Conceptual block diagram

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

Schematic

+-------------------------------------------------------------------------+
|                       SLOW TURN-OFF TIMER DIAGRAM                       |
+-------------------------------------------------------------------------+

1. TIMING & CONTROL LOOP (Charges C1, drives Transistor Base)
---------------------------------------------------------------------------

VCC (9 V) --> [ S1: Button ] --> [ R1: 100 ] --(V_STORE)--> [ R2: 22k ] --> [ Q1:Base ]
                                                  |
                                                  v
                                            [ C1: 1000u ]
                                                  |
                                                  v
                                                 GND


2. OUTPUT LOAD LOOP (Powering the LED)
---------------------------------------------------------------------------

VCC (9 V) --> [ R3: 470 ] --> [ LED: Red ] --> [ Q1:Collector ]
                                                     |
                                                     v
                                              (Current Flow)
                                                     v
                                              [ Q1:Emitter ] --> GND
Schematic (ASCII)

Measurements and tests

To validate the circuit operation, perform the following steps:

  1. Charging phase: Press and hold S1. Measure the voltage at V_STORE relative to Ground. It should rise rapidly to approximately 9 V. The LED D1 should be fully lit.
  2. Base activation: While holding S1, measure the voltage at V_BASE. It should differ from V_STORE due to the drop across R2, stabilizing around 0.7 V – 0.8 V (the Base-Emitter saturation voltage).
  3. Discharge phase: Release S1. Observe D1. It should not turn off instantly. Instead, it should fade.
  4. Time measurement: Use a stopwatch to measure the time from the moment S1 is released until the LED is completely dark. With a 1000 µF capacitor and 22 kΩ resistor, this should take several seconds.
  5. Voltage tracking: Connect a multimeter to V_STORE immediately after releasing the button. Watch the voltage drop. The LED usually turns off when V_STORE drops below the threshold required to maintain sufficient base current through R2 (roughly when V_STORE approaches 1.5 V – 2 V).

SPICE netlist and simulation

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

* Practical case: Slow turn-off timer
.width out=256

* --- Models ---
* Standard NPN Transistor Model
.model 2N2222 NPN(IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8E-12 CJE=25E-12 TR=46.91E-9 TF=411.1E-12 ITF=0.6 VTF=1.7 XTF=3 RB=10 RC=1 RE=1)
* Generic Red LED Model (Vf approx 1.8V-2V)
.model DLED D(IS=1e-22 RS=10 N=1.5 CJO=50p)
* Switch Model for Push Button
.model SW_BTN SW(Vt=2.5 Ron=0.1 Roff=100M)

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

* --- Input / Trigger Mechanism ---
* S1: Push Button. Modeled as a voltage-controlled switch connecting VCC to SW_OUT.
* V_BTN_ACT: Simulates the user pressing the button. 
* Pulse starts at 1s, holds for 2s (simulating a solid press), then releases.
V_BTN_ACT CTRL 0 PULSE(0 5 1 0.1 0.1 2 100)
S1 VCC SW_OUT CTRL 0 SW_BTN
* ... (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: Slow turn-off timer
.width out=256

* --- Models ---
* Standard NPN Transistor Model
.model 2N2222 NPN(IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8E-12 CJE=25E-12 TR=46.91E-9 TF=411.1E-12 ITF=0.6 VTF=1.7 XTF=3 RB=10 RC=1 RE=1)
* Generic Red LED Model (Vf approx 1.8V-2V)
.model DLED D(IS=1e-22 RS=10 N=1.5 CJO=50p)
* Switch Model for Push Button
.model SW_BTN SW(Vt=2.5 Ron=0.1 Roff=100M)

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

* --- Input / Trigger Mechanism ---
* S1: Push Button. Modeled as a voltage-controlled switch connecting VCC to SW_OUT.
* V_BTN_ACT: Simulates the user pressing the button. 
* Pulse starts at 1s, holds for 2s (simulating a solid press), then releases.
V_BTN_ACT CTRL 0 PULSE(0 5 1 0.1 0.1 2 100)
S1 VCC SW_OUT CTRL 0 SW_BTN

* --- Switch Current Protection & Charging ---
* R1 limits inrush current to C1 when S1 is closed.
R1 SW_OUT V_STORE 100

* --- Timing Tank ---
* C1 charges when S1 is closed and discharges through R2/Q1 when open.
C1 V_STORE 0 1000u

* --- Transistor Control ---
* R2 provides base current and sets the discharge timing constant (Tau = R2*C1 approx 22s).
R2 V_STORE V_BASE 22k

* --- Transistor Switch ---
* Q1 NPN Transistor (2N2222)
* Collector: V_COLL, Base: V_BASE, Emitter: 0 (GND)
Q1 V_COLL V_BASE 0 2N2222

* --- Output Stage ---
* R3 limits current through the LED.
R3 VCC LED_ANODE 470
* D1 Red LED. Anode at LED_ANODE, Cathode at V_COLL.
D1 LED_ANODE V_COLL DLED

* --- Simulation Commands ---
.op
* Transient analysis for 60 seconds to capture the slow decay (RC ~ 22s).
.tran 0.1s 60s

* --- Output Directives ---
* Printing Capacitor Voltage (Timing) and Collector Voltage (Output State)
.print tran V(V_STORE) V(V_COLL) V(LED_ANODE) V(SW_OUT)

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (640 rows)
Index   time            v(v_store)      v(v_coll)       v(led_anode)    v(sw_out)
0	0.000000e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
1	1.000000e-03	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
2	2.000000e-03	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
3	4.000000e-03	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
4	8.000000e-03	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
5	1.600000e-02	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
6	3.200000e-02	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
7	6.400000e-02	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
8	1.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
9	2.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
10	3.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
11	4.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
12	5.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
13	6.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
14	7.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
15	8.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
16	9.280000e-01	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
17	1.000000e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
18	1.010000e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
19	1.026000e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
20	1.030750e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
21	1.039062e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
22	1.041363e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
23	1.045390e+00	8.962619e+00	1.066236e-01	2.056192e+00	8.999963e+00
... (616 more rows) ...

Common mistakes and how to avoid them

  1. Capacitor polarity reversed: Electrolytic capacitors have a specific polarity. Connecting the negative stripe to the positive voltage can cause the component to heat up or pop. Solution: Ensure the leg marked with a stripe (negative) connects to Ground.
  2. R2 value too low: If R2 is very small (e.g., 1 kΩ), the capacitor will discharge into the transistor base very quickly, resulting in no visible fading effect. Solution: Use a high resistance value (10 kΩ–47 kΩ) to slow down the discharge.
  3. Omitting R1: Connecting the switch directly to a large capacitor creates a massive current spike (spark) when pressed. Solution: Always use a small resistor (100 Ω) in series with the switch to protect the contacts.

Troubleshooting

  • LED turns off instantly (no fade):
    • Cause: Capacitor C1 is missing, disconnected, or the value is too small (e.g., 100 nF instead of 1000 µF).
    • Fix: Verify C1 is correctly seated and is at least 470 µF.
  • LED stays on permanently:
    • Cause: The switch S1 might be the wrong type (Latching instead of Momentary) or there is a short circuit bypassing the transistor.
    • Fix: Ensure the button releases physically and check wiring around the Collector-Emitter.
  • LED is very dim even when button is pressed:
    • Cause: R2 (Base resistor) is too high (limiting base current too much) or R3 (LED resistor) is too high.
    • Fix: Check that R2 is roughly 22 kΩ and R3 is roughly 470 Ω.

Possible improvements and extensions

  1. Variable Timing: Replace R2 with a 100 kΩ potentiometer in series with a 1 kΩ resistor. This allows you to adjust the fade-out duration manually.
  2. Darlington Pair: Replace Q1 with a Darlington transistor (or two NPNs connected in Darlington configuration). This offers a much higher current gain, allowing you to use a much larger R2 (e.g., 1 MΩ), resulting in extremely long timer durations (minutes) with the same capacitor.

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




Question 2: Which component is responsible for storing the electrical charge that keeps the LED lit after the button is released?




Question 3: What real-world application mimics the effect created by this circuit?




Question 4: What happens to the LED immediately when the push button is pressed?




Question 5: Based on the text, what is the purpose of the resistor R1 (100 Ω) in this specific circuit design?




Question 6: Which type of transistor is specified for use in this project?




Question 7: If you measure the voltage at the capacitor after releasing the button, how does it behave?




Question 8: What is the expected duration for the LED to fade out after releasing the button?




Question 9: Besides lighting, what concept does this circuit demonstrate regarding signal changes?




Question 10: What physical phenomenon allows the direct observation of electrical charge storage and decay in 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: