Shop OBEX P1 Docs P2 Docs Learn Events
Goofy problem with getting an IR LED to be detected by a IR detector on a 2nd Prop — Parallax Forums

Goofy problem with getting an IR LED to be detected by a IR detector on a 2nd Prop

vanmunchvanmunch Posts: 568
edited 2011-02-24 14:04 in Propeller 1
Solved!

Hooked up the two different Props (one receiving and one sending and receiving) on two different computers and that worked. However, the the sender and the reciever also had to be carfully aimed at each other to get a distance of more than 8 inches. Not like the remotes that could bounce it off the walls. The big thing was that the board was unpluged from the computer so the USB was waking up when "FullDuplexSerialPluse" tried to talk to the computer, thanks Rayman! So it looked like I was doing two things wrong the "FullDuplexSerialPluse" was waking up the USB and causing the board to reset and the light needed to be carefully aimed because it was dim.



Hey all,

I'm sure that the answer is as plain as the nose on my face so can someone hold up a mirror and tell me what I'm missing?

I'm modifing the lab in the PEK book V1.1 pg 148. I'm trying to have one prop control an IR LED that is then detected by a second prop that has an IR detector connected to it. The IR detector detects my remote controls, but it doesn't respond to the prop controlled IR. I figured that something must be wrong with the IR LED so I replaced it with a normal LED and could see it flicker. Ok, so I put the IR LED back and wired up a second IR detector to the same prop. So now I have a prop with both the IR detector and IR LED attached and it detects it, however the IR detector attached to the second Prop still doesn't respond (but it still does to my remote). I've checked all of the connections, I think I'm missing something with the code...

IrObjectDetection.spin

photo.jpg






''This code example is from Propeller Education Kit Labs: Fundamentals, v1.1.
''A .pdf copy of the book is available from www.parallax.com, and also through
''the Propeller Tool software's Help menu (v1.2.6 or newer).
''
'' IrObjectDetection.spin
'' Detect objects with IR LED and receiver and display with Parallax Serial Terminal.

CON

_clkmode = xtal1 + pll16x ' System clock → 80 MHz
_xinfreq = 5_000_000

' Constants for Parallax Serial Terminal.
HOME = 1, CR = 13, CLS = 16, CRSRX = 14, CLREOL = 11

OBJ

Debug : "FullDuplexSerialPlus"
SqrWave : "SquareWave"

PUB IrDetect | state

'Start 38 kHz square wave
SqrWave.Freq(0, 1, 38000) ' 38 kHz signal → P1
dira[1]~ ' Set I/O pin to input when no signal needed

'Start FullDuplexSerialPlus
Debug.start(31, 30, 0, 57600) ' Start FullDuplexSerialPlus
waitcnt(clkfreq * 2 + cnt) ' Give user time to click Enable.
Debug.tx(CLS) ' Clear screen

repeat

' Detect object.
dira[1]~~ ' I/O pin → output to transmit 38 kHz
waitcnt(clkfreq/1000 + cnt) ' Wait 1 ms
state := ina[0] ' Store I/R detector output
dira[1]~ ' I/O pin → input to stop signal

' Display detection (0 detected, 1 not detected)
Debug.str(String(HOME, "State = "))
Debug.Dec(state)
Debug.str(String(CR, "Object "))
if state == 1
Debug.str(String("not "))
Debug.str(String("detected.", CLREOL))
waitcnt(clkfreq/10 + cnt)
1024 x 765 - 135K

Comments

  • RaymanRayman Posts: 14,886
    edited 2011-02-24 03:50
    Do you have the transmitter and receiver pointed at each other? (Doesn't look like it in the photo...)
  • vanmunchvanmunch Posts: 568
    edited 2011-02-24 05:21
    Hey thanks Rayman, I just put them side by side for the picture although the IR detector on the demo board has no problem picking up the IR LED on it. It's constantly detecting it until I pull the IR LED out (not good practice). Both detectors have no problem detecting the remote. :/
  • RaymanRayman Posts: 14,886
    edited 2011-02-24 06:08
    Hmm... It seems like it should work... Maybe somthing strange is going on with the crystal on one of your boards?
    Maybe I'd try running 2 wires between the Props and try talking over fullduplexserial.

    Or, actually it's probably easier to try fullduplexserial one at a time over USB or PropPlug...
  • RaymanRayman Posts: 14,886
    edited 2011-02-24 06:13
    One other thing... That USB reset problems shows up in some configurations when using Fullduplexserial over pins 31&30 but without the USB cable connected...
    You might try not starting fullduplexserial if it's connected to an FTDI chip that isn't connected to a PC...
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-24 07:12
    Are you sure that the receiver is a 38kHz type?
    Do you have a scope to check the carrier frequency of the remote-controls?
    If the IR receiver has a different frequency it can still work, but with a dramatically decreased range.
  • vanmunchvanmunch Posts: 568
    edited 2011-02-24 07:30
    Hey Guys, good ideas, I'll try those after work tonight. I bet it is the USB reset thing. I ran into that pesky thing when I was trying to show some friends my prophex robot last summer. It worked fine inside, but in direct sunlight and ~100 degree F it just stuttered.

    The receivers are the ones that came with the Boe-Bot and PE kit. I don't have a scope and no idea how to use one, but maybe I'll get lucky with the "Free Friday giveaway" this Friday. :) I know that I really need to learn how to use one...

    Anyhow, I'll let you know how it goes.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-02-24 13:18
    From your code it looks like you're modulating a carrier frequency through the detector - is that necessary? My own experience with them has been that the emitter needs to be modulated, but the detectors I've used don't need it. (Like this one: http://www.sparkfun.com/products/10266) Edit: Never mind - the modulation code is for the output - I gotta read more carefully. :)

    The other thing that caught me was that the Prop will only push 20ma through the pins (I think - it might be 40), but an IR emitter will soak up 150ma or so. You're better off to use a transistor with a small value current limiting resistor on it, or your range will be horrible.
  • vanmunchvanmunch Posts: 568
    edited 2011-02-24 14:04
    Solved! Thanks everyone! Woot Woot!!

    Hooked up the two different Props (one receiving and one sending and receiving) on two different computers and that worked. However, the the sender and the reciever also had to be carfully aimed at each other to get a distance of more than 8 inches. Not like the remotes that could bounce it off the walls. The big thing was that the board was unpluged from the computer so the USB was waking up when "FullDuplexSerialPluse" tried to talk to the computer, thanks Rayman! So it looked like I was doing two things wrong the "FullDuplexSerialPluse" was waking up the USB and causing the board to reset and the light needed to be carefully aimed because it was dim.

    @JasonDorie I like your "edit reason", but who can blam you? How can you read carefully when you have a bird attacking your eye? :) But seriously, I'm planning on either using a smaller resistor or an amplifier. Thanks!
Sign In or Register to comment.