Shop OBEX P1 Docs P2 Docs Learn Events
emitter/detector — Parallax Forums

emitter/detector

ltmhallltmhall Posts: 102
edited 2007-01-30 15:06 in BASIC Stamp
Is there any way you could design a emitter/detector circuit so the emitter would be on the time
and not be pulsed through the basic stamp using a hex schmitt trigger or something.
«1

Comments

  • LSBLSB Posts: 175
    edited 2007-01-24 16:41
    If you mean IR... there are several IR emitter schematics (Google) for using a 555 to provide a 40K modulated signal (aside: the higher 555 voltage range allows driving 2-3 LEDs for wider, denser signal). I have seen a couple of ultrasound emitters using a BS to trigger a 40K signal pulse, again produced by a 555. A pair of 555's (556) could be used to produce a modulated signal in regular bursts.
  • ltmhallltmhall Posts: 102
    edited 2007-01-24 17:41
    I'm a little confused. I all ready have the parallax IR pair. What I wanted to do was be able to run the emitter without tieing up the basic stamp.

    So I could use this schematic shown below to run an emitter, but would the other circuit look like.

    Post Edited (ltmhall) : 1/24/2007 5:50:43 PM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-01-24 18:33
    The reciever circuit would look exactly the same.
  • ltmhallltmhall Posts: 102
    edited 2007-01-24 18:45
    1) The reciever would just consist of a Infrared·detector. One pin to· a resistor, another to ground,
    ····and the other connected to the basic stamp as shown in the boe bot manual. Could I
    ··· use the emitter circuit with the 555 timer I posted earlier. Suppose I wanted to build a pair
    ··· would I need two 555 timer circuits.

    2) I know this may seem like a stupid question but is a emitter/detector the same as detector/reciever
    ··· I'm new to robotics and I hear people call them different things.

    Post Edited (ltmhall) : 1/24/2007 6:51:23 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-24 20:17
    Detector and receiver in this case refer to the same thing. Emitter and transmitter would both be terms for the device that produces the IR signal. The 555 timer circuit you posted earlier is exactly what you could use. There are slightly simpler circuits, but that one should work fine. If what you want is two IR LEDs both producing a beam of pulsing IR, you could use one 555 circuit to drive both of them. Each one has it's own series current limiting resistor, but they're both connected to the switching transistor and the + power supply where the single one is shown in your diagram.

    These days, you buy an integrated receiver/detector for pulsed IR (at a specific frequency - often 40KHz) rather than making your own circuit. These are the detectors that Parallax (and others) sell. They connect to +5V and ground and have a 3rd pin as mentioned that becomes grounded when the detector detects something. You connect a pull-up resistor from that pin to +5V (often 4.7K) and also connect that pin to the microcontroller (Stamp) I/O pin.
  • ZootZoot Posts: 2,227
    edited 2007-01-24 22:02
    This doc has lots of great info and circuits (incl. 555 timer generation of the modulated IR frequency): www.parallax.com/dl/docs/prod/sic/WebIR-%20v1.1.pdf

    The 555 circuit in that doc lets you turn on/off the emitter(s) with a single pin (LOW or HIGH, no FREQOUTs). I would suggest that you turn the emitters on and off when you need them -- if they are on all the time then you will use juice AND you are more likely to trip up other IR detectors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-24 22:09
    So I could use my parallax infrared detector to sense the IR signal thats produced by the 555 emitter circuit.
    I would just connect one pin of the detector (as shown in the boe bot robotics manual) to the Basic Stamp and this will be the only connection to it from the IR circuit.

    And if I wanted to add a second IR LED to my previous circuit. I just connect one end to power and the other
    would just connect to a resistor that connects to the collector of the 2N2222 transistors.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-24 22:15
    Yes.

    The BOE-BOT Robotics manual is a great reference.
  • ZootZoot Posts: 2,227
    edited 2007-01-24 22:22
    Are you talking about transistors in your schematic in your Word doc? I confess I don't have a copy of Word on my laptop so was unable to view it. The circuit in the IR tutorial PDF from Parallax uses *very few* components besides the 555, and a 555 will drive several LEDs easy without transistors. I used this circuit with 4 IR LEDs on one of my 'bots and I had to use 2k resistors because it was hard to get the LEDs *dim* enough...

    So as Mike said, yes, you would only *need* one pin for the IR detector. But you might like the option of using another pin to turn the 555 on and off. For example:

    IR555  PIN   5  'to reset pin of 555/LEDs circuit
    IRdet   PIN   6  'from output pin of IR detector (use a resistor)
    
    DO
       HIGH IR555   'turn on 555 -- now all LEDs on the 555 circuit are flashing at ~38khz (or whatever your modulation freq. is)
       IF IRdet = 0 THEN
           'you have got a hit, do some stuff
           DEBUG "ohmigosh, I got hit with my own IR reflection", CLREOL, CR
        ENDIF
        LOW IR555   'turn off 555 -- now LEDs are dark, you save juice and you don't trigger detectors on other projects
        '...    
        PAUSE 10
        '....
        'now, because you know your own LEDs are off, you can look for something else's IR too!
       IF IRdet = 0 THEN
           DEBUG "something is emitting modulated IR other than myself!!!", CLREOL, CR
       ENDIF
    LOOP
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-24 22:53
    Where the schematic says Low To Disable, you can connect to a Stamp pin. When LOW, the IR emitter is turned off. When HIGH or INPUT, the IR emitter is turned on. It should be connected to any I/O pin.
  • ZootZoot Posts: 2,227
    edited 2007-01-24 22:53
    said...
    However, if I wanted to turn the emitter circuit on/off I would connect it to the Basic Stamp.

    Correct.

    I checked out the schematic in your Word doc. In the circuit posted you would connect the "pin" labeled "take low to disable" to your Stamp pin -- if that pin is HIGH or INPUT the timer is on, if that pin is LOW, the timer is off. The posted circuit has a pullup on the disable line which it takes it "high" by default, even if the enable/disable line is left unconnected.

    If it were me, I would use the circuit in the IR tutorial PDF (link is above). Way fewer parts, and you don't need the transistors if you are driving 1-4 LEDs or so (though I bet you could push it to 6 or 7 if you weren't driving the LEDs too hard). That said are you actually using a CMOS and not a TTL timer? Check the specs for the actual 555 you are using -- the TTL 555 I use will drive nearly 200ma, which is way more than I need usually.

    Now you can just tie the reset pin on the 555 high (to +5v) to keep the LEDs on all the time (and saving a pin).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-24 22:55
    Yes the is a 2n2222 transistor.

    If I used the 555 timer circuit shown in
    www.parallax.com/dl/docs/prod/sic/WebIR-%20v1.1.pdf

    Could this also be used to produce the emitter circuit and turn it off/on.
    The I would just connect the reciever as shown in the robotics manual.
    In this design if I wanted to add another IR LED, would I just connect between
    ground and a I/O pin or would I need another 555 timer.

    For my robot I need it to be able to roam towards a light and avoid obstacles. In addition
    it must be able to hear a sound and be able to react to it. While designing I had friend tell
    me that it wouldn't be a good idea to pulse it through the microcontroller because that it
    would just be a burden to have the microcontroller do it and it would slow down its process
    of running through the other comands.

    Thats just a little backround about why I want it to be pulsed seperatley.


    THANKS FOR EVEYONES HELP I REALLY APPRECIATE IT

    Post Edited (ltmhall) : 1/24/2007 11:10:25 PM GMT
  • ZootZoot Posts: 2,227
    edited 2007-01-24 23:46
    ltmhall said...
    Yes the is a 2n2222 transistor.

    If I used the 555 timer circuit shown in
    www.parallax.com/dl/docs/prod/sic/WebIR-%20v1.1.pdf

    Could this also be used to produce the emitter circuit and turn it off/on.

    Yes.
    said...
    The I would just connect the reciever as shown in the robotics manual.
    In this design if I wanted to add another IR LED, would I just connect between

    ground and a I/O pin or would I need another 555 timer.

    No, you would only need another IR LED and another resistor. You would wire that LED and resistor to the 555 output just like the single LED in the circuit. You would be wiring the LEDs in parallel but each would have it's own resistor. You may need to experiment with resistor values to get the IR "brightness" you want.
    said...
    For my robot I need it to be able to roam towards a light and avoid obstacles. In addition
    it must be able to hear a sound and be able to react to it. While designing I had friend tell
    me that it wouldn't be a good idea to pulse it through the microcontroller because that it
    would just be a burden to have the microcontroller do it and it would slow down its process
    of running through the other comands.

    It's not so much a burden, since you are only FREQOUTing for a very very brief time, but with the 555 circuit you can run one more than one LED from one pin. One caveat -- with the 555 circuit you can only get a YES/NO on whether an obstacle is present; you can not get a distance range as described in Robotics with the Boe-bot.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • LSBLSB Posts: 175
    edited 2007-01-25 00:30
    As others have pointed out, it doesn't take much processing power to run the whole IR system with the Stamp. Think of yourself in a dark room with a camera flash unit, you trigger the flash and move according to the snapshot you see in that brief instant--then trigger the flash again. The bigger consideration is that while moving and listening, can you flash often enough to remain aware of your surroundings. Remember, the stamp only does one thing at a time and, motor control is a very processor intensive process. In the project you outline I would think that motor control would consume roughly 60% of your processor time, hearing 30%, and seeing 10%. I'm making a lot of assumptions here, but if obstacles are fixed in position and if you see them a foot away it will be a couple of seconds before you've moved far enough to need to 'see' again, hearing will require listening for much more brief inputs (presumably) and smooth motion will require near constant output (if you are planning to use any type of processor speed control). If you offload the motor control then you will have a lot of free time (processor cycles) and the brief flash and read of IR is relatively inconsiderable.
  • ltmhallltmhall Posts: 102
    edited 2007-01-25 01:49
    In the IR tutorial PDF (link is above) does the 555 have to be a NE555N.

    I tried building the circuit with a LM555CN using the code below and the debug terminal reads 0 HZ.

    ' IR Remote for the Boe-Bot - Test555Frequency.bs2
    ' Displays 555 timer frequency for potentiometer adjustment and tuning.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    cycles VAR Word
    DO
    HIGH 6
    COUNT 7, 100, cycles
    LOW 6
    cycles = cycles * 10
    DEBUG HOME, "Frequency = ", DEC5 cycles, " Hz"
    LOOP
  • ZootZoot Posts: 2,227
    edited 2007-01-25 02:31
    In the resources I checked they both have the same datasheet and are listed as functional equivalents, so I would double check your wiring and components first. You could also try wiring up a regular LED and resistor to the 555 output and see if you get anything for a visual test.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-25 02:36
    Would having a 0.1ufd across pins one and two instead of a 0.1ufd make a difference ?
  • ZootZoot Posts: 2,227
    edited 2007-01-25 02:54
    Is there a typo in your last post? 0.1ufd and 0.1ufd are the same.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-25 11:54
    Would having a 0.01ufd across pins one and two instead of a 0.1ufd make a difference ?

    And the wiper(the middle of the Potentiometer) connects to·the node from pin 6 and pin 2·and I just connect one of the
    two other ends of the pot to pin 7.



    Post Edited (ltmhall) : 1/25/2007 5:13:02 PM GMT
    946 x 642 - 43K
  • ZootZoot Posts: 2,227
    edited 2007-01-25 17:27
    Yes, it would. The relationship between the capacitor on the trigger and the "tuneable" voltage divider on the discharge pin is what makes the timer do it's thing.

    It sounds like your pot is wired up OK, but make sure you have the other half of the voltage divider at the node to pin 7 (the 470ohm resistor between pin 7 node and pin 8 node).

    I would wire up the circuit as shown. If you don't have the right value cap and resistors on hand, a quick trip to Radio Shack can solve that. Wire it up, double check your wiring, center your pot, and give it a go.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-26 02:25
    I built the 38 kHz emitter as shown. However my debug terminal ony goes up to 6000 Hz.
    Does anyone know why it does that ?
  • ZootZoot Posts: 2,227
    edited 2007-01-26 02:53
    Can you post your code and maybe a photo of your wiring (up close)?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-26 03:18
    I've built the 555 circuit and I just wanted to adjust the frequency.


    First I placed the 555 on a bread board. Then I took the 0.01ufd cap and place it between pin 1 and pin 2.
    Then I took a piece of wire and connected pin 1 to ground. Next I placed a 220 ohm resistor
    to pin 3 and connected the other side of the resistor to Basic Stamp pin 7. I also connected the IR
    LED to that same side of the resistor and ground. Then I took another 220 ohm and connected one side to pin 4
    and the other side of pin 6 of Basic Stamp. Next I placed a wire between pin 2 and a empty
    row on the bread board and connected the wiper of the pot tt that same row. Then I took a piece of wire
    and connected pin 6 to the same row. Then I connected another piece of wire between pin 7 and the other
    end of the pot. Next I took the 470 ohm resistor between pin 7 and pin 8 and connected pin 8
    to power.





    ' IR Remote for the Boe-Bot - Test555Frequency.bs2
    ' Displays 555 timer frequency for potentiometer adjustment and tuning.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    cycles VAR Word
    DO
    HIGH 6
    COUNT 7, 100, cycles
    LOW 6
    cycles = cycles * 10
    DEBUG HOME, "Frequency = ", DEC5 cycles, " Hz"
    LOOP
  • ZootZoot Posts: 2,227
    edited 2007-01-26 04:04
    Sounds right and your code looks OK. Try removing the IR LED (no need to drive it at this point) and doing the count on PIN7 of your Stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-27 00:53
    I have built the circuit from www.parallax.com/dl/docs/prod/sic/WebIR-%20v1.1.pdf and it transmitts 38 kHz.
    Now if I want to use it for object detection I just connect my detector as shown in the robotics manual and
    have it constantly check for the emitter signal. Also I can turn the emitter IR 38 kHz signal off/on with the reset
    (pin 4) of the 555 chip by sending High and Low signals.
  • ZootZoot Posts: 2,227
    edited 2007-01-27 01:55
    Congrats on getting your circuit working.

    Yes, connect your detector as shown -- use a 220ohm resistor between the output pin of the detector and the pin of the Stamp.

    Set RESET pin of the 555 HIGH and then read the detector. Set RESET pin of the 555 LOW to turn off the LEDs.

    Remember on the IR detector that a 0 (low/false) means there IS IR detected, a 1 (high/true) means that NO IR was detected.

    You may want to experiment with the value of the resistor(s) that go to your IR LEDs to get the opitmal "brightness" of the IR -- the lower the resistor, the more electricity flows to the LED, and so it's brighter. The brighter the LED the farther an object can be when it reflects the IR to your detector. Don't make the resistor too low or you risk burning out the LED. If you have any kind of video camera with "nightshot" infrared mode, you can point your camera at the LED and see the IR light, which can be kind of fun.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-28 21:55
    I connected my detector as shown but I notice a couple of problems.

    1) It seems that it is really slow to detect an object using the code I have provided. Is there any way to fix this
    2) It seems it constantly false triggers.

    IR555 PIN 6
    IRdet PIN 7

    DO
    HIGH IR555
    IF IRdet = 0 THEN
    HIGH 8
    ENDIF
    LOW 8
    LOW IR555
    PAUSE 10
    LOOP
  • ZootZoot Posts: 2,227
    edited 2007-01-28 23:00
    Slow how? It should be very fast. Your code certainly should not be slow, but if pin 8 is hooked up to a visible indicator LED, you might want to change one thing in your code so the indicator LED is on or off properly when the detector changes state:

    Now, for false triggers there are number of things you can do. First you might want pause a tiny bit after turning on the 555 so it can settle. See code below

    You can also stabilize your circuit (the detector) and/or the software so it only reads IR correctly. First make sure you don't have interference from fluorescents, other IR sources, etc.

    Then you can try any or all of the following:
    - put a .1 - 10uf capacitor across the +5v and GND pins of the detector (right at the detector)
    - put a pull-up resistor (5k-20k -- experiment) from the output pin of the detector to +5V. This "pulls" the output of the detector towards +5v ("1" or no IR) unless it gets a strong "0" from the detector itself
    - sample the detector a number of times in software. Count the number of times you get a "hit" and then decide how many hits = a true obstacle (i.e. if you hit 3 out 5 it's real, anything less than 3 out of 5 might be false)

    IR555 PIN 6
    IRdet PIN 7
    indicator PIN 8
    
    DO
    HIGH IR555
    PAUSE 1 'time to settle
    IF IRdet = 0 THEN
    HIGH indicator
    ELSE 'indicator pin is either HIGH or LOW depending on last read state of the detector
    LOW indicator
    ENDIF
    LOW IR555
    PAUSE 10
    LOOP
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ltmhallltmhall Posts: 102
    edited 2007-01-29 01:43
    I initially thought that it would work faster, but I was suprised to see that it didn't. The way I tested it was writting the code so
    when an object is placed in front the led would come on, then turn off when there wasn't anything in front of it. However
    when I tried it I placed an object in front I could see that the led wasn't illuminating really bright and I could see it flashing on/off. I'm not really worried about the fasle triggering because I know that can be corrected. I just want it to react quicker.

    I tried running the code that was supplied above and my circuit shows no reaction. When I place and object in front
    of the circuit using the code above the led doesn't flash on.

    So far I built the emitter circuit using the 555 timer and I checked its frequency and it read 38 kHz. Then I connected
    the 220 ohm resistor on the reset pin of the 555 timer to pin 6 of the Basic Stamp. Next I took the detector and placed one pin to ground, another pin to power and placed a 220 ohm on the last pin and connected the other side of the resistor to pin 7 of the Basic Stamp. Then I took an led and placed on pin to ground the other end to a 470 ohm resistor, and then connected the other end of the resistor to pin 8 of the Basic Stamp.

    When I tried the code I supplied it worked but it seemed liked the led wasn't quick to respond, so I can tell wasn't to an object in front of the detector
  • ZootZoot Posts: 2,227
    edited 2007-01-29 02:42
    It should be very quick, and it sounds like your circuit is basically working OK. In addition to the tricks I mentioned to try and stabilize your reading, you might also want to experiment with the value of the resistor to the IR LED -- it may be too bright, or not bright enough.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
Sign In or Register to comment.