View Full Version : PIR Sensor Help
03-07-2007, 05:07 AM
Hello everyone.· I apologize if this question has already been answered but I searched and couldn't find it.· I am building a device that will sense motion and play a sound when that motion is detected.· It will be mounted in a doorway so my intention is for the sound to play when somone enters or exits through the doorway.· I was planning on using the PIR sensor to detect·the entrance or exit,·but I am having trouble achieving the desired result.· In the preliminary testing I've done, the sensor does not seem to be as sensitive as I need.· I am running it off of a 5V power supply and for testing purposes·I've connected an LED to the output to see when the output is high (simple diagram attached).· The LED turns on when power is first applied· and then turns off a few seconds later as expected.· However, it seems to detect motion at random times or not at all.· For instance I can wave my hand in front of the sensor and the LED does not turn on, but it turns on when I am just sitting in front of it.· Is there a minumum range required for the sensor to function properly?· Can it detect motion 5ft, 2ft, 1ft, 6in, etc?· For it to work in this project it would have to be able to detect motion as close as 6 in.· I have played with the jumper in both the H and L positions and have obtained similar results.· Anyway, any insight into this problem would be greatly appreciated.· Thanks in advance.
03-07-2007, 05:11 AM
The PIR sensor is slow to react regardless of distance. It detects temperature differences in far infrared. It's not really a motion detector so much as a heat difference sensor. It also accomodates to the ambient temperature pattern in a space. I'll bet if you sit in front of it, it will eventually ignore you.
03-07-2007, 06:30 AM
Mike is correct in that the PIR detects sudden changes in the heat pattern. The documentation also explains that it is necessary to allow a kind of warm-up or settling time for the sensor to adjust to the current ambient heat patterns. As Mike suggested if you sat perfectly still in front of it the PIR should eventually adjust. But you need to give it the adjustment time or it may not function properly until left alone for awhile. Driving an LED will consume some current. I’m not sure if/how that may affect the sensor operation since we don’t really recommend driving anything from the output. Take care.
Parallax Tech Support
03-07-2007, 08:15 AM
Thanks for the quick replies and the input.
I was unaware that the PIR sensor would not react quickly when I purchased it for this application. I need to detect a person walking at normal speed past the sensor about 6 - 18" in front of it. According to Mike's post it sounds like the PIR is not suited for a quick detection like that. Please correct me if I've misinterpreted your comments Mike. I was aware of the 10 - 60 second warm up time as stated in the data sheet and I did wait several minutes but it didn't make a difference. I hadn't considered that the LED would be drawing current and that might affect the sensor. I will scrap the LED and hook it up to a PIC to see if it makes a difference.
I've also started looking at alternatives and I'd be interested to hear your opinions on that. I was looking at the PING ultrasonic range sensor and I think I can adapt my project to use that instead of the PIR. I can have a PIC record the distance the PING is measuring shortly after power up. This distance would be the distance to the opposite side of the doorway about 2.5ft (as long as I'm not standing in front of it at power up). It would then repeatedly measure the distance (say 5 times/sec) and if the distance suddenly decreased that would indicate someone stepped in front of the PING when they were walking through the doorway.
It sounds simple to me but then again I also thought the PIR would work for this project. Please let me know if you see anything fundamentaly wrong with this idea or if you have a cheaper and/or simpler solution. Thanks again.
03-07-2007, 08:31 AM
Okay, I think maybe we lost you a bit…The PIR is slow to settle, but in fact it is quick to react. I have used these in alarm systems for many years and this unit reacts the same in the testing we have done at Parallax. Once allowed to settle, the sensor immediately brings its output line HIGH when a hand is waved or even if a piece of paper is waved in front of it. The position of the jumper affects whether or not the line is forced low between re-triggers. This is covered in the current documentation on out website. But in fact the line should go HIGH almost immediately. What happens when you let it settle then walk past it?
Parallax Tech Support
03-07-2007, 10:17 AM
Okay, I scraped the LED and connected the output of the PIR to an I/O pin on a 16F688. I wrote some quick code to monitor the output from the PIR and when it goes high, the PIC turns on an LED connected to a different I/O pin. So this should solve any potential problems I may have been experiencing earlier when driving the LED directly from the PIR output (I think). I tested the PIC by connecting a pushbuton to the same pin on the PIC that would be connected to the PIR output and verified that the LED lit up when I depressed the pushbutton (simulating the high signal the PIR will output when motion is detected). All that worked fine.
I then did the following with the jumper in H position:
1. Turn on the power (the LED lights up for 2-3 sec and then turns off).
2. Allowed the PIR to "warm up" for 5 minutes. I did not walk in front of it, wave my hand in front of it, change the lighting in the
room, or do anything else that might significantly change the IR profile of the room.
3. After 5 minutes I walked back and forth in front of the PIR about 3-4 feet in front of it 5 times before the LED lit up for about 2-3 sec. After the LED went out I continued walking back and forth in front of it and the LED would not turn on.
4. I sat down in front of the PIR and waved my hand in front of it approx 4-6" away all the while the the LED is not turning on. I then moved the sensor itself and this caused the LED to turn on for 2-3 sec, but when I placed it back down I could not get the LED to consistently light up again.
I hope I have been clear in my explainations. Thanks again for your help.
03-07-2007, 10:56 AM
I used to have a PIR burglar alarm sensor and had a very similar experience in testing it. I think you'll do better with the PING. I suggest you take several readings (2-3) at your 5/sec rate and average them.
03-07-2007, 11:05 AM
OK Mike thanks for the input. I think I'll begin pursuing the PING idea unless Chris or anyone else have any additional insights or suggestions. Thanks.
03-07-2007, 11:30 AM
Another option could be using an IR LED and IR detector on opposite sides of the doorway so the beam gets interrupted when someone goes through the doorway. The Robotics book that you can download from Parallax's Stamps in Class website page has some examples. You can drive the LED with a 555 timer or a PIC or a Stamp or whatever can put out a 38kHz square wave. The detector runs off 5V and has a transistor to ground (with a 20K or so weak pullup to 5V) when it detects the IR.
03-07-2007, 12:42 PM
It sounds like you may have a defective or misadjusted PIR sensor. A good one should be able to detect motion over a range of distances and directions, and quite fast enough for your purposes. I've noticed too that burglar alarm sensors vary widely in sensitivity.
The one in your diagram looks like it has a little domes with radial detection zones. The warm body to be detected has to move across those zones so that it creates a fluctuating heat pattern on the sensor elements at the focal point of the lens. There are several types of lens that can be fitted onto PIR sensors, and each type of lens provides a different pattern of sensitivity, for example, a "curtain" or a "fisheye" or a "beam" and many of the ones used for burglar alarms are "multizone". I have designed custom PIR sensors that monitor the activity of bats at cave entrances and the blip of a bat flying through can be less than 0.05 second. That used a curtain or beam lens.
Another option might be the Sharp GP2D12, which is an IR transmitter LED and receiver for distance measurement, in one package. The PING uses ultrasound. However, one nice thing about PIR sensors is that they consume quite low current, whereas the ones with active light or ultrasound are relatively power hungry.
03-07-2007, 10:13 PM
Perhaps there is something wrong with your PIR sensor…You should definitely be getting constant re-triggering with motion in front of the sensor. We could have you send it in and have it tested to see what is going on. If defective we would certainly replace it. One note about PING))) or any ultrasonic sensor being used to detect people is that people are very poor reflectors of sound waves. In a small doorway you can almost always get it to work to some degree by detecting any change in distance but you will find that sometimes the measurement from a person can be way off between two pulses as one is absorbed and another is reflected. This may or mat not be a problem in your case. Again, the PIR could work, and certainly should as described, so I would recommend contacting us directly about having that sent in for testing. Take care.
Parallax Tech Support
03-07-2007, 11:01 PM
Thanks for the suggestions from Mike and Tracy.· I didn't know about the GP2D12 before but it sounds like a good possibilty I will explore.·
I think I would like to send the PIR back to see if there something wrong with it.· At this point I hope·it is defective because if the PIR is working fine then that means there is something wrong with me.·Anyway,· should I contact you directly or just call the customer service number?· Thanks.·
03-08-2007, 01:57 AM
Please contact support either at our main phone number or via e-mail at firstname.lastname@example.org (mailto:email@example.com)
Parallax Tech Support