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.

IR Light sensor circuit with multiple phototransistors

Status
Not open for further replies.
sorry I meant phototransistor, not photodiode. Ok, call me paranoid. but I did happen to run more tests and sometimes the tests work and sometimes they dont. I'm gonna try to shield the side of these phototransistors since there are LEDs and 7-segment displays on the same board that sometimes light up. The LEDs are right next to the phototransistors (even touching them). so now I need to find a decent LED insulator that isn't too fat and the only thing I can think of which is unprofessional is wrapping the phototransistor sides up with electrical tape.
 
Then you described a forward biased photodiode parallel with the forward biased base-emitter diode and it won't work.
Ahh of course you are right. I had it in my head correctly, I just didn't write it correctly .... the Cathode should go to the Base, and the Anode should go to ground. I will correct the post above.
 
Ok before I go to the idea of using transistors to amplify the signal instead of the opamp, I'm thinking maybe the resistors in the Mohm range are incorrect. Maybe I need something in the Kohm range since the +ve power to the opamp input runs through the resistor and the phototransistor is a switch that acts as a short under light and almost an open under no light. Maybe audioguru's math refers to the resistance of the phototransistor by itself given a voltage. Am I accurate? because I don't think an opamp would turn on with such little current/voltage (1na?) applied to + input and a larger voltage applied to - input, especially when the values I read at the outputs on the voltmeter are between 0 and 0.07V.
 
The datasheet for the phototransistor says its max saturation voltage is 0.4V at 2mA when it is in fairly bright light. Since your supply is 5V then the collector resistor would be (5V - 0.4V)/2mA= 2300 ohms.

The light can be 1/100th producing a collector current of 2mA/100= 20uA. Then the collector resistor would be (5V - 0.4V)/20uA= 230k ohms and the sensitivity would be 100 times what it is with the 2300 ohm collector resistor.

How about a very dim light or some dark current then the collector resistor could be 2.3M ohms but the dark current will not let the phototransistor to completely turn off.
 
ok now those smaller values make some more sense but I have the circuit hooked to an opamp input then the output of the opamp to input of 74HC251. A logic high for 74HC251 is 3.5+V. What would be the maximum resistance I could use before the input is no longer seen as logic high? do I factor in leakage current for the opamp and 74HC251? because so far, what I can gather, 1M resistance is extremely high for a pull-up, and 2K is rather low, and most places suggest 10K as a standard pull-up but I might choose 100K but I'm not sure if that's too weak.

Because I will be tying multiple phototransistors in parallel, how does the equation change? do I add the mA together?
 
The 74HC251 has NO INPUT CURRENT, just a very low leakage current. You need amplification (from an opamp?) if the light shining on only one phototransistor is low and there are 11 other phototransistor dark currents requiring a low collector resistor.

I do not know the brightness of your laser beam or its distance. I do not know if it shines on only one phototransistor or a few of them.
 
In the end, I'm estimating the lazer beam distance (from beam emitter to detector) is about 200 feet but for initial testing, I'll use 20 to 50 feet. The lazer beam I tested with is run with 6VDC batteries (measured at 5.7V on voltmeter) and the beam seems to have a built-in resistor since it didn't blow up when I connected it directly to the battery leads.

I must be referring to leakage current I think. What I'm trying to achieve is that:

if there is light from either the lazer beam or from an infrared emitter hitting at least any one of the several phototransistors, then there should be a logic low voltage level from the opamp being fed into the 74HC251. Otherwise, it should be logic high. I don't mind if the logic levels being fed into the 74HC251 are swapped because I can also take an inverted output from a different pin on the same chip.

It would be nice if the phototransistors don't react to the onboard diffused LEDs, but if I must, then I'll use electrical tape and/or LED holders.
 
The beam will eventually be controlled by software in a microcontroller so modulation isn't an issue. I can also control other lights on board via software as well. My main concern is getting it to detect the beam even if the accuracy isn't perfect.
 
To confuse myself less, I'm gonna say photosensor instead of phototransistor because everytime I type, I type photodiode. lol

Lowering the resistor from supply to photosensor did help quite a bit and the voltage measurement at input pins of the 74HC251 is < 1V or 3.5V which is OK. so 2 out of 4 boards of sensors now work.

But I have some photosensor which is connected to a long cable before hitting the sensor detection, and that detection doesn't work. I verified this by testing at the 74HC251 and the input voltage reads < 3V which doesn't mean logic high for the part.

The cables I'm using are the following for each set of sensors that don't work:

For the one set of 12 sensors, I'm using 1 wire in the grey flat ribbon cable 10-core I bought from here: https://futurlec.com/Cable.shtml to connect it to the main board (yes I need to make some boards separate from others). Its about 60cm in length.

For the other set of photosensors that don't work, I'm using the same kind of cable but coloured about 15cm in length as well as a 3-foot DB9 serial cable. (In other words, the wire length from photosensor to the input of the opamp is about 3 feet in length)

However, the two sets of sensors that do work have cable lengths that are shorter. One length is about 30cm and the other length is about 10cm.

Having said that, I made another schematic with resistor values I corrected. and I use high values for R3 and R4 in the megaohm range. About 1.8M.

circuit.png


So this leads me to a couple questions:

1. What is the resistance of one wire in a flat-ribbon cable given the length?
2. What is the resistance of one wire in a 3-foot DB9-DB9 serial cable extension cord?

3. How do I adjust the value of the resistor marked 68K on long wire connections such as the ones I described so that the photosensor can be detected?
 
1 & 2 ) will be negligible however in a 3ft length your actually talking about 6ft of wire, because it must go there and back.
3) Are the lighting conditions the same between the cable vs. non-cable ? that will make more of a difference than resistance of your wire. You need to use a circuit that has auto-gain or else you will be fighting ambient light conditions as well as source and detector distance differences.
 
When I run the tests, I either have maximum light on the sensor or zero light on the sensor. Nothing inbetween. I just want to get all sensors working even with long cable in-between. I mean if I have to, I'll order shorter serial cable online
 
I don't think it is the length that is your problem. The fact that you have no adjustability in your circuit will play a huge factor. The 68k at a minimium should be a potentiometer. light differences from one sensor to the next will be another contributing factor as well as component tolerance differences between the sensors, and in the current design, tolerance differences between the 68k resistors.
 
Why are you using opamps that have the same voltage gain as a piece of wire? Also the resistor values at the inverting and non-inverting inputs should be the same to balance their input currents and voltages.
The inputs of a 74HCxx IC have no input current so connect the photo-transistors directly to it without the opamps.
The capacitance of the long cable might be causing the photo-transistors to oscillate.
 
The capacitance of the long cable might be causing the photo-transistors to oscillate.

So this must mean I should use a lower pull-up resistor I guess. I read elsewhere about someone using long wires, and the current used for serial lines was 20mA. At 5V this sounds like a 250 ohm resistor. But to play safe, I think I could pull it off with 2K.

But then I come across another thing. Maybe my software is trying to read the data too fast. I came across this thought after disconnecting the parts with the phototransistor on it and using a short piece of wire to act as a phototransistor and the test results were pretty much the same.

The micro I hooked the address lines as well as the inverted output to is an AT89S52 with a 22.1184Mhz crystal. I did put in a 1 wait state wait time (about 530ns) between when the address (sensor set number) is selected and when the detection takes place. I guess I should increase wait times in my program by double? or triple? hmm
 
There is no "pullup resistor", instead it is the collector resistor for the photo-transistor that affects its sensitivity. With a high value for the collector resistor then a low light level will turn on the transistor. If you use 2k ohms then it will take a close by lightning strike to produce a small drop in its collector voltage.
Your long cable is also picking up mains hum and all kinds of other interference. Use shielded audio cables because the shield blocks interference.

The capacitance of a long cable slows rise time and fall time of digital signals especially when the collector resistor value is high. Then the photo-transistors and their collector resistors need a fast opamp as a buffer mounted at the photo-transistors to drive the cable capacitance quickly with lots of current but not a lousy old low power and slow LM324.
 
Ok, so I am on the right track with the need to modify timings in software. I had to do that when controlling other components as well. Now this means I'll have to order shielded cables from ebay. Other places are expensive. Are there any special model numbers I should observe for the cable? because I could type that in as a search on ebay and find one of the exact same type from china (or near there) at a substantially cheaper price.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top