PIR Problem Help Please
robomaker
Posts: 12
I am trying to use a PIR sensor to delay action until motion is detected. However it seems to send a HIGH signal right away and does not wait for motion;
I am using this code at the beginning of my program but it always produces no motion pause. What am I doing wrong?
Do
IF IN4 = 1 Then GOTO Start
LOOP
Start;
REST OF PROGRAM...........
IN4 Seems to always be at 1
What gives? Any help would be greatly appreciated. Hope I don't seem too stupid
I am using this code at the beginning of my program but it always produces no motion pause. What am I doing wrong?
Do
IF IN4 = 1 Then GOTO Start
LOOP
Start;
REST OF PROGRAM...........
IN4 Seems to always be at 1
What gives? Any help would be greatly appreciated. Hope I don't seem too stupid
Comments
Is the PIR powered up at the same time the microcontroller is powered up? Try powering up the PIR by itself and see what it does / how it works.
Try disconnecting the PIR from IN4 and see what happens.
You didn't mention which processor you're on, but here's some sample code for the Basic Stamp 1, originally from EFX-Tek, that could help. Note the section right after MAIN that debounces the PIR input, it makes a big difference.
These are facts from my past projects.
PIR sensor needs to be powered up always, if not it will need about a one minute warmup.
PIR sensor, once warmed up consumes almost no power. I've had 4 AA batteries last for 6 months.
PIR sensor output is active high whenever the red LED in the sensor is On.
PIR sensor will see through plastic milk carton material. I use 1/2 gallon milk carton for weather proofing.
PIR sensor is very sensistive to sunlight when output is set to the default of long range.
I hope these facts help you.
garyg,
I just wanted to touch on one point in your comments for clarity on PIR sensor operation. You noted that the PIR sensor is very sensitive to sunlight in the long range mode. It's not the light that it is sensitive to. If you're using a clear material to weatherproof the sensor you may be experiencing a mild greenhouse effect caused by sunlight passing through the material and striking a surface converting some of the energy into radiated heat energy, which is then trapped inside the material. This is how your car heats up so much inside wen sitting in the sun. So the PIR is responding to the changes in heat as it should. Without the weatherproof material it should not be doing that though, unless picking up radiated heat from a surface, such as you might see radiated heat from asphalt on a sunny day.
Point Noted and well taken.
On my outdoor project, I've fabricated a sunshield, similar to a baseball cap bill.
I painted the inside of my housing black
I also set my PIR on the 15ft less sensitive setting.
The milk carton material is somewhat translucent, but basically clear.
I'll need to observe my owl project over a day or two to see if the misfires due to heat on my
milk carton window disappear. The thing actually works very good after sunset.
I hope this discussion helps out Robomaker.
A good understanding of how these sensors actually works is very helpful in general.
Yes, that was my hope as well. Like any sensor, things can vary based on environment, location, enclosure, etc. So sometimes experimentation is necessary.