go_away

### Author Topic: Need help w/ prog. for IR transistor circuit  (Read 4356 times)

0 Members and 1 Guest are viewing this topic.

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Need help w/ prog. for IR transistor circuit
« on: June 26, 2008, 02:31:26 PM »
Hello, I'm currently trying to make a object detecting circuit using IR emitter and IR transistor.  I need help on what the program needs to be like in order to emit a frequency and then have the receiver take a reading.  I'm programming in basic BasicMicro IDE. 02.2.1.1  Any help would be greatly appreciated.

See attachment of schematics

Bane
« Last Edit: June 26, 2008, 02:36:06 PM by BANE »

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #1 on: June 26, 2008, 02:36:06 PM »
If you're using a phototransistor, your detector circuit is missing a current-limiting resistor...

#### hazzer123

• Supreme Robot
• Posts: 460
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #2 on: June 26, 2008, 02:37:50 PM »
So i guess what you mean by emit a frequency is use a modulated signal. As far as i know this is just taking a measurement of the IR levels, then turning the IR LED on and taking another measurement of the IR levels.

The bigger the difference between the readings, the closer/shinier/bigger the detected object.

I would create a function, called getIRMeasurement(), and it would return a value which is related to how close/shiny/big the object is.
Imperial College Robotics Society
www.icrobotics.co.uk

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #3 on: June 26, 2008, 02:40:03 PM »
Quote
If you're using a phototransistor, your detector circuit is missing a current-limiting resistor...
They use this circult on SumoBots from Parallex, and they don't use a limiting resistor....  May be they don't use them.

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #4 on: June 26, 2008, 02:44:05 PM »
Quote
I would create a function, called getIRMeasurement(), and it would return a value which is related to how close/shiny/big the object is.
Yes thats what i'll do once i can emit the frequency and receive at the same time .

Here an idea, (maybe this how you'd have it set up) have the IR leds always emitting a frequency instead of controlling when its emited.

bane

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #5 on: June 26, 2008, 03:05:22 PM »
They use this circult on SumoBots from Parallex, and they don't use a limiting resistor....  May be they don't use them.
So maybe they're using a photoresistor instead of a phototransistor, or maybe they're using a more complicated integrated detector like this, which is a phototransistor with an integrated 30k resistor and other electronics.  If you are just using a phototransistor you need a current-limiting resistor or else you are creating a short between power and ground.  Where did your schematics come from and are you using the same detector as is in the schematic?

- Ben
« Last Edit: June 26, 2008, 03:06:13 PM by bens »

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #6 on: June 26, 2008, 03:35:04 PM »

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #7 on: June 26, 2008, 03:54:28 PM »
Taking a quick look at the datasheet shows that your detector is a phototransistor with an internal 20k pull-up, so you'll never have a short between power and ground.

- Ben

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #8 on: June 26, 2008, 04:07:09 PM »
Thats nice   here is the program that they use.
Code: [Select]
`' Program Listing 1.1 - Testing the IR Beam.bs2IR_detect  var  bitlow 7loop:  pause 50  freqout 7, 1, 38500  IR_detect = in8  if IR_detect = 0 then unbroken    ' Make sure to add six spaces to the debug statement    ' below.  That way both debug statements will have the    ' same number of spaces for a better display.    debug home, "Beam is broken; object detected.      "    goto loop  unbroken:    debug home, "Beam is unbroken; object not detected."    goto loop`
the part that gets me in this program is that they only define one pin they use.  I need one pin for the output frequency and one for the receiver signal.

bane

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #9 on: June 26, 2008, 04:22:37 PM »
It looks like they're ouputting a frequency on pin 7 to drive the LED and taking the detector input on pin 8...

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #10 on: June 26, 2008, 04:34:05 PM »
you mean the "in8" part?

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #11 on: June 26, 2008, 05:24:33 PM »
You know what, i think i'm going throw away the phototransistors that i have and just buy two pairs of simple emitters and detectors.
Has anyone tried these out?

then i could use the schematics fromhttp://www.societyofrobots.com/schematics_infraredemitdet.shtml

Bane
« Last Edit: June 26, 2008, 05:27:43 PM by BANE »

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #12 on: June 27, 2008, 12:11:27 AM »
You could also consider using a prebuilt IR emitter-detector solution:

http://www.pololu.com/catalog/product/958
http://www.pololu.com/catalog/product/959

It's got all of the extra components you need in a compact package, optimized for performance.  All you need to do is connect power (5 V capable of delivering 25 mA), which can typically be supplied by a digital output if you want to control when the sensor is on, or you can just directly connect it to your power bus.  The OUT pin is the sensor output, which will be an analog measure of IR reflectance.  The QTR-1A outputs an analog voltage as a function of reflectance, so you would need an ADC to read it.  The QTR-1RC outputs a pulse whose length is a function of reflectance (usually between 0.1 and 1 ms), so you can use a standard digital I/O line to read it.

- Ben

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #13 on: June 27, 2008, 06:30:21 AM »
Quote
Maximum recommended sensing distance: 0.375" (9.5 mm)

I kind of need something that has the maxmium distance of 10 in. through, but thanks becuse I might use something that cheap and small for sensing when the biped has had contract with the ground.

Bane

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #14 on: June 27, 2008, 12:17:15 PM »
I don't think the sensors you linked from Radio Shack are going to detect reflections from 10" away any better than the QTR sensors.  We have been able to use the  QTR-1RC version to detect something up to around 8" away, but this was only when there was very little ambient IR hitting the receiver.  The maximum recommended sensing distance listed on the sensor's web page is for getting a good analog measure of white and black surfaces (e.g. the maximum height you would want to mount it for a line following application).  If you just want to know if a wall is in front of you, you can use it for much greater distances so long as:

1) the wall is sufficiently reflective.  If it is a black wall, you won't see it well at all.
2) there is very low ambient IR.  Ambient IR will cause your weakly reflected IR to be lost in the noise (just like it's much harder to see a candle flame several blocks away on a sunny day than it is to see that same candle on a dark, moonless night).  For example, you wouldn't be able to see something 8" away with a QTR sensor in a room with a lot of sunlight streaming in through the window.

If you really want to see farther, you'll need a brighter IR source so that your detector has a better signal to see.  You could achieve this by running more current through the LED, but this will cause the LED to burn out faster, or you could perhaps find a matched LED that can handle more current.  Or you could consider getting a Sharp IR sensor (note that this stops working for objects that are within a minumum distance of the sensor) or a sonar sensor (this has pretty much no dead zone, but it can also see a lot farther than 10" so it might be overkill for your application).

- Ben

#### BANE

• Supreme Robot
• Posts: 639
• E=roboticsC^2
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #15 on: June 27, 2008, 12:45:25 PM »
I already have a Sharp IR sensor in the center of the biped.  What i need is two more small sensors on the sides for spot checks.
I do have a pair of QTI that i had got form parallax http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/qti/List/1/ProductID/100/Default.aspx?SortField=ProductName%2cProductName

but the sensing range kind of sux

Bane

#### bens

• Expert Roboticist
• Supreme Robot
• Posts: 335
##### Re: Need help w/ prog. for IR transistor circuit
« Reply #16 on: June 27, 2008, 12:59:44 PM »
The QTR-1RC sensors are the same interface as the Parallax QTIs.  The only noticeable differences are that the QTR sensors are much smaller than the QTis, they have the three pins arranged in a different order, and they draw more current in order to make the IR LED brighter, so the QTRs would conceivably be able to see a little farther than the QTIs.  Additionally, the QTRs are also almost half the price of the QTIs.

- Ben