Shop OBEX P1 Docs P2 Docs Learn Events
output pin of IR detector — Parallax Forums

output pin of IR detector

kwanzimelonhidekwanzimelonhide Posts: 20
edited 2009-12-23 00:38 in Accessories
there's something I'm not understanding about the IR detector.

In the documentation, it states, "In the absence of IR flashing on and off at around 40 kHz, the IR detector sends a 5 V high signal. When IR flashing on and off at around 40 kHz enters this lens, the circuitry inside the IR detector sets its output to 0 V (active-low)."

How come the voltage on the output pin of the IR detector does not measure 0 V once the IR beam·is transmitted? It is always about 5 V.· I want to get a motor to turn on and off without a microcontroller, simply by having the change from 5 V to 0 V create the necessary voltage drop when the motor leads are connected·to·5 V·and the output pin of the IR detector.·

thanks!·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-22 06:18
    The IR detector cannot produce enough current to operate a motor. You have to have a switching transistor actually switch the motor on and off and the IR detector can turn the transistor on and off. There is a diagram on the last page of Nuts and Volts Column #6 that shows how to use a switching transistor with a microcontroller. You can just use the IR detector's output to trigger the switching transistor. Remember that the transistor will work in reverse. When the IR detector is not seeing any light, its output will be at 5V which will switch the transistor on. When the IR detector is seeing a 40KHz light source, its output will be at 0V which will switch the transistor off. To change this the opposite way, you can change the circuit around and use a PNP switching transistor or you can add another NPN transistor to invert the signal from the IR detector.

    Nuts and Volts Columns: www.parallax.com/tabid/272/Default.aspx

    Switching Transistors: knol.google.com/k/electronic-circuits-design-for-beginners-chapter-8#

    The last circuit on the webpage uses a PNP transistor to switch on a load like a motor when the input is brought to 0V like what the IR detector does when on.

    Post Edited (Mike Green) : 12/22/2009 6:26:16 AM GMT
  • kwanzimelonhidekwanzimelonhide Posts: 20
    edited 2009-12-22 06:33
    thanks for the response...though I am still confused about why the voltage at the output pin is not measured to be 0 V when the IR detector sees the 40 kHz light source.
  • kwanzimelonhidekwanzimelonhide Posts: 20
    edited 2009-12-22 07:31
    also, why doesn't only the current capacity of the battery matter if the motor is connected to the battery's positive terminal?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-22 16:20
    1) Try connecting the output pin of the IR receiver just to the meter. If it doesn't read near 0V (0.3-0.4V typically), one of two things is true: a) You've damaged the output transistor of the IR receiver; b) You're not really generating 40KHz IR light for the IR receiver to receive.

    2) The current capacity of the battery does matter. It needs to be large enough that the battery can supply the requirements of the motor. The other connection of the motor matters too. The current has to go somewhere. If that connection can only provide a limited amount of current, then that's all the current that will flow regardless of what the battery can supply.
  • kwanzimelonhidekwanzimelonhide Posts: 20
    edited 2009-12-22 19:24
    I connect one lead of the voltmeter to ground, the other lead to the IR receiver output pin. Without the IR led shining, it's 4.89 V, and with the IR led shining, it lowers to 4.84 V. but the basic stamp sample program

    ' Program Listing 1.1 - Testing the IR Beam.bs2
    IR_detect VAR Bit
    LOW 15
    Main:
    PAUSE 50
    FREQOUT 15, 1, 38500
    IR_detect = IN8
    IF IR_detect = 0 THEN unbroken

    DEBUG HOME, "Beam is broken; object detected. "
    GOTO Main
    unbroken:

    DEBUG HOME, "Beam is unbroken; object not detected."
    GOTO Main

    works perfectly, so once again I don't get why the voltage only lowers slightly and doesn't go to 0 V.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-22 20:36
    Assuming you have the IR LED connected properly with a proper series resistor, your program only turns on the LED for 1 millisecond. You're not going to see a pulse that narrow with a voltmeter. Try changing the FREQOUT to "FREQOUT 15,30000,38500". That will turn on the LED for about 30 seconds, long enough to notice with a voltmeter.
  • kwanzimelonhidekwanzimelonhide Posts: 20
    edited 2009-12-22 21:41
    thank you so much! it works now...just a few more things i'm curious about: how come the basic stamp doesn't also need the LED to be on longer to indicate the presence of the beam? also, why is the resistor for the IR LED suggested to be 220 ohms in the documentation? thank you...
  • ZootZoot Posts: 2,227
    edited 2009-12-22 23:46
    The Stamp can read the IR state in 1ms (or less) because the microcontroller is much much much faster than your eye/brain (though not nearly as sophisticated, of course).

    The 220 ohm resistor is to limit the CURRENT flowing through the LED (so it doesn't burn out) and to limit the current through the Stamp pin (ditto).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-23 00:38
    If you know Ohm's Law, try using that with the information you already have on that pullup. If you don't know it, read the Wikipedia article on it. It's a basic mathematical rule in electricity and electronics. You need to know and understand it.
Sign In or Register to comment.