1. Panoramica tecnica e principio di funzionamento
Whenever an analog sensor (NTC temperature, photodiode light level, liquid level, or battery voltage) needs to trigger a clean digital alarm, relay, or fan without a microcontroller, a Comparator with Positive-Feedback Hysteresis (Schmitt Trigger) is the essential circuit.
A bare single-threshold comparator chatters violently whenever sensor noise hovers near Vref — burning out relay contacts in minutes. Adding just ONE positive-feedback resistor Rf splits the trip point into two clean thresholds (Vth+ and Vth−), creating a rock-solid noise-immune deadband!
Dual Threshold Mechanics: Positive feedback routes a small fraction of the output voltage back to the non-inverting (+) pin. When output snaps HIGH (5 V), it nudges the (+) pin upward, reinforcing the HIGH state so Vsens must drop all the way below Vth− to flip back LOW — giving deadband ΔVh = Vcc · (R1 / Rf).
Dedicated Comparator vs Op-Amp: Always prefer a real comparator (TLV3201 push-pull or LM393 open-collector) over a general-purpose op-amp! Op-amps suffer slow overload recovery from saturation rails and some have back-to-back input clamp diodes that short Vsens to Vref.

2. Step-by-step: Sizing a chatter-free Schmitt trigger sensor switch
1Measure peak-to-peak sensor noise and set ΔVh ≥ 3× noise
Choose ΔVh wide enough to reject noise AND stop mechanical equipment short-cycling (e.g. 100–300 mV for alarms, 0.5–1.0 V for pump/fan thermostats).
2Compute Rf = R1 × (Vcc / ΔVh) around your target Vref
Pick R1 = 10 kΩ (large enough not to load the sensor), then calculate Rf (e.g. 100 kΩ gives ΔVh = 500 mV on 5 V). Keep sensor source impedance << R1.
3Remember pull-up resistor if using open-collector LM393
LM393 cannot source HIGH voltage! Add a 2.2–4.7 kΩ pull-up resistor to Vcc (and note R_pu adds to Rf when HIGH — pick Rf ≥ 20 × R_pu so symmetry stays tight).
4Add a small input RC filter BEFORE R1 (never right at the + pin!)
Filter high-frequency sensor noise BEFORE R1 so the positive feedback step at the (+) pin snaps instantaneously without delay.
3. Ricerca guasti sul campo con multimetro
| Sintomo | Causa principale | Verifica multimetro | Soluzione |
|---|---|---|---|
| Relay buzzes / chatters for 1–2 seconds as temperature crosses setpoint | Missing Rf hysteresis, ΔVh smaller than sensor noise, or power-supply dip when relay pulls in | Probe Vref and Vcc during relay engagement; confirm ΔVh > 3× ripple | Lower Rf to widen ΔVh, decouple Vcc near comparator (100 µF + 100 nF), and stabilize Vref |
| LM393 output never goes HIGH (always stays near 0 V) | Forgot external pull-up resistor on open-collector LM393 output | Check datasheet output stage — LM393/LM339 are open-collector | Add 4.7 kΩ pull-up resistor from output pin to +5 V (or use push-pull TLV3201) |
4. Domande frequenti (FAQ)
Why shouldn’t I use an LM358 op-amp as a sensor comparator?
Op-amps are internally frequency-compensated for linear feedback, so recovering from rail saturation takes tens of microseconds and output slew is sluggish — increasing noise susceptibility during switching. Dedicated comparators snap in nanoseconds.
How much hysteresis (ΔVh) is enough?
At least 3× the worst-case peak-to-peak noise at the comparator input (typically 50–200 mV for clean board sensors, 300–800 mV for noisy remote process probes or pump/heater deadbands).
Does the sensor’s own output impedance affect Schmitt trigger thresholds?
YES! Any sensor source impedance R_s adds directly in series with R1 (R1_eff = R1 + R_s), widening hysteresis and shifting thresholds! Either buffer the sensor first or include R_s in your R1 calculation.
How do I invert the logic so output goes HIGH when sensor drops BELOW Vref (e.g. low-battery)?
Swap inputs to an Inverting Schmitt Trigger: connect Vsens to (−) and apply Vref + positive feedback Rf to (+). Then Vsens < Vth− snaps output HIGH!
Can I build a Window Comparator (both Under-Range AND Over-Range alarms)?
Yes! That’s why open-collector LM393 is legendary: tie the two comparator outputs together with ONE shared pull-up resistor — either Under-Limit OR Over-Limit pulls the shared FAULT line LOW automatically!
Why does a relay turning ON sometimes make the comparator immediately turn back OFF?
Relay coil inrush pulls down the shared power rail, momentarily lowering Vsens or shifting Vref across the threshold. Add bulk decoupling (100 µF) and derive Vref from an independent shunt reference (TL431) rather than raw Vcc.
5. Calcolatori correlati, guide e altri circuiti
- Calcolatore di partitore di tensione NTC
- Calcolatore di filtro RC anti-aliasing
- Amplificatore a Transimpedenza (TIA) per Fotodiodo
- Amplificatore Shunt di Corrente High-Side vs Low-Side
- Condizionamento Piezo / IEPE (ICP) Corrente Costante
- Trasformatore di Corrente AC (CT): Burden, Bias Vref/2 e TVS
- Filtro RC Charge-Bucket (Kickback) per ADC SAR e Assestamento
- Potenziostato 3 Elettrodi per Sensore Gas Elettrochimico
- Amplificatore di Carica Piezoelettrico (Immune al Cavo)
- Uscita Sensore PNP 3 Fili (Sourcing) — Circuito e Simulatore
- Uscita Sensore NPN 3 Fili (Sinking / Open-Collector)
- Circuito NAMUR 2 Fili Sicurezza Intrinseca (IEC 60947-5-6)
- Loop di Corrente 4–20 mA 2 Fili e Ricevitore Protetto