Shop OBEX P1 Docs P2 Docs Learn Events
Can't get infrared detector to work — Parallax Forums

Can't get infrared detector to work

SSteveSSteve Posts: 808
edited 2006-03-25 19:07 in Learn with BlocklyProp
I just got the StampWorks kit and I've been going through the experiments. I'm having trouble with experiment #20. I'm assuming it's supposed to detect when the IR from the LED is blocked, but it acts like it's always seeing the IR. Even if I completely remove the IR LED, it still says "All Clear".

I think I have the LED connected correctly. (My background is in programming and I know very little (so far) about analog circuits.) I have the long lead connected to the resistor that goes to Pin 0. The short lead is connected to ground. I have the detector connected as shown in the diagram.

The program is working correctly. If I connect Pin 1 to ground, it shows "Intruder Alert!". With pin 1 connected to VDD it shows "All Clear".

So it seems like the Detector is always detecting IR but when I completely remove the LED from the circuit, it still always says "All Clear".

The thing that seems weird to me is that if I reverse the leads on the LED, the program always says "Intruder Alert!".

I'm stumped. Can anyone figure out what I'm doing wrong?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows

Comments

  • Steve JoblinSteve Joblin Posts: 784
    edited 2006-03-20 15:50
    Are you using fresh batteries? I have had funny things like this happen to me, and it always seems to get "fixed" when I replace the batteries...
  • SSteveSSteve Posts: 808
    edited 2006-03-20 17:25
    I'm not using batteries. The board is powered from a 12V adapter.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-20 17:57
    How are you connecting the LED?· Which lead goes where on the board?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • SSteveSSteve Posts: 808
    edited 2006-03-22 20:44
    The long lead is connected to the 1k resistor which is connected to P0. The short lead is grounded.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-22 21:41
    Can you swap out the LED with another?· Separately you could also swap out the detector.· If you have a Digital Camera or Camcorder you can see if the IR LED is working.· These devices usually pick up IR light.· I use my HP Digital Camera all the time to verify.· You can double check by putting a TV Remote up to the camera to verify it sees a known good source.· Likewise you can use the TV remote to attempt to trigger the detector briefly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2006-03-22 22:23
    Just for kicks, have you tried turning the IR LED around? I just came across one of my own where the short lead was the Anode.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • SSteveSSteve Posts: 808
    edited 2006-03-22 22:54
    Chris: what a great trick! I never would have thought of that. My camera does indeed see the IR from my TiVo remote.

    Beau: I had tried turning the LED around like I said in my first post and the program always said "Intruder Alert". I just tried it again and the program switches to "All Clear" when I break the beam (which I would swear it wasn't doing before). Just to double-check: Was I was correct in originally connecting the long LED lead to Pin 0 through the resistor and the short lead to ground? If so, then this LED is backward.

    Also, the program works opposite from what I'd expect. It says "Intruder Alert" when the IR is detected and "All clear" when the beam is broken. Is that the way it's supposed to work or is it a bug in the program? (I'm using the experiment 19 program I downloaded from the StampWorks product page.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2006-03-22 23:52
    SSteve,

    In your original post...
    You said...

    ...I just got the StampWorks kit and I've been going through the experiments. I'm having trouble with experiment #20. I'm assuming it's supposed to detect when the IR from the LED is blocked, but it acts like it's always seeing the IR.....

    I'm a little confused, since I don't have a StampWorks book in front of me. However, looking online at experiment #20, it has something to do with Sound effects.
    see www.parallax.com/html_pages/downloads/sw/sw.asp


    Aside from that, I'm glad you got something working.

    In your original post...
    You also said...

    Even if I completely remove the IR LED, it still says "All Clear".
    In your latest post...
    You said...

    ...I just tried it again and the program switches to "All Clear" when I break the beam...

    Without looking at your code, both of the statements above seem to logically agree.

    In your latest post...
    You also said...

    ...If so, then this LED is backward....

    Not necessarily, the Anode or Cathode being longer than one another can vary depending on what the manufacturer decides.
    "Usually" the Anode is longer, but it is not an absolute requirement. I don't have one of our IR-LED's to check against so I can't
    confirm which of ours is longer or shorter.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/22/2006 11:55:05 PM GMT
  • SSteveSSteve Posts: 808
    edited 2006-03-23 00:40
    Beau said...
    I'm a little confused, since I don't have a StampWorks book in front of me. However, looking online at experiment #20, it has something to do with Sound effects.
    That's StampWorks 1.2. I'm using 2.0: www.parallax.com/dl/docs/books/sw/Web-sw-v2.0.pdf
    Beau said...
    Not necessarily, the Anode or Cathode being longer than one another can vary depending on what the manufacturer decides. "Usually" the Anode is longer, but it is not an absolute requirement. I don't have one of our IR-LED's to check against so I can't confirm which of ours is longer or shorter.
    Well that's good to know. Now that I know I can see IR with my camera's display, I'll be able to check in the future.
    Beau said...
    In your original post...
    SSteve said...
    Even if I completely remove the IR LED, it still says "All Clear".
    In your latest post...
    SSteve said...
    ...I just tried it again and the program switches to "All Clear" when I break the beam...
    Without looking at your code, both of the statements above seem to logically agree.
    You're right. But I was confused because the program from the book was doing the opposite of what I expected. I assumed it would say "All Clear" when it detected IR and "Intruder Alert" when it didn't.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • PARPAR Posts: 285
    edited 2006-03-24 02:09
    Just out of curiosity, is the short lead also the side with the flat part on the lens' edge?

    Also, is the short lead also the side that holds the larger "part" inside the lens --i.e., the part that contains the LED's cone-shaped reflector?

    If so, then it seems maybe the leads were cut the wrong lengths.

    (The flat side, and the large "part" are (supposed to be) the cathodes too, along with the short lead.)

    PAR
  • SSteveSSteve Posts: 808
    edited 2006-03-24 05:37
    PAR said...
    Just out of curiosity, is the short lead also the side with the flat part on the lens' edge?
    Yes
    PAR said...
    Also, is the short lead also the side that holds the larger "part" inside the lens --i.e., the part that contains the LED's cone-shaped reflector?
    Yes
    PAR said...
    If so, then it seems maybe the leads were cut the wrong lengths.
    I just fixed that with my wire cutters.

    Cruel trick to play on a beginner, though. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-24 06:23
    SSteve -

    Cruel trick? I'm not so sure about that.

    Consider that you just had a valuable, first hand learning experience that you'll probably never forget. The real lesson here is: to have trust in what you know and can prove, and not in what you think you know, based merely on convention. The "you" here is third person.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • SSteveSSteve Posts: 808
    edited 2006-03-24 17:28
    Bruce:

    I meant the cruel trick comment more as a joke, but you are correct. It was a good lesson that didn't hurt anything and I learned a great way to test IR LEDs.

    -Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • PARPAR Posts: 285
    edited 2006-03-25 01:27
    SSteve said...
    PAR said...
    Just out of curiosity, is the short lead also the side with the flat part on the lens' edge?
    Yes
    PAR said...
    Also, is the short lead also the side that holds the larger "part" inside the lens --i.e., the part that contains the LED's cone-shaped reflector?
    Yes
    PAR said...
    If so, then it seems maybe the leads were cut the wrong lengths.
    I just fixed that with my wire cutters.

    Cruel trick to play on a beginner, though. smile.gif

    Hmmmm. Now I'm confused. Originally you said your project didn't work correctly if you connected the "short" lead to ground (as instructed by the manual).

    But, above you respond to my questions with "Yes" (i.e., that your *short* lead is on the same side of the LED as the flattened surface and the large cone-shaped reflector). So, it sounds like your short lead was correctly placed, and should not have been trimmed.

    No? Yes?

    PAR
  • SSteveSSteve Posts: 808
    edited 2006-03-25 09:00
    Ok, well now I'm completely confused too. smile.gif Here's what I currently think is supposed to be the case:

    short lead = cathode = flat side of lens = larger plate in body = the lead that gets connected to ground
    long lead = anode = smaller plate in body = the lead that gets connected to VDD

    I just tested this with a red LED, a green LED, and a yellow LED and it and it was true for all of them. But to get the IR LED to light up (looking at it through the screen on my digital camera) I connect the lead on the flat side of the lens with the larger plate in the body to VDD and the lead with the smaller plate in the body to ground. I'm not sure what to think at this point.

    (Just to be complete: the side of the LED with the smaller plate in the body went through a 220 Ohm resistor to VDD.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • PARPAR Posts: 285
    edited 2006-03-25 17:27
    SSteve, See my PM (personal message) to you.
    PAR
  • SSteveSSteve Posts: 808
    edited 2006-03-25 19:07
    SSteve said...
    (Just to be complete: the side of the LED with the smaller plate in the body went through a 220 Ohm resistor to VDD)
    That's a typo. It should say that the larger plate went through a resistor to VDD. I just double-checked to make sure that is the case. And then I double-checked again.

    I'm really sorry that this was the first thread I started on this forum. I think it has made me look like a complete idiot when, in reality, I'm a reasonably intelligent person.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
Sign In or Register to comment.