Shop OBEX P1 Docs P2 Docs Learn Events
PnP IR Optical Sensor — Parallax Forums

PnP IR Optical Sensor

alessendrocrowalessendrocrow Posts: 6
edited 2010-12-18 15:53 in Accessories
I'm doing a walking robot with turn right or left when an object is detected, i'm using Basic Stamp 2 as software. Can any one give an idea or concept that how i'm gonna to program the sensor part.....

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-12-15 06:49
    Depends on the type of optical sensor. If it is a phototransistor that provides a high/low signal it is relatively simple. If the signal is high take one action, if the signal is low take the other action. An IR imaging chip requires a more complex program.
  • alessendrocrowalessendrocrow Posts: 6
    edited 2010-12-15 08:09
    how if it's a phototransistor, can u give me a hand, please
  • kwinnkwinn Posts: 8,697
    edited 2010-12-15 11:35
    Can you post a schematic of the phototransistor circuit and the code you have so far?
  • ercoerco Posts: 20,256
    edited 2010-12-15 13:23
    Most phototransistors are NPN, not PNP. Unless you meant plug & pray...

    The BoeBot text shows pretty clearly how to make a more reliable object detector using an IR LED and a 38 kHz IR rcvr module. Scribbler gets left & right detection using one center mounted detector and 2 LEDs, one left one right.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-15 14:41
    The thing about phototransistors is that it doesn't matter whether they're constructed as PNPs or NPNs, since there's no base connection. Both types would function exactly the same.

    -Phil
  • ercoerco Posts: 20,256
    edited 2010-12-15 16:33
    @PhiPi: Did I fail to mention that I was speaking only about metric, left-handed, Australian, region 13 PNP phototransistors? What with the corriolis, reversed seasons and sunspot activity, strange things have been know to happen down under! :)

    Seriously, thanks for your input. I have seen a few Fairchild metal-can phototransistors that do have an unused base lead. It's just there for moral support!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-15 17:23
    Erco,

    You're right: there are some with base connections. Frankly, I'm not sure what they're for, though. Biasing, perhaps?

    -Phil
  • ercoerco Posts: 20,256
    edited 2010-12-15 20:18
    Not sure, but I use them for mechanical fastening & accurate aiming. The FPT540A's I used had nice glass lenses that made them very directional, and they were much more rigid with the base wire soldered to an isolated PC board pad.
  • alessendrocrowalessendrocrow Posts: 6
    edited 2010-12-18 05:35
    the sensor picture can found at this site,
    http://cgi.ebay.com.my/PnP-Opto-IR-Sensor-Basic-Stamp-PIC-AVR-MCU-Robot-/350233715179?pt=LH_DefaultDomain_0&hash=item518b8e61eb
    it only consists of 1 output, the boe-bot sensor is similar to this sensor, but, i just dint work it out, can some one teach me ?
  • alessendrocrowalessendrocrow Posts: 6
    edited 2010-12-18 09:53
    kwinn wrote: »
    Can you post a schematic of the phototransistor circuit and the code you have so far?

    main:
    FREQOUT 4, 1, 38500
    Left_sensor = IN4

    IF (Left_sensor = 0) THEN
    GOSUB turn
    ELSE
    GOSUB forward
    ENDIF
    GOTO main
  • alessendrocrowalessendrocrow Posts: 6
    edited 2010-12-18 10:06
    main:
    FREQOUT 4, 1, 38500
    Left_sensor = IN4

    IF (Left_sensor = 0) THEN
    GOSUB turn
    ELSE
    GOSUB forward
    ENDIF
    GOTO main

    i wonder my robot dint get into ' turn ' command, and the sensor red LED just keep blinking when ther's an object in front of my robot, the LED should be a permanent light up when ther's an object, is'nt it ?
  • alessendrocrowalessendrocrow Posts: 6
    edited 2010-12-18 10:08
    This is urgent, i really hope some you guys can figure out solution for me, please
  • ercoerco Posts: 20,256
    edited 2010-12-18 15:53
    The specs for your sensor module show 2 differences from the stock BoeBot sensor:

    1) it generates the IR frequency by itself (don't freak out: you don't need the FREQOUT) and
    2) this module is active HIGH where BoeBot's sensor is active low

    So your code should look more like:

    Left_sensor = IN4
    main: IF (Left_sensor = 1) THEN GOSUB turn ' was 0
    ELSE
    GOSUB forward
    ENDIF
    GOTO main
Sign In or Register to comment.