2nd try - infrared emitter and detector

Since i broke my previous one's i bought some new ones.
I got the LD271 and the BPW40.

This should be the setup if i'm correct.

5v
|
|----------------
| |
R1 R2
| |
| |-------------pin2
| |
| |
emitter phototransistor

gnd

With my calculation i need a 24 ohm resistor for the emitter and no resistor for the phototransistor, but i know pretty sure that my math is quite wrong.
So what do i need?

Also after i got 1 working the next step will be to get 2 working since i want to detect speed of falling objects.
Is this schematic correct?

5v
|
|---------------------------------------------
| | |
R1 R2 R3
| | |
| |-------------pin2 |-------------pin3
| | |
| | |
emitter1 phototransistor1 |
| | |
| | |
| | |
emitter2 | phototransistor2
| | |
|---------------- |

gnd

And can i use R1/2 as in, if R1 = 10K for one led, can it for this setup then be 5K?
And do the value R2 and R3 stay the same as in the first schematic?

someone please? I can't afford to break more stuff.

OK, OK..
See attached.
When the IRED is on then the phototransistor output = 0 (digital LOW)
When the IRED is off then the phototransistor output = 1 (digital HIGH)

You will need to shield the two inside a box - even though it's an IR phototransistor ambient / visible light will (likely) affect it.

IRemdetpr.JPG

With my calculation i need a 24 ohm resistor for the emitter and no resistor for the phototransistor, but i know pretty sure that my math is quite wrong.

Well I can say your maths is way wrong but without seeing it it is hard to say where you are going wrong, but:-
For the LED assuming a 1.5V drop across the LED then you will get
5 - 1.5 = 3.5V
3.5 / 24 = 145 mA
Do you want that much current?

no resistor for the phototransistor

So when the photo transistor conducts you will have
5V / 0 ohms = infinite current

Thanks runaway_pancake, i only wonder how you come to the resistor values cause one shows 1k - 10k and that's quite a range to choose from.

For the LED assuming a 1.5V drop across the LED then you will get
5 - 1.5 = 3.5V
3.5 / 24 = 145 mA
Do you want that much current?

No i don't want that much current cause according to the datasheet the maximum rating for forward current is 130 mA.
If i want 40mA for example (would that be a good value?) then how do i calculate that? Every attempt i make with the formulas don't make sense.

Also, why do they show maximum ratings, why not minimal ratings also? Cause at some point a led doesn't give light anymore.

Is forward voltage from a datasheet important? Cause i have no way of how to take them into calculations?

please teach me how to fish..

The datasheet tells us here that the voltage drop is 1.3V when the LED is pulsed for 20ms with 100mA flowing through it. I assume this is because it is an IR LED and these are normally pulsed in remote controls etc. If you want to run the LED continuously then a lower current would probably be advisable. Anyway, if you are operating the LED under these conditions you will need to a resistor to ensure the current isn't too high.

Ohm's Law: R = V / I

So R = (5 - 1.3) / 0.1 = 470ohms

Here I have taken the voltage left after the drop across the LED (5 - 1.3) and divided it by the required current (100mA). This gives us 470ohms. The last page of the datasheet shows the voltage drop for other current flows so you could use this to adjust the resistor to reduce the current flow if necessary (hint: increase the resistor).

I'd really like to hear some more about the phototransistor. I assume the calculation is based on the collector current which seems to be ~10nA in the dark and ~5mA in the light? So we need to choose a resistor that limits the current flow to 5mA, which would be 1kOhm. Is this reasoning correct? Or do we assume the current is fixed at 5mA and try to ensure the voltage drop across the phototransistor is correct to toggle the reading at the collector?

Yes, right.
The IR irradiance has the effect of base current.
So, assuming the phototransistor irradiated into saturation and little or no VCE then
IC = Vsupply / R.

** Breadboard those up. Guaranteed safe-area operation, but you have to get the wires right. A great opportunity for "experientation". **

Also, why do they show maximum ratings, why not minimal ratings also? Cause at some point a led doesn't give light anymore.

Because this is not true. At some point the light is so small you can't see it but it is producing light at all currents.

cause one shows 1k - 10k and that's quite a range to choose from.

No it is not.
Especially for something non critical like this. A range of current of 10 to 1 is normal for some things in electronics.

So R = (5 - 1.3) / 0.1 = 470ohms

No!
5 - 1.3 = 3.7V across the resistor. For 100mA this gives a resistor value of:-
3.7 / 0.1 = 37 Ohms

No!
5 - 1.3 = 3.7V across the resistor. For 100mA this gives a resistor value of:-
3.7 / 0.1 = 37 Ohms

Haha, thanks. Not sure how I managed to make a mistake on both of the simple maths operations.

Anyway, I managed to get my phototransistor hooked up and working with a common-emitter circuit as drawn earlier in the thread. My trouble was that I had the phototransistor wired backwards, incorrectly assuming that the longer lead should go to +ve like an LED. However, I'm still a bit unsure about why it is working.

So, assuming the phototransistor irradiated into saturation and little or no VCE then
IC = Vsupply / R.

So I'm confused here about the assumption that there is little or no VCE. Surely if there is no voltage drop across the phototransistor then there is no voltage change to detect when light is applied?

No that quote said assuming little or no Vce when the detector was saturated, that is turned on by exposure to light.
It then gave the current through the device.
When there is no light there will be no current and Vce will be the supply voltage.

Note this is super simplified to a first approximation only but it will do to work with.

Thanks, that is clear now.

Ok, so 100mA is too much current for those things.
So let's say i want 25mA (is that good?),
Then
R = V/I
R = (5 - 1.3)/0.025 = 148ohms for the resistor

That calculation looks good.

Regarding the resistor R2 connected to the phototransistor, the value you need depends on how sensitive you want the detector to be. See this thread http://arduino.cc/forum/index.php/topic,86435.0.html for someone else's experience of this. He was initially using the internal pullup resistor in the Arduino (which has a value of around 20K) to substitute for R2.

cool, i tested with my camera and it gives a little light!
I will look at the link you give me after i posted this.

About the detector, the wpb40 that one is next.
http://www.datasheetcatalog.org/datasheets/400/499826_DS.pdf

is the max 200mA or do i see that wrong?
And about the emitter and the collector, by the image there is a small square with a capital A in it, i first thought it was a indication for Anode, is that wrong?
Also i don't see a voltage drop, is that because it depends on the amount of light it is receiving?

Atm i'm thinking when powered up on 5V that the max forward voltage is 5V depending on the light.
Let's say i want 25mA.

R = V/I
5/0.025 = 200ohm resistor

would that be good? (please check datasheet as well)

You're going about the choice of resistor for the phototransistor the wrong way. The phototransistor will draw an amount of current depending on how much light it senses. The purpose of R2 is to translate that current into a voltage drop that can be sensed by the Arduino. So the value of the resistor you choose depends on how sensitive you want the phototransistor to be. Higher resistance gives more sensitivity. You're unlikely to get the phototransistor to draw more than a few mA even if you place to right next to the emitter. The OP in that other thread I linked to ended up using 400K, because he needed enough sensitivity to detect the emitter when it was 10 inches away from the phototransistor.

Intresting topic, i'm reading it atm, some very good tips.

let's say i want 3 inches? How do i calculate from there?

You need to take measurements. Measure the current drawn by the phototransistor when it is 3 inches away from the emitter (also check that the current drawn is much lower when the emitter is turned off). Use Ohm's law to calculate the resistor you need for 4 volts drop across the resistor at that currentr.

Or try a few resistors in the range 1K - 1M and see what gives you the sensitivity you want.

You need to take measurements. Measure the current drawn by the phototransistor when it is 3 inches away from the emitter (also check that the current drawn is much lower when the emitter is turned off). Use Ohm's law to calculate the resistor you need for 4 volts drop across the resistor at that currentr.

For that i have to start with a high resistor right and measure then, if i need more sensitivity then try a lower resistor, right?

Or try a few resistors in the range 1K - 1M and see what gives you the sensitivity you want.

Is 1M really 1.000.000 ohms? It sound so much compared to something where 1000ohms might could work as well.

And how would you suggest connecting the speaker?

No the bigger the resistor the more sensitive it is. That is because it takes a smaller current to make a bigger voltage. It's Ohms law!

No the bigger the resistor the more sensitive it is.

O yes afcorse

I = V / R

5 / 1000 = 0.005 current
5 / 1000000 = 0.000005 current

So if i am correct, if you use no resistor you will notice no difference if the detector receives light or not.

R = V/I

5/0.025 = 200ohm
5/0.05 = 100ohm
5/0.001= 5k

So in the other topic a pullup resistor is mentioned.
I will be using 2 ir detectors and emitters to detect the speed of a falling object, so most of the time it just detects light.
Will i need a pullup resistor for that?


I do understand that it's HIGH when the irled is off and LOW when the irled is on.
What i don't understand, the resistor is in between the 5V and the arduino pin so how can the arduino ever notice a change?