PIR startup weirdness
dfletch
Posts: 165
Hi all.
I just picked up a PIR motion sensor from Radio Shack (how neat that some Parallax toys are waiting for me around the corner!).
I hooked it up to my protoboard and I'm having a strange startup issue. It seems that I need to wait the 10-60 seconds calibration/setup time and reset my Prop before it will work. If I don't, my little program here doesn't detect motion. It's weird though, the reset button doesn't always work. Reprogramming with f10 or f11 seems to do the trick sometimes.
I noticed a little bit of a pattern to it, don't know if that helps isolate.
1) During this "frozen" startup the pin seems high when I first read it. Then it goes low and never seems to go high again.
2) After waiting say 60 seconds and resetting, the pin is low when first read, goes high due to the motion of me messing around near the sensor and is now in normal operation.
I'm pretty darned positive that I'm doing something wrong with waitpne, because when I do this the ham-fisted way - display.dec(ina[noparse][[/noparse]12])) in a tight loop - it works great. Can anyone see the prob?
Thanks in advance if anyone has a hint.
Cheers,
--fletch
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler
I just picked up a PIR motion sensor from Radio Shack (how neat that some Parallax toys are waiting for me around the corner!).
I hooked it up to my protoboard and I'm having a strange startup issue. It seems that I need to wait the 10-60 seconds calibration/setup time and reset my Prop before it will work. If I don't, my little program here doesn't detect motion. It's weird though, the reset button doesn't always work. Reprogramming with f10 or f11 seems to do the trick sometimes.
I noticed a little bit of a pattern to it, don't know if that helps isolate.
1) During this "frozen" startup the pin seems high when I first read it. Then it goes low and never seems to go high again.
2) After waiting say 60 seconds and resetting, the pin is low when first read, goes high due to the motion of me messing around near the sensor and is now in normal operation.
I'm pretty darned positive that I'm doing something wrong with waitpne, because when I do this the ham-fisted way - display.dec(ina[noparse][[/noparse]12])) in a tight loop - it works great. Can anyone see the prob?
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ display : "GDM1602K" PUB start | state, count display.start(0) dira[noparse][[/noparse]12]~ count := 0 state := 2 repeat if ina[noparse][[/noparse]12] if state <> 1 count++ display.clear display.str(string("on: ")) display.dec(count) state := 1 else if state <> 0 count++ display.clear display.str(string("off: ")) display.dec(count) state := 0 waitpne (state << 12, %100_0000_0000, 0)
Thanks in advance if anyone has a hint.
Cheers,
--fletch
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler
Comments
Try:
Or, if you want to make it all readable:
Perfect!
Thanks,
--fletch
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
Newbies, oldies, programmers, math professors, and everyone in-between welcome!
Propeller IRC howto
spinc - open source Spin compiler