Go Down

Topic: Using phototransistors - hardware check. (Read 2 times) previous topic - next topic

kevind2010

Hello again, Arduino forums! I've read some posts about people using phototransistors as a "switch" setup, with very high-resistance circuits (>10Kohms). Here, I'm trying to use the phototransistor in its "active" mode to sense light - this uses much lower resistance.

Right now I'm working with some Vishay Semiconductors TEPT5600 phototransistors (sold as "ambient light sensors"), which I just received yesterday. I'm having some difficulties getting them to work well in my test setup, however. What I'm doing here is trying to measure the response of the phototransistor to a red LED which has a peak emission wavelength very near the phototransistor's peak sensitivity.

Testing procedures are as follows:
- room is completely dark
- wire up a red LED to a PWM pin on the board, attach it to something about 5 inches away from the phototransistor.
- point PWM and phototransistor at each other.
- use board to step through PWM settings, 15 at a time (0, 15, 30, 45, etc)
- for each PWM "step", take a reading of the light from the LED.

Using this, I should be able to create a response function for the phototransistor. Unfortunately I believe I'm doing something wrong. One set of (simplified) results looks like this:

     PWM setting:   15                120            255
Voltage (counts):   337.875        338.75         339.625

This was made with a 68-ohm resistor and a phototransistor (more on the setup below), with a normal reference value; saturation occurred when I put the setup at 2.56V or 1.1V on the Mega. Readings were taken simply using analogRead().

My emitter LEDs are not weak, and they occupy a particularly sensitive range of the phototransistor. I would expect something a little more... "diverse" from my results. It is difficult to make a response function for something that really only changes by about two counts from "barely light" to "all the way on". I would expect something considered "sensitive" like a phototransistor to produce more variation between brightness levels.

My circuit looks like this:

GND ------- resistor ---- Arduino analog in ------- phototransistor ------ Vcc
... where I've experimented with values between 68 ohms and 470 ohms for the resistor, and I've been trying to avoid frying the resistor by making the input voltage 1.5 volts (supposedly the maximum for this specific photodiode when used in an emitter-collector state).

Might anybody have some insight as to why the photodiode is producing results with such low variation between brightness levels?

Thanks in advance,

Kevin

liudr

Long post. Summary: I used phototransistor in active region (PNP or NPN?) to PWM'd LED and results don't change when I change PWM from 15 to 255.

See, pwm is kind of slow (512Hz if I remember correctly). The phototransistor can follow the PWM intensity up and down so maybe your experiment design is flawed by thinking that the led intensity is continuously varied.

Plus the photo transistor has two leads and I don't think you described how you connected it well enough for anyone to tell if E or C is connected to 5V, or even PNP or NPN.

EmilyJane

The response of that device appears to be more logarithmic than linear. Take a look at Figure 4 on the data sheet. I have no idea how to relate your illuminance levels to the curve but that might explain what you are seeing.

kevind2010

That was a long post, I apologize. Thanks for the summary!

That's the gist of it - the results do not change much at all from 0 to 255.

liudr, I see your point about the PWM approach - the phototransistors are pretty sensitive and they can "follow" a square wave. However I'm not sure that this is showing a huge effect on my data. Presently I'm taking ten samples per intensity, and the variation is generally quite low. The largest variation I see is maybe 2 counts, which is pretty negligible to me. What I showed in the first post was a set of averages computed from the 8 trials at each level. The standard deviation for those were 0.3, 0.5, and 0.7, respectively. All very low in my book.

As far as the phototransistor goes, I'm not entirely sure if it's PNP or NPN. If I connect the long lead to the Vcc, it senses; if I connect the short lead to the Vcc it reads zero each time. I e-mailed the people at Vishay Semiconductor to see if they could tell me more about the device... waiting to hear back still from them. You'd think they would put that sort of information on their data sheets.

kevind2010

Thanks for the suggestion, EmilyJane! I'll see what my results look like when I try to correct for nonlinearity and see what that gives me.

-Kevin

kevind2010

Also, @ liudr - the phototransistor is an NPN type. Finally found that out... that took way too long.


liudr

You have a spare one?

Emitter collector voltage VECO 1.5 V

The above is the maximal reverse voltage the thing can take. By reversing the connection you have already burnt it.

Short leg on the filed flat edge is collector and should be on higher voltage (collector-resistor---5V). Long leg on the circular edge is emitter and should be on lower voltage (gnd).

BTW, I burnt one IR receiver and an accelerometer. Hope that makes you feel better.

EmilyJane

When you get a phototransistor that you know works, I recommend you modify your test method a bit. Attach the emitter of the transistor to ground and attach the collector to one end of a 7-ish KOhm resistor and the other end of the resistor to Vcc. Connect the junction of the resistor and the collector to an analog input. Hook up your LED like before but use long leads so you can move it closer and farther away from your phototransistor.

Now, with the only light in the room coming from the LED run your sketch and move the LED back and forth until the reading is around 2.5V. This will be the point at which your illuminance is 100 and your photocurrent is 350 microamps. Then you can use that knowledge to use the curve in Fig.4 of the data sheet to get where you want to be.

Turn the lights back on and see what effect that has. Remember, light intensity varies by the square of the distance, so use that fact while you're playing with the setup.

If you approach the problem scientifically you will have better results, I think.

pantonvich

i'll add that you can have wildly different affects with: sunlight (time of day i.e. angle), fluorescent bulbs, incandescent bulbs and led bulbs

EmilyJane

I looked at the curve in Fig. 4 again and it's plotted log vs log to compress the axes not to disguise the non-linearity of the device. The device is actually very linear.

tkbyd

While I endlessly reinvent wheels myself, and have fun doing it, if you actually want to know light levels somewhere (sooner rather than later), you might consider the $5 module from ModernDevice....

http://shop.moderndevice.com/products/ambi-light-sensor

Note what they say about their answer to the problem of the wide range of light levels you may experience, and "eye-like" sensitivity.

MarkT

Forget the LED thing, first just roughly check the thing's working by comparing the output with
(a) direct sunlight,
(b) shade,
(c) indoors in daytime
(d) artificial light.

That should cover a range of 3 or 4 or so orders of magnitude.

And if you want to calibrate it then PWM is never going to work without some sort of low-pass filtering - opto electronic devices like this have MHz bandwidths...
[ I won't respond to messages, use the forum please ]

liudr

Yes, try a few lighting options as said by Mark. I still suspect it is dead. Phototransistors are not rated for high current and while reversing a GP transistor you may get a survivor, you may have killed your phototransistor already the first time you connected it wrong.

liudr

I may have one or two phototransistors I can mail you if you are in US. Don't order just one from a major supplier. Bad for trees.

Btw mine is not rated so no spec sheet ;)

kevind2010

So many helpful suggestions! Thanks everybody! I got the phototransistors working in my system. Here they only need to be sensitive to a specific light source that I'm controlling using the Arduino. Response functions are fantastic for these things - very linear and easy to measure. Linear fits reveal correlations of > 0.9998. Fantastic!

And no I haven't fried any of them yet. The good news is that they are cheap - at $0.56 apiece I won't cry too badly about frying one. Or three.

Thanks again everyone!

Go Up