Introduction
The final stage in a PIR signal chain is a comparator that converts the analog signal to a clean digital output. Adding hysteresis prevents oscillation when the signal hovers near the threshold.
Why Hysteresis is Essential
Without hysteresis, when the input signal is near the threshold, noise can cause multiple rapid output transitions (chattering). Hysteresis creates two thresholds: one for rising edge (V_rising) and a lower one for falling edge (V_falling). This creates a dead zone that ignores noise.
Hysteresis Calculation
For a non-inverting comparator with positive feedback:
- Upper threshold (V_UT): V_ref + (V_OH – V_ref) × R1/(R1+R2)
- Lower threshold (V_LT): V_ref – V_ref × R1/(R1+R2) (assuming V_OL = 0)
- Hysteresis width: ΔV = (V_OH – V_OL) × R1/(R1+R2)
Where V_OH is comparator output high voltage, V_OL is output low (near 0).
Design Example
Goal: Hysteresis of 100 mV around a threshold of 1.0V. Supply voltage = 3.3V, comparator output swings 0 to 3.3V.
- Choose R1 and R2 to set ΔV. ΔV = 3.3 × R1/(R1+R2) = 0.1V.
- R1/(R1+R2) = 0.1/3.3 = 0.0303.
- If R1 = 10k, then R2 = 10k × (1/0.0303 – 1) = 10k × (33 – 1) = 320k (choose 330k).
- Center threshold set by V_ref. Use resistor divider from VCC to generate 1.0V.
Using Comparators with Built-in Hysteresis
Many comparators (e.g., LMV7235, MAX9025) have built-in hysteresis of a few millivolts. For larger hysteresis, external feedback is still needed.
Inverting vs. Non-Inverting
The above formula is for non-inverting configuration (signal to non-inverting input). For inverting, the calculation differs.
Practical Circuit
Analog input ────┬──── 10k ────┬──── Inverting input of comparator
│ │
10k │
│ │
V_ref (1.0V) ───┴──────────────┴──── Non-inverting input
Adjusting Threshold Dynamically
For adaptive systems, the threshold can be generated by a DAC or PWM-filtered signal from a microcontroller, allowing software-adjustable sensitivity.
Output Pull-Up
If using an open-drain comparator, add a pull-up resistor to VCC. Choose value (e.g., 10k) for fast rise time.
Conclusion
Proper comparator design with hysteresis ensures clean, reliable digital output from your PIR sensor.
