I have designed a security system using PIR sensor module i have successfully interfaced with micro controller and is working that is as it detects the motion alarm starts ringing for preset time, however I want to delay the sensor module output so that when motion exists for short time ( 1 or 2 minute ) it should be ignored and if motion exists more than 1 or 2 minute then only module will give me output. I have connected jumper to H position. please help i have tried with the help of microcontroller like ring the alarm after 1 minute after motion detection, however it rings alarm if motion for short time exists.
Code for micro should go like:-if motion alarm = true , start timer. Has timer reached 1 min? if yes then is motion alarm true? if yes then ring bell.
Frank
As an alarm system installer i would suggest built a pulse/time system like almost all alarm systems have.
Assign how many pulses (motion detections) must occur and in what time window.
e.g. if u assign pulses=3 and time=30 seconds, then the PIR must detect 3 motions in 30 seconds, in order to start the siren. If only 2 are detected, after 30 seconds, pulses=0.
Something like:
Code:
unsigned int pulse_counter, timer;
reset{
pulse_counter=0;
timer=0;
}
motion_detect{
if (pulse_counter<3 & timer>30){
reset;
}
if (pulse_counter>3 & timer<30){
start_alarm;
}
if (pulse_counter<3 & timer<30){
pulse_counter++;
delay_ms(1000);
timer++;
}
}
main{
**if motion detected** goto motion_detect;
}
Thanks for your excellent solution, i will definately try the logic, but what about the hardware because in PIR sensor module there is a 3-pin jumper selection for single or continuous trigger output mode. The two positions have labels H and L. When the jumper is at H position, the output remains high when the sensor is re-triggered repeatedly. In position L, the output goes high and low every time the sensor is triggered. So a continuous motion will give repeated high/low pulses in this mode. then should I keep jumper at L mode to implement above logic.
You need to get a pulse for every detection from the module.
Also you have to make the MCU determine if there is a real alarm and not trying to delay the module detection.
So the module detects every motion, transfers every motion to the MCU, then the MCU makes the calculations and gives the alarm output or not.
Also i made a mistake with the above diagram, the timer thing is wrong (increases only on every motion, not every second).
You have to use Timer0 or Timer1 for that, start Timer when a detection occur, run the rest of the code until alarm or until Timer interrupt occur(30 sec) which will reset Timer and pulses.