Introduction
When using PIR sensors, two timing parameters significantly affect behavior: hold time (also called delay time) and block time (lockout time). Understanding these parameters is essential for designing reliable motion-triggered systems.
Hold Time (Delay Time)
Definition: The duration the output remains HIGH after motion is detected.
On HC-SR501, this is adjusted via the “TIME” potentiometer, typically ranging from 5 to 200 seconds. When motion is detected, the output goes HIGH and stays HIGH for the set hold time, even if motion stops.
Repeatable Trigger Mode (H)
If motion continues to be detected during the hold time, the timer resets, extending the output HIGH period. This ensures the output stays HIGH as long as someone is moving in the area.
Non-Repeatable Trigger Mode (L)
The output stays HIGH for the full hold time regardless of subsequent motion, then goes LOW. The sensor ignores any motion during the hold time.
Block Time (Lockout Time)
Definition: The period after the hold time ends during which the sensor will not trigger again.
On HC-SR501, block time is fixed at approximately 2.5 seconds. This prevents the sensor from immediately retriggering, allowing the circuit to stabilize. During block time, the sensor ignores motion.
Block time is sometimes referred to as “inhibit time” and is essential for reducing false triggers from electrical noise or minor fluctuations.
Timing Diagram
Motion | | | | | | | | | | |
+---+ +---+ +---+ +---+
Output |_______| |_______|
Hold Time |<----->| |<----->|
Block Time |<->| |<->|
Adjusting for Your Application
Short Hold Time (5-10 seconds)
- Ideal for: Occupancy sensing where you want fast response when person leaves.
- Example: Automatic light in closet.
Long Hold Time (1-2 minutes)
- Ideal for: Security systems where you want alarm to stay triggered.
- Example: Intruder alarm.
Applications Requiring Rapid Retriggering
If you need to detect motion quickly after a previous event, consider using non-repeatable mode with a short hold time, or choose a sensor with adjustable block time.
Measuring Timing with an Oscilloscope
To verify your sensor’s timing, connect the output to an oscilloscope or logic analyzer. Trigger on rising edge and measure the pulse width. This is the hold time. The period until the next possible trigger (including block time) can be observed as the minimum time between two output pulses.
Limitations of Potentiometer Adjustment
The potentiometers on HC-SR501 are not precise; they vary between units and with temperature. If exact timing is critical, consider using a microcontroller to interpret the sensor output and implement your own timing logic, ignoring the sensor’s internal timing.
Example: Custom Timing with Arduino
You can set the sensor’s hold time to minimum and use Arduino to extend it:
const int pirPin = 2;
const int holdTime = 10000; // 10 seconds in ms
unsigned long lastTrigger = 0;
bool outputState = false;
void setup() {
pinMode(pirPin, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
if (digitalRead(pirPin) == HIGH) {
lastTrigger = millis();
outputState = true;
}
if (outputState && (millis() - lastTrigger > holdTime)) {
outputState = false;
}
digitalWrite(13, outputState ? HIGH : LOW);
}
Conclusion
Hold time and block time are critical for PIR sensor behavior. By understanding and adjusting them, you can tailor motion detection to your specific needs.
