Saturday, September 26, 2026

Temperature-Controlled Fan



 Temperature-Controlled Fan

Here's the walkthrough with those two refinements folded in:

Power block: 12V-IN, +12V, GND
Power comes in through the 12V-IN connector onto the +12V and GND rails. Everything below is referenced to these two rails.

Reference block: R1 — the threshold-set divider
R1 is a 10k trimmer wired end-to-end between +12V and GND, with its wiper feeding the op-amp's non-inverting input. This just creates an adjustable reference voltage — turning the trimmer sets exactly what voltage the comparator will treat as "the trip point." Nothing here reacts to temperature; it's a fixed (but adjustable) reference.

Sensing block: R2 + R6 — the temperature divider
R2 (4.7k) sits between +12V and the sensing junction; R6 (the NTC thermistor) sits between that same junction and GND. That junction feeds the op-amp's inverting input. As temperature rises, R6's resistance drops, so more of the +12V drop falls across R2 — meaning the junction voltage (the inverting input) falls as it gets hotter.

Comparator block: IC1 (LM358)
The op-amp is wired open-loop, so it acts as a comparator: reference voltage on the non-inverting input, temperature-dependent voltage on the inverting input. As temperature climbs and the inverting input drops below the reference, the output swings high. Below threshold, output stays low. There's no feedback path back into either input here, which is worth noting — this comparator has no built-in hysteresis, so right around the trip point it could in principle chatter a little rather than switch cleanly.

Zener threshold/offset block: D2 + R4
The comparator's output doesn't drive the transistor directly — it goes through a 3V zener (D2) first, then R4 (1k) into the base. The zener's cathode faces the op-amp output; its anode faces R4. When the output is low, the zener simply blocks — no base current, transistor stays off. When the output swings high enough to exceed the zener's breakdown voltage, it conducts and passes the excess through R4 into the base. This builds in a fixed voltage threshold before the transistor gets any drive, rather than reacting to the very first millivolt of comparator swing — though it's worth keeping in mind that a zener's breakdown voltage isn't a precise, fixed number; it shifts a bit with current, temperature, and part tolerance, so "3V" here is approximate rather than exact.

Switching block: Q1 (BC547)
Q1's emitter is grounded, base comes from the zener stage above, and its collector is the relay coil's low side. When base current flows, Q1 turns on and pulls the coil's low side down toward ground, completing the circuit (the coil's other end is tied straight to +12V) and energizing the relay.

Relay block: K1 + flyback diode D1
D1 (1N4004) sits across the coil — cathode on +12V, anode on the switched (collector) side — as a flyback diode, clamping the inductive kick when Q1 turns off so it doesn't damage the transistor. On the switch side, the relay's common pole is tied to +12V, and its normally-open contact feeds the fan. So energizing the coil is what actually connects +12V through to the fan.

Output block: FAN connector
The fan's positive side comes from the relay contact (so it only gets power when the relay is energized); its return goes straight to GND. So: hot enough → comparator trips → transistor pulls the relay coil low → relay closes → fan gets +12V and spins.

Indicator: LED1 + R3
This is on its own separate branch — R3 (1k) from +12V straight into the LED, cathode to GND. It has no connection to the comparator, transistor, or relay at all, so it's simply a "power is on" indicator, not a "fan is running" indicator.

Net effect
Temperature rises above setpoint: NTC resistance falls → sensing voltage falls → inverting input drops below the reference → output goes high → Q1 turns on → relay energizes → fan gets +12V.
Temperature falls back below setpoint: NTC resistance rises → sensing voltage rises → inverting input goes back above the reference → output goes low → Q1 turns off → relay de-energizes → fan stops.

Unlike your latch circuit, this one has no memory — the fan just follows the thermistor directly, with no feedback path from the output back into the sensing or reference network. That also means no deliberate hysteresis: if the temperature sits right at the threshold, the relay can potentially chatter.
-
old you tube link with files : 
https://www.youtube.com/watch?v=ngJHaid4X3Q
temperature activated fan (උෂ්ණත්ව සංවේදී විදුලි පංකාව)

 

Understanding a Thermistor-Based Temperature Alarm Latch

 Understanding a Thermistor-Based Temperature Alarm Latch

 


 

Power block: PWR, +5V, GND
Power comes in through the PWR JST connector onto the +5V and GND rails. Every other block below is referenced to these two rails.

Sensing block: R19 + R21 — the resistor divider
R19 (the NTC thermistor) sits between +5V and the divider junction. R21 (the trimmer pot, wired as a two-terminal rheostat) sits between that same junction and GND. So the divider is: +5V → R19 → divider junction → R21 → GND. As temperature rises, R19's resistance drops, so the divider junction's voltage rises. R21 sets how far it needs to rise before the next stage reacts — that's your trip-point adjustment. D2's anode taps directly into this divider junction.

Trigger block: D2
D2's cathode sits on the latch's output node — the same node shared by Q2's collector, R10, R16, and C3. Normally that node sits low (latch off), so as the divider junction climbs with temperature, once it gets about a diode-drop above the output node, D2 starts conducting and pushes a small current into it. This is the "detect" event — a small trickle of current appearing there the moment the voltage condition is met. D2 is really acting as the voltage-sensitive trigger interface; the transistors that follow provide the actual amplification and memory.

What that trigger current does — through R10 into T2's base
That injected current at the output node has one meaningful path onward: through R10 (4.7K) into T2's base, which it shares with reset switch S2. So the small trigger current nudges T2 slightly into conduction.

Latch block: T2 + Q2 — the regenerative pair
This is the core mechanism:

  • T2 (NPN) starts turning on → pulls its collector down.
  • T2's collector feeds Q2's base through R15 (2.2K), so as it drops, Q2's base gets pulled down → Q2 (PNP) turns on.
  • Q2's emitter is on +5V, so turning on pulls its collector — which is that same output node D2 feeds into — up toward +5V.
  • That rise pushes more current through R10 into T2's base than the thermistor alone ever could.

That's the loop: T2 on → Q2 on → output node rises → drives T2 harder. This is regenerative switching — exactly how fast it snaps over depends on the transistor characteristics, capacitances, and resistor values, but the direction is unambiguous: once it starts, it runs away to fully on. Once latched, D2 and the thermistor stop mattering — the output node sits higher than the divider junction, so D2 goes reverse-biased and is out of the picture. The circuit is now holding the trip state purely through this feedback, not through any capacitor.

Supporting resistors and caps on the latch:

  • R17 (2.2K) is the pull-up from +5V to T2's collector. With T2 off it holds T2's collector, and therefore Q2's base, high — keeping Q2 off. When T2 turns on, it pulls that node low, pulling Q2's base low and turning Q2 on.
  • C4 (33µF, +5V to T2's collector) and C3 (1µF, output node to GND) provide filtering and transient stabilization around the regenerative nodes, making the circuit less sensitive to rapid voltage fluctuations.
  • R16 (1K, output node to GND) gives that node a defined path to ground when Q2 is off, and also sets how much current Q2 has to supply once it turns on.

Output block: SG2 + R18, and LED2 + R13/R14
Once latched, the output node sits near +5V. From there:

  • R18 (10R) current-limits into the buzzer SG2, whose return goes to GND — this sounds the alarm.
  • Separately, T2's emitter node drives the indicator: R13 (330R) feeds LED2's anode, LED2's cathode goes to GND, lighting it up. R14 (10K) sits from that same emitter node to GND in parallel, giving it a defined load/pull-down path too.

Reset block: S2
S2 connects T2's base directly to GND when pressed, forcing T2 off regardless of the latch state. With T2 off, R17 pulls its collector back up, releasing the pull-down on Q2's base, so Q2 turns off too, and the output node falls back low — buzzer and LED both go out. The important caveat: resetting doesn't remove the temperature condition. If the divider junction is still sufficiently above the output node, D2 conducts again the moment you release S2, and the regenerative process starts right back up.
-
old youtube video which contain the demo+circuit+pcb files :
https://www.youtube.com/watch?v=_q9TxOG8NQc
fire detector circuit (උෂ්ණත්ව සංවේදී පරිපථය).

Wednesday, September 23, 2026

practical diode-protection cheat sheet

 

1. Polarity Protection

Topology

How it works

Trade-off

Series diode

Diode in line with supply; wrong polarity → blocked

Simple, but costs a forward-voltage drop (less with Schottky)

Parallel crowbar diode

Diode across supply, normally reverse-biased; wrong polarity → conducts hard and blows a fuse

Robust, zero drop in normal operation, but needs a fuse/current limiter sized correctly

MOSFET "ideal diode"

MOSFET replaces the series diode, driven by a small controller or gate-charge circuit

Near-zero voltage drop; standard in battery and automotive gear

Bridge rectifier

Full bridge in the power path; input polarity no longer matters

~2 diode drops in the current path, but works for AC or DC-either-way inputs

2. Overvoltage Protection

Topology

How it works

Trade-off

Zener clamp

Zener from signal to ground; conducts once voltage exceeds Vz

Simple, but limited power handling and soft knee

TVS diode

Avalanche diode built specifically for transient suppression (ESD, inductive spikes, automotive)

Fast response, higher surge capability than a Zener; unidirectional or bidirectional

Avalanche diode

Diode/Zener/TVS chosen to break down at a controlled voltage

Common for clamping inductive spikes from motors, solenoids, relay coils

Steering-diode clamp

Diodes route overvoltage to a nearby rail (VCC or ground) instead of dissipating it locally

Good for ADC/analog input protection, usually paired with a series resistor

3. Negative-Voltage / Bidirectional Protection

Topology

How it works

Trade-off

Two-diode input clamp

One diode clamps to VCC, one clamps to ground — most MCU pins have this built in internally

Cheap, but only protects within a diode drop above/below the rails

Back-to-back diodes

Two diodes oriented oppositely across a signal line, limiting both polarities symmetrically

Good for bidirectional signal protection against small over/under swings

Bidirectional TVS

Single TVS package that clamps both polarities

Best combined ESD + transient protection for signal lines

4. Inductive Load / Switching Spike Protection

Topology

How it works

Trade-off

Flyback diode

Diode across the coil (relay, solenoid, motor) gives stored energy a path when the switch opens

Protects the driving transistor/MOSFET; slows relay release time

Zener + flyback diode

Zener in series with (or replacing) the flyback diode lets the coil collapse at a higher voltage

Faster release/turn-off, useful when timing matters

RC snubber

Resistor + capacitor across the switching element

Reduces spike amplitude and EMI, doesn't fully clamp

RCD clamp

Resistor + capacitor + diode network

Common in SMPS to absorb transformer leakage-inductance energy

5. Multiple Power Sources

Topology

How it works

Trade-off

Diode OR-ing

Each supply feeds the load through its own diode; only the highest-voltage source conducts

Simple, but a full diode drop lost from each source

Ideal-diode MOSFET OR-ing

MOSFET version of the above

Much lower loss, more complex control circuitry

Battery isolation diode

Same principle applied specifically to prevent one battery from charging/discharging another

Same trade-offs as diode OR-ing

6. Dedicated Protection ICs

Topology

How it works

Trade-off

ESD diode array

IC containing multiple low-capacitance diodes tied to a common rail structure

Used for USB, CAN, HDMI, RS-485, GPIO — designed to shunt ESD without loading the signal

Diode matrix / steering network

Multiple diodes route abnormal voltages from several inputs toward safe rails

Used in keyboards, multiplexed inputs, interface protection

7. Two-Layer / Combined Schemes

Topology

How it works

Series diode + Zener

Series diode handles reverse polarity, Zener handles overvoltage — simple two-stage protection for low-power circuits

Diode + fuse crowbar

Crowbar diode conducts on reverse polarity, fuse opens before damage — prioritizes simplicity over efficiency

The key distinction

Ordinary diodes, Zeners, TVS diodes, and MOSFET "ideal diodes" solve different failure mechanisms and aren't interchangeable:

  • Ordinary diode → one-way current blocking (polarity, OR-ing)
  • Zener → moderate-power voltage limiting at a fixed level
  • TVS → fast, high-surge transient absorption
  • MOSFET ideal diode → polarity/OR-ing protection with near-zero loss

Picking the wrong one for the job (e.g., a Zener where you need TVS-level surge handling, or a series diode where you need MOSFET-level efficiency) is the most common design mistake in this space.

PROTECTION CIRCUIT LIMITATIONS

Protection circuits are not magic shields. Every protection method has a voltage, current, energy, time, and frequency limit.

Series diode

Protects against reverse polarity, but does not protect against overvoltage.

The diode itself must also be rated for the maximum forward current and reverse voltage.

Crowbar diode + fuse

Protects against reverse-polarity connection, but depends on the fuse opening quickly enough.

The diode must survive the fault current until the fuse operates. A wrong fuse rating can make the protection ineffective or damage the diode.

MOSFET ideal diode

Provides very low-loss reverse-polarity or power OR-ing protection, but the MOSFET still has limits for voltage, current, power dissipation and transient energy.

It is not automatically an overvoltage protector.

Bridge rectifier

Makes input polarity irrelevant, but introduces approximately two diode forward-voltage drops in the current path.

It also does not inherently protect against overvoltage or current overload.

Zener diode

A Zener is mainly a voltage clamp, not a universal surge protector.

Its ability to absorb a fault depends on its power rating and the duration of the event. A series resistor or current-limiting element is often essential.

TVS diode

A TVS is designed to absorb short-duration transients, not unlimited continuous overvoltage.

If an excessive voltage remains continuously, the TVS can overheat and fail. The TVS must therefore be selected according to standoff voltage, clamping voltage, peak pulse current and pulse energy.

Steering-diode clamp

Steering diodes can safely redirect an abnormal signal only if the destination rail can absorb the resulting current.

Without current limiting, such as a suitable series resistor, the protection diode or the supply rail itself can be damaged.

Flyback diode

Protects a switching transistor from the voltage generated by an inductive load when it is switched OFF.

However, a conventional flyback diode also makes the coil current decay more slowly. It therefore may not be suitable when fast release is required.

Zener + flyback

Allows a higher voltage across the coil during turn-off, producing faster energy decay.

But the Zener must be rated for the resulting pulse current and energy. The switching transistor must also be rated for the higher voltage.

RC snubber

Reduces switching spikes and EMI, but does not guarantee that the voltage will remain below a particular safe level.

Its effectiveness depends strongly on the resistor, capacitor, switching frequency and parasitic inductance of the actual circuit.

RCD clamp

Useful for absorbing controlled amounts of leakage-inductance energy, especially in switching power supplies.

The components must be designed for the actual switching voltage, current, frequency and energy. An incorrectly designed RCD clamp can itself become a source of heating or failure.

Diode OR-ing

Prevents one power source from directly feeding another, but the diode introduces power loss.

It also does not automatically provide current limiting, short-circuit protection or overvoltage protection.

ESD diode array

Designed mainly for short, fast ESD/transient events.

It is not intended to continuously dissipate a large overvoltage. Signal-line capacitance and leakage current must also be considered, especially with high-speed interfaces.


THE MOST IMPORTANT RULE

When selecting a protection component, ask five questions:

1. What is the abnormal condition?
Reverse polarity? Overvoltage? ESD? Inductive spike? Short circuit?

2. How much voltage can appear?
The protection device must survive the actual voltage, not just the nominal operating voltage.

3. How much current can flow?
A clamp without current limiting can become the thing that fails.

4. How much energy must be absorbed?
A 1 kV pulse lasting a few nanoseconds and a 30 V fault lasting several seconds are completely different protection problems.

5. What happens if the protection device itself fails?
A TVS, Zener or crowbar diode may fail short or open. The surrounding fuse, resistor, MOSFET or power supply should be considered as part of the complete protection system.

In one sentence:

Protection design is not simply about choosing a diode with the right voltage rating — it is about controlling voltage, current, energy and time during a specific failure event.