Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple IR switch advice needed

Status
Not open for further replies.

Pax Writer

New Member
Hello experts

I'm trying to build a circuit where I can count the number of times an object pass through a simple photocell. I have attached a picture of the schematic to the post for a quick overview. As the text states, the connection running off to the left goes directly to an active low (or negative edge-trigged) interrupt on a 2051 processor.
This doesn't seem to trigger the interrupt when the light ray is broken. Maybe you have some advice on how to improve the circuit?
I realise that I'm probably hopelessly naive to expect something so simple to work :)
All comments and help is greatly appreciated.
Thanks.
 

Attachments

  • IR switch proto.GIF
    IR switch proto.GIF
    6.1 KB · Views: 191
Have you measured the voltage at the input to the 2051? It should change from about 0 Volt to at least 70% of the 2051 supply voltage if you want the 2051 to see the change.

I would use a photo transistor rather than a photo diode.
 
A photo-diode has an extremely small current when it sees light. Not nearly enough current to cause a mA in the 4.7k resistor to make a logic high.
 
Hello ljcox and Audioguru

First of all, this circuit is meant to be "naturally high" (no pun), in that L1 (which should have been called D2) shines on D1, causing it to saturate, or what the correct term is. This should keep the junction between D1 and R2 high until an object passes between D1 and D2, breaking the ray of light, and causing D1 to go "off", which would then pull the junction down to ground. Provided no other errors in the schematic, wouldn't that work?

To Audioguru: R2 is in fact a 47k resistor, not 4k7, which happens not really to matter since I guess its still too low value. I'm thinking of replacing it with a 470k or even 1M resistor. Do you think this would work, or do I have to add a buffer, comparator or similar between the CPU input and the junction?

To ljcox: I haven't yet tested this particular setup, because I'm waiting for a bunch of BP104s to arrive by mail, but I have tried it with a BPW34 which, although also sensitive to normal light, worked quite nicely.

In any case, D1 and D2 will be mounted in a dark place, so there should be little or no ambient light to mess with D1. Also, they are spaced no further than 10 cm away from each other, so I guess distance won't be the problem. Am I wrong?
I've been searching the database for similar posts, and there seems to be quite a few, and I learned much from them, but none of them really seems to answer this question: Can the photodiode act as a logic switch (in this case with a 2051 input)?
Thanks so far for your help.
 
A photodiode has an extremely low output current and is usually amplified.
I would use a photo-transistor in your circuit because it is at least 100 times more sensitive.
 
Pax Writer said:
Hello ljcox and Audioguru

First of all, this circuit is meant to be "naturally high" (no pun), in that L1 (which should have been called D2) shines on D1, causing it to saturate, or what the correct term is. This should keep the junction between D1 and R2 high until an object passes between D1 and D2, breaking the ray of light, and causing D1 to go "off", which would then pull the junction down to ground. Provided no other errors in the schematic, wouldn't that work?
The term you are looking for is "active high". As Audio said, the diode current is very low. See my comments below.
Pax Writer said:
To Audioguru: R2 is in fact a 47k resistor, not 4k7, which happens not really to matter since I guess its still too low value. I'm thinking of replacing it with a 470k or even 1M resistor. Do you think this would work, or do I have to add a buffer, comparator or similar between the CPU input and the junction?

To ljcox: I haven't yet tested this particular setup, because I'm waiting for a bunch of BP104s to arrive by mail, but I have tried it with a BPW34 which, although also sensitive to normal light, worked quite nicely.

In any case, D1 and D2 will be mounted in a dark place, so there should be little or no ambient light to mess with D1. Also, they are spaced no further than 10 cm away from each other, so I guess distance won't be the problem. Am I wrong?
I've been searching the database for similar posts, and there seems to be quite a few, and I learned much from them, but none of them really seems to answer this question: Can the photodiode act as a logic switch (in this case with a 2051 input)?
Thanks so far for your help.
If you want to use the photo diode, you need to know 2 parameters

1. what current does the diode source when illuminated

2. what is the input resistance of the 2051.

Sop you need to look at the data sheets of both the diode and the 2051.

I don't knowe anything about the 2051, but if it is a CMOS device, then it should have a very high input resistance.

I don't have a data sheet for a photo diode, so I can only guess at the current.

You could measure the current if you have a meter that can measure small currents. Connect in series with the diode and resistor and disconnect the 2051.

If it is say 2 uA, then the resistor you need to give a 5 Volt input to the 2051 would be R = 5/2 = 2.5 M Ohm, ie. use a 2M7. This assumes that the 2051 has a very high input resistance, ie. > 50 M Ohm.

However, this calculation does not account for the voltage drop across the diode. So I suggest you find a data sheet for the diode you are using and post it so we can advise you further.
 
Audioguru:
Once again you are correct.
I must admit that at first I simply wouldn't let go of the photo diode in this circuit, and I've spent a fair deal of the evening trying to make this work. Finally, I grabbed an old photo transistor, which a very friendly guy from another forum sent me, taped to a post card. i simply soldered the collector to the interrupt (internally pulled up) and the emitter to GND. Then I placed the circuit under a lamp and passed my hand over the photo transistor. Instant results! So I had to learn the hard way, but at least I learned. Thanks for your help :)
My only concern is the relatively long rise and fall times of the transistor. I'm looking at the SFH309-4, which is the only available type at my local supplier, but according to the data sheet, it has rise/fall times of 5-8uS...
Well, I guess it'll have to do.
 
ljcox: It seems our posts crossed each other. In fact I made a rough calculation much like the one you suggested earlier this evening, and without consulting the data sheets, I concluded form memory that the photo diode wasn't strong enough to change the pin without the help of extra amplifying circuits, so in accordance with my above post, I tried a photo transistor, and it worked a breeze :) So I guess, I'll solve the problem by simply switching from the diode to the transistor..
Thanks for your help, though :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top