PDA

View Full Version : emitter/detector



ltmhall
01-24-2007, 10:23 PM
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.

LSB
01-24-2007, 11:41 PM
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.

ltmhall
01-25-2007, 12:41 AM
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

allanlane5
01-25-2007, 01:33 AM
The reciever circuit would look exactly the same.

ltmhall
01-25-2007, 01:45 AM
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 Green
01-25-2007, 03:17 AM
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.

Zoot
01-25-2007, 05:02 AM
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 (http://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

ltmhall
01-25-2007, 05:09 AM
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 Green
01-25-2007, 05:15 AM
Yes.

The BOE-BOT Robotics manual is a great reference.

Zoot
01-25-2007, 05:22 AM
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 Green
01-25-2007, 05:53 AM
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.

Zoot
01-25-2007, 05:53 AM
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

ltmhall
01-25-2007, 05:55 AM
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

Zoot
01-25-2007, 06:46 AM
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

LSB
01-25-2007, 07:30 AM
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.

ltmhall
01-25-2007, 08:49 AM
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

Zoot
01-25-2007, 09:31 AM
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

ltmhall
01-25-2007, 09:36 AM
Would having a 0.1ufd across pins one and two instead of a 0.1ufd make a difference ?

Zoot
01-25-2007, 09:54 AM
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

ltmhall
01-25-2007, 06:54 PM
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

Zoot
01-26-2007, 12:27 AM
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

ltmhall
01-26-2007, 09:25 AM
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 ?

Zoot
01-26-2007, 09:53 AM
Can you post your code and maybe a photo of your wiring (up close)?

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

ltmhall
01-26-2007, 10:18 AM
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

Zoot
01-26-2007, 11:04 AM
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

ltmhall
01-27-2007, 07:53 AM
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.

Zoot
01-27-2007, 08:55 AM
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

ltmhall
01-29-2007, 04:55 AM
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

Zoot
01-29-2007, 06:00 AM
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

ltmhall
01-29-2007, 08:43 AM
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

Zoot
01-29-2007, 09:42 AM
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

ltmhall
01-29-2007, 10:23 AM
I think the problem maybe that the range isn't far enough. It seems the smaller the resistor that connected to the IR LED
the shorter the range. However I already have a 22o ohm in place. I also noticed that by increasing the pause value
after the LOW IR555 increases the intensity of the LED on pin 8.


Do you have any suggestions on how I can increase its range ?

Zoot
01-29-2007, 01:19 PM
Somebody said...
It seems the smaller the resistor that connected to the IR LED
the shorter the range.


Something doesn't sound quite right. It should be the other way around -- smaller resistor = more current flowing to LED = brighter LED. Lower than 330/220 you risk burning out the LED anyway.

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

ltmhall
01-29-2007, 09:54 PM
I’m not sure what the problem is. It’s a simple circuit. ·I built the circuit and tested the Test555Frequency.bs2 program and I adjusted the 10k ohm pot until the debug terminal read 38 kHz. I even took a dmm and measured across the anode of the IR led and ground and got a frequency of 38 kHz. I will continue to keep trying to troubleshoot the circuit, but I think it works correctly. I mean if I get 38 kHz out I don’t understand what the problem could be. Is there any way to check if the signal is being transmitted through the
IR led?
·
·
I have provided a schematic of my wiring and the code I am using.
·
Any suggestions would be appreciated?
·
·
IR555 PIN 6
IRdet PIN 7

DO
HIGH IR555
IF IRdet = 0 THEN
HIGH 8
ENDIF
LOW 8
LOW IR555
PAUSE 10
LOOP

allanlane5
01-29-2007, 10:21 PM
It could be working -- it looks like you give a "HIGH 8" for about 300 uSecs, which is WAY faster than you can see the blink. Put a 100 mSec pause after the "HIGH 8" so you can see it.

ltmhall
01-29-2007, 10:26 PM
I tried Pause 1 after "HIGH 8" and I didn't see the led come on !

Zoot
01-30-2007, 12:11 AM
PAUSE 1 would be 1 ms, not 100. Also, if you have video camera with "night shot" -- i.e. an infrared mode -- aim it at the IR LED and see if you can see it. You can also try putting a regular LED in place of your IR LED to see it. It sounds like your signal is OK as measured though.

Can you take a photo of your setup and post it?

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

ltmhall
01-30-2007, 06:04 AM
I tried the PAUSE 100 and I think it works. I place my hand in front and the led comes on for a few seconds and goes off.

Is there a way to increase the circuits range ? I tried switching the value of the resistor connected between
the IR led and pin 3 of the 555 and I see no difference.

Zoot
01-30-2007, 06:23 AM
You might want to check out Robotics with the Boe-bot (or have you already?). There a number of things to change the way the IR beams out, is reflected, then detected:

- different frequencies will give slightly different ranges -- since you can tune the frequency output of your 555, you can test this out. In Robotics with the Boe-bot there is an experiment with using frequencies from 37000 - 41500 or so for differerent ranges

- the resistor between the LED and the 555 output -- try 2k -- you should have a very very short range. 330 -- a long range.

- the placement and light shield for the IR LED and the detector can influence how the IR is detected

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

Tom Walker
01-30-2007, 09:26 PM
I just spun through this thread, so if your answer to my question is here, I apologize for not seeing it. What kind of range are you expecting to get? Driving the I/R led with 5 volts, you are probably only going to get a few inches at most. Your ambient conditions, the alignment of the emitter to the detector, the frequency of your emitter, and other factors will also determine the effective range of your setup.

What range are you looking for?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...

ltmhall
01-30-2007, 10:06 PM
I'm looking for about a inch/ 1/2 inch. The range of my circuit is only a few centimeters