Distance Detection with IR Led and IR Phototransistor
================================
2012.01.16 -
-----------------
So, it's back to distance detection with IR Leds and IR phototransistors.
I used the IR pair from Radio Shack. A few comments on these, so I don't
forget yet again, I'm sick of re-learning this. The dark one is the emitter.
The clear one is the detector. The emitter has the following key properties:
Forward Current: 150 mA
Forward Voltage: 1.3 V typical. max is 1.7 V
Reverse Voltage: 5 V
Wavelength: 950 nm
Resistance is calculated as always for a diode:
Vs = voltage source
Vf = forward voltage
I = forward current
So,
Vs - Vf
_______ = resistance for max current.
I
For the Radio Shack emitter at 5V source:
5 - 1.3 / .150 = 24.66666
I use a 33 Ohm resistor to get ~112mA.
The big reminder:
1. The long lead does not always mean hook to Positive!!!!
On the emitter, the long lead corresponds to the flat part of the casing.
This corresponds to the Anode ( positive ) lead of the Led.
On the phototransistor, the long lead hooks to the flat part of the part.
The flat part, short lead is the Collector and goes to positive!!!
The round part, long lead goes to the emitter ( ground ).
o Control the IR Led from the microcontroller by triggering an NPN transistor.
I got good results with a 2N3904. I used a 1k resistor to the base.
o The emitter uses a 33 Ohm resistor as calculated above. If you can find
something closer to 25 Ohms, use that.
o The detector gets unresisted 5V to the collector. The emitter goes to ground
via a 100k resistor. The detection line to the microcontroller is hooked
to the emitter.
Results:
----------
Using a hand or white piece of paper, good results went almost 30cm.
Non-precise measurements:
value | value
cm | hand | white paper
--------------------------------
1 | 553 | 1023
2 | 391 | 820
3 | 279 | 620
4 | 199 | 438
5 | 162 | 351
6 | 126 | 272
7 | 113 | 231
8 | 98 | 194
9 | 89 | 166
10 | 79 | 144
11 | 75 | 132
12 | 70 | 118
13 | 67 | 109
14 | 63 | 99
15 | 61 | 88
16 | 57 | 83
18 | 52 | 74
20 | 50 | 66
22 | 48 | 61
24 | 46 | 56
26 | 45 | 54
28 | 44 | 51
30 | 44 | 49
I hooked up a test rig to get these results. Here is the code:
sense source code
As usual, this is assembly source code for a PIC microcontroller from Microchip. In this case, I'm using my little work horse, the 16F88, running at 8 MHz.
Here are some photos of the rig on breadboard:
The Full Rig With Ruler
Closer View of the Board
Very Close View of Connections
I'll whip up a schematic soon.
EDIT:
And here it is in somewhat rough shape:
No comments:
Post a Comment