Help with photo diodes.  - Page 1
Forum section: electronics / beginners

author: cvriv
author_rank: Frequent Contributor
timestamp: March 21, 2020, 05:27:29 am
content: I'm creating an interactive surface, a 4x4 matrix, consisting of IR sensors and blue LEDs. This surface detects objects hovering above and adjusts the brightness of the blue LEDs based on how close the object is to the surface.I have it working, but I noticed that some of the sensors are way more sensitive than some others. I thought it was my microcontroller at first and then my coding, but I dont think so anymore. I think it's the photo diodes.I had setup a simple jig that holds a photo diode a certain distance away from an operational IR diode and measured the resistances of the photo diodes and found that they are all very much different. I understand tolerances, but this is clearly affecting my circuit. I cant go through my whole stash of photo diodes to find the closest matched. I want to build several of these and thats just not an option.I want to ask if there is a way to "normalize" all the photo diodes so that all of my inputs are seeing about the same voltage for an object hovering above the sensors at the same distance?

author: mikerj
author_rank: Super Contributor
timestamp: March 21, 2020, 11:14:02 am
content: Quote from: cvriv on March 21, 2020, 05:27:29 amResistance is not a useful parameter here since you are dealing with a diode, not a light-dependant resistor. The relevant parameter would be responsivity, which indicates how much incident light is converted to a current (which is most always wavelength dependant). Show us how you have the photodiodes wired up, a schematic would be useful.The photodiodes likely won't be very sensitive at the blue end of the spectrum but they will have some level of responsivity. Are you ensuring they don't pick up light from the LEDs?

author: GerryR
author_rank: Frequent Contributor
timestamp: March 21, 2020, 11:24:05 am
content: I expect that you would have to send each detector output through an amplifier and calibrate each output to give the same result for a given intensity exposure. Sounds tedious but, off hand, unless you ordered matched diodes from the manufacturer, I think you will have to "condition" each unit to get matched outputs. JMO.

author: SeanB
author_rank: Super Contributor
timestamp: March 21, 2020, 12:15:46 pm
content: You are using a microcontroller, so simply add some extra code in which takes the input value and scales it. That then only needs you to calibrate each sensor with a known light intensity, and calibration would be either to read out the value per sensor, enter into a table, and then calculate a value to multiply with to get a standardised value, or simply have a cal routine where the measured value is read, and scaled to a particular value internally, with the required scaling per sensor being stored for use in normal operation.

author: StillTrying
author_rank: Super Contributor
timestamp: March 21, 2020, 02:02:25 pm
content: Very small differences between the beam alignments of the IR emitter and photodiode will be 10X higher than any differences in sensitivities, very wide IR beam emitters might help.Are they really photodiodes, from the reflected IR light they'll output only a few mV or a few uA, measuring their resistance doesn't mean much.

author: cvriv
author_rank: Frequent Contributor
timestamp: March 21, 2020, 02:49:04 pm
content: Very good information. Thanks everyone.@mikerj - Interesting. So when I use them to pull an input pin up to VDD, it's not the resistance of the diode that's changing to allow the flow of current? It's converting light to a current, which is a very small amount, so if I use it as a pull-up, that small current is amplified via VDD? Ill have to research how these work. So the way I coded this to work is that the blue diodes are off when the sensors are polled.@GerryR - So the responsiveness is pretty weak with sensing an object, because your hand has to get pretty close to the sensors. I think it's because because Im polling the sensors too fast. I have the emitters being turned on with a constant current LED driver, via EUSART, that's sinking 100ma from them. I have to allocate more time for them before performing the ADC to see if that helps. The receivers are multiplexed. Each row of receivers is brought to 5V via port pins, one each row. The columns are connected to 4 input pins, one column each pin. The code associates the emitters, receivers, and blue LEDs into clusters. All blue LED are turned off, a TX diode is turned on and then the associated RX is polled.@SeanB - So your saying that I need to set something up above each sensor at the same height and write code to adjust each sensor so that the ADC binaries are the same? I dont think I'll be able to do that until I have the TX and TX diodes permanently mounted to a circuit board etc, because right now they are just roughly in a protoboard.@StillTrying - Interesting. So its more important that they are all as perfectly aligned than the responsiveness of each diode?When I was swapping out the photo diodes, with the circuit running, some of the photo diodes would turn the blue LED on with no object above with only room light. Some of the photo diodes wouldn't. I find that to be vert frustrating. I attached an image of how the photo diodes are connected. The blue LEDs and emitters are connected to constant current LED drivers. The mircoprocessor uses EUSART to transmit data the the drivers.I failed to mention that the processor varies the intensity of the blue diodes based on how close an object is to a sensor. I think I know what I have to do. I think I have to do what SeanB mentioned. I going to have to hard-code adjustment for each diode. That's going to suck because that's a hell of a lot more code. That seems very tedious and I want to make a few of these too!There's has to be another way that I can do this, but for another time because I have to get this done now.

author: TimFox
author_rank: Super Contributor
timestamp: March 21, 2020, 03:26:10 pm
content: As stated above, a reverse-biased (normal connection) photodiode generates a current proportional to the light power stopped in the junction. If I remember correctly, the factor is about 0.4 A/W for green light in silicon. Ordinarily, at a given wavelength, the conversion factor should be constant from device to device, however the optical efficiency (due to reflections, effective aperture area, etc.) affects how much light power hits the junction. Since the diode is biased, there is also a leakage current, which is a strong function of temperature. How are you converting this current to a voltage for your circuit?

author: Siwastaja
author_rank: Super Contributor
timestamp: March 21, 2020, 04:13:37 pm
content: Just a guess, you are likely connecting the photodiodes wrong. You need to reverse bias them, measure the current, and because the current is usually so damn small, you may need to amplify it locally before feeding to a microcontroller. Yes, a lot of components. You may want to look at integrated light sensors.

author: cvriv
author_rank: Frequent Contributor
timestamp: March 22, 2020, 09:21:47 am
content: Thanks for the replies. Imbpretty aire I have them forward biased; the anode connected to VDD and the cathode connected to the input pin. Reverse biasing it would be the other way around right?How would I amplify that current? Could I use a transistor? I have some opamps as well.This is more of a learning experience than just something to complete. I'd like to do everything from scratch as much as possible.The current leakage is going to produce about 0.7v across the junction right? The more light on the junction, the more current that gets through? Just want to be clear.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 22, 2020, 10:21:41 am
content: Quote from: cvriv on March 22, 2020, 09:21:47 amNo, 0.7V-ish would be the upper limit inforwardconduction (at significant current), you don't want to do that. Below that, the voltage over the diode is as much as you put over it, typically from around zero to negative. Then it acts like a normal diode: it won't conduct, except that light makes it "leak" more current.For a typical circuit, seehttps://www.analog.com/en/technical-articles/optimizing-precision-photodiode-sensor-circuit-design.html

author: cvriv
author_rank: Frequent Contributor
timestamp: March 22, 2020, 11:57:57 am
content: Thanks for the link. I'm gonna read it. Thanks.

author: TimFox
author_rank: Super Contributor
timestamp: March 22, 2020, 02:26:24 pm
content: The equivalent circuit for a photodiode is a current generator (proportional to light power) in parallel with a P-N diode. The direction of current flow is that which would try to forward-bias the junction. Therefore, a reverse bias voltage is usually supplied by the outside circuit to keep the diode reverse-biased so that the current flows out of the device. If the current flow into the external circuit overcomes that reverse bias voltage, then the diode will turn on and steal current from the load.In "photovoltaic" mode, used for solar cells, there is no applied bias. The current flowing into the load tries to forward-bias the junction, so the maximum voltage available from one cell is approximately 0.6 V. For higher voltage in practical use, cells are connected in series to produce higher voltage.In some sensing applications, the photodiode is connected directly (no bias) between ground and a virtual ground at an operational amplifier input (with feedback resistor) to eliminate the "dark current" due to diode leakage when reverse biased.

author: cvriv
author_rank: Frequent Contributor
timestamp: March 23, 2020, 01:34:20 am
content: Quote from: TimFox on March 22, 2020, 02:26:24 pmReally great information. Thank you so much. I'm reading reading all about it via the link shared here. I actually did a small test with a photo diode reverse biased and sure enough it works. I couldnt believe it. I would have never though to do that. I checked my project, just to verify, and I do have all of them forward biased. So im going research this and do some experiments before making changes to my project. This is all very cool and I hope that once I make the changes that the sensors will operate similarly to one another.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 24, 2020, 12:43:58 am
content: Type in "sharp distance sensor" somewhere on the 'net.These things have an IR diode and an array of sensors and they measure distance by where the reflected light hits the sensor.You can also get simple IR diodes and photo diodes/transistor together in a plastic housing, and screened from each other.For example, moules like below cost about EUR2 on Ebay / Ali / China.You should be able to get them cheaper without the PCB and such.

author: cvriv
author_rank: Frequent Contributor
timestamp: March 24, 2020, 04:24:57 am
content: Thanks for the info. I was actually going to design and 3D print a custom plate that would be used to mount the IR and photo diodes as well as isolate them from each other.I have a question about multiplexing the photo diodes with the opamps to the inputs of the microprocessor because foresee a problem, but Im going to hold out until I have a schematic drawn first. Plus I have other homework I need to get done:)

author: TheUnnamedNewbie
author_rank: Super Contributor
timestamp: March 24, 2020, 07:31:13 am
content: Since a photodiode is a currentsource, you usually use something like a TIA to amplify and transform the signal into the voltage domain, which is what your ADC of the micro controller probably wants.

author: mikerj
author_rank: Super Contributor
timestamp: March 24, 2020, 08:39:45 am
content: Quote from: cvriv on March 24, 2020, 04:24:57 amMultiplexing photodiodes can be problematic since you are dealing with small currents and high impedances so leakage and charge injection from a mux can become very significant, so you'd have to select a mux with this in mind and figure out suitable stabilisation times etc.Since you only have 16 inputs, it wouldn't be too arduous to have a TIA per photodiode (i.e. four quad op-amps) and then mux the low impedance voltage outputs of the op-amps. Unless you are planning to expand the number of photodiodes?Something to note is that photodiodes tend to work better with a non-zero reverse bias

author: cvriv
author_rank: Frequent Contributor
timestamp: March 25, 2020, 12:53:57 am
content: I don't even know what a TIA is at the moment. I guess I'll have to research as well. I actually would like to have more photodiodes one day as Id like a nice large surface area, but for now 4 x 4 is good for learning purposes.EDIT: I know what a TIA is now. One per diode?!?!?!?!?!? Is there another way?

author: cvriv
author_rank: Frequent Contributor
timestamp: March 25, 2020, 02:56:05 am
content: I'm checking out opamps and i'm paying attention to the important characteristics, input bias and voltage offset, but I'm wonder how much these characteristics will affect what I'm doing. I'm not doing anything to precise. I just want to diodes to operate similarly to one another and be able to have enough range that I can generate ADC binary that can be used to vary the intensity of the blue diodes in my project.There are opamps with multiple inputs. I was eyeballing the 4 or 8 input versions. Could i use a couple of these to switch between the diodes and run the output of each opamp to the analog pins of the microprocessor?Thisbis all very intriguing and id like to try and split hairs doing this one day.

author: GerryR
author_rank: Frequent Contributor
timestamp: March 25, 2020, 11:19:28 am
content: TIA =TransImpedanceAmplifier, as in the data sheet referenced above.