Shop OBEX P1 Docs P2 Docs Learn Events
Why doesn't this IR detection program work? — Parallax Forums

Why doesn't this IR detection program work?

RichardFRichardF Posts: 168
edited 2007-06-25 03:24 in Propeller 1
{Only the first pulse out gives a return detect signal (red LED on), then the red LED goes off until I remove the reflective surface from in front of the LED, then reinsert it. I then get one detect pulse and then nothing again. In other words I am only getting one return detected (the first one) even though the reflector object remains in place. It resets if I remove the reflector then reinsert it. The IR_detect_2 method is straight out of the Counter Modules and Cicuit Applications Lab PE Kit Lab Series, page 29. Any ideas, please?
Thanks,
Richard}

CON
_clkmode = xtal1 + pll16x················
_xinfreq = 5_000_000

VAR
byte IR_detect

OBJ
SqrWave··· : "SquareWave"

PUB main
IR_detect_2

PUB IR_detect_2
SqrWave.Freq(0, 2, 38500)········ '38.5 kHz signal → P2·······················
dira[noparse][[/noparse]15]~~····························· 'output to red indicator LED
repeat
· dira[noparse][[/noparse]2]~~···························· 'I/O pin → output to transmit 38.5 kHz
· waitcnt(clkfreq/1000 + cnt)···· 'Wait 1 ms
· IR_detect := ina[noparse][[/noparse]3]··············· 'Store I/R detector output·
· dira[noparse][[/noparse]2]~······························ 'I/O pin → input to stop signal
···
· if IR_detect == 0·················· 'object detect
··· outa[noparse][[/noparse]15]~~······················· 'turn on red LED
· else
··· outa[noparse][[/noparse]15]~························ 'turn off red LED
····

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-06-24 08:11
    Richard,

    Just out of curiosity, what happens if you just leave the IR's clock output enabled, instead of keying it on and off (i.e. put the dira~~ above the repeat, and eliminate the dira~)?

    -Phil
  • RichardFRichardF Posts: 168
    edited 2007-06-24 16:19
    Did that, doesn't make any difference.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-06-25 03:24
    Check your connection between the detector's output and the Propeller. It almost sounds as if it's capacitively coupled instead of solidly connected.

    -Phil.
Sign In or Register to comment.