Question about phototransistor and resistors (Arduino projects book from Amazon)

Hey I'm new to electronics and working my way through an Arduino projects book from Amazon. In the latest project I did, three photo transistors are wired up with red, blue, and green gels over them to detect the red, blue, and green light. Then values are output to an LED to mix the values. I get the code and most of the electronics. However, at one point the book says:

on the other side [of each photoresistor], attach a 10 kilohm resistor to ground. This resistors is in series with the phototransistor. The phototransistor will force a current to flow in the resistor leading to a voltage drop across it. On the same side as the resistor, connect the phototransistor to Analog in pins 0, 1, and 2...

My question is why does there have to be a 10 kilohm resistor (or any resistor) between the phototransistor and ground? Why can't we run the phototransistor straight to ground? The way it's written says to me that the resistor is what is somehow helping the phototransistor vary the voltage? TIA.


To get a voltage drop, you need a current flowing thru a resistor.

The transistor is like a switch, it is On or Off.

When On, current from 5v flows thru the transistor, thru the resistor then to GND.

This creates a voltage drop of 5v across the 10k which your analog input is looking for.

When the transistor is Off there is no current flow, therefore no voltage across the 10k resistor.

larryd:
To get a voltage drop, you need a current flowing thru a resistor.

The transistor is like a switch, it is On or Off.

When On, current from 5v flows thru the transistor, thru the resistor then to GND.

This creates a voltage drop of 5v across the 10k which your analog input is looking for.

When the transistor is Off there is no current flow, therefore no voltage across the 10k resistor.

Thanks for the reply. I'm still a little confused. If the transistor is like a switch (on/off), isn't that just transmitting two values (0V or 5V)? I thought phototransistors varied their output based upon how much light they absorb (e.g. much more than two values)?

My question is why does there have to be a 10 kilohm resistor (or any resistor) between the phototransistor and ground?

Doesn't have to be.

Why can't we run the phototransistor straight to ground?

You can ... but in this case, you'll need a resistor connected from the phototransistor straight to VCC. In other words, you can swap the positions of the phototransistor and resistor to get an inverted signal.

The way it's written says to me that the resistor is what is somehow helping the phototransistor vary the voltage?

Yes, because the phototransistor varies the current with varying levels of light intensity.

I think of the phototransistor as a variable resistor, but its only 2 terminals. Any 2-terminal variable resistance can't output a varying voltage on its own, so adding a resistor creates a "wiper" at the phototransistor-resistor junction point.

cbriz:
Thanks for the reply. I'm still a little confused. If the transistor is like a switch (on/off), isn't that just transmitting two values (0V or 5V)? I thought phototransistors varied their output based upon how much light they absorb (e.g. much more than two values)?

Okay, Now you want to know exactly what happens opposed to basically.


A transistor is a current controlled device.

Light falling on the base junction is analogous to transistor base current in a regular BJT.

The more light, the more base current, the more the transistor will turn on.

Transistors have something called Gain (HFE)

The amount of base current times the HFE gives the transistor collector current allowed to flow
(Ic = HFE * Ib) .

If the Gain/HFE of the transistor was 1,000,000, you should be able to see the transistor would allow a maximum amount of collector current flow for a small amount of base current.

If the Gain were 1 (one) the collector current would be little.


Most Phototransistors have high Gain.

Hence, think of the transistor as a switch, a small base current will allow a lot of collector current.

No base current or no light, no collector current.


If there was 5v across the 10k resistor, you would have Ic = 5v / 10k = 500uA of current flowing through it.

For this 5V across the 10k, let us say the Gain of the transistor was 1,000, this means the effective base current would be, Ib = Ic / 1000 = 5uA

5uA is a small amount of base current.

If the Gain were only 100 the base current would need to be 50uA, still a very small amount of current.

It should be pointed out that since the collector current is so small, the transistor can enter ‘saturation’ at very low base current level, Google transistor ‘saturation’.

If you vary the light carefully, you could effectively very the collector current hence give an analog variable input voltage to the input on the Arduino.


Thinking of a transistor as similar to a variable resistor is okay if it makes you comfortable.


Watch this:

Photo transistor

Read these:
https://www.globalspec.com/learnmore/optics_optical_components/optoelectronics/phototransistors

https://johnloomis.org/ece445/topics/egginc/pt_char.html

As the light intensity increases (x-axis), the collector current increases in a linear fashion (y-axis). By adding the resistor, you can calibrate your circuit to operate within a desired range on this graph. That way you can achieve the greatest voltage range on the analog input. For calibration, it would be good to test your curcuit using both the minimum and the maximum lighting levels in your application.


BPV11 Silicon NPN Phototransistor

There is some confusion about transistors perhaps here.

There are two very different ways to use a BJT, linear and switched.

In linear operation the collector-emitter voltage is at least 1 or 2V, putting the device in
the active region of operation where the hFE gain parameter is relevant. For analog sensing
this is what you want, so here the voltage across the 10k resistors should be 3V or less to
ensure linear operation (you may need to adjust the resistor value to ensure this).

As a switch the transistor is either cut-off (no base or collector current), or in saturation
(collector-emitter voltage 0.5V or less, typically 0.2V or so). The hFE gain parameter
doesn't apply, and base current has to be about 5 to 15% of collector current.

The 4 modes of a BJT are determined by whether each pn-junction is forward biased or not:

EB BC mode
forw forw saturation (current gain about 10, switch on)
forw back active (current gain is hFE from datasheet, typically 50 to 800 depending)
back back cutoff (switch off)
back forw reverse-active (not normally useful as there's no gain)

The difference between emitter and collector is that the emitter is extremely highly doped,
the collector very weakly doped (10000:1 ratio or so). This is why reverse-active doesn't work.

For a photo-transistor you want the highest gain, so typically its not going to be used in
saturation, but in linear mode, even as a switch.

Thanks everyone for the detailed replies. A lot of this is over my head right now but I'll review it all as I keep working through the projects.

Why can't we run the phototransistor straight to ground?

Because you would have nowhere to connect the analogue input to that isn’t ground or 5V.

Or if you mean why not connect the phototransistor between output an ground then there is no voltage that is being generated by the phototransistor for the analogue inputs to measure.

The way it's written says to me that the resistor is what is somehow helping the phototransistor vary the voltage?

Yes this is exactly what it is saying, although it is written in a very clumsy way.

cbriz:
Thanks everyone for the detailed replies. A lot of this is over my head right now but I'll review it all as I keep working through the projects.

Do you have a DMM, Digital Multimeter?
If not it will help you understand how your circuits work.
Even a cheap DMM less than $20 will do if it will measure DC volts and resistance ohms.


Tom... :slight_smile:

Hi,
This may help;

Tom... :slight_smile:

dlloyd:
As the light intensity increases (x-axis), the collector current increases in a linear fashion (y-axis). By adding the resistor, you can calibrate your circuit to operate within a desired range on this graph. That way you can achieve the greatest voltage range on the analog input. For calibration, it would be good to test your curcuit using both the minimum and the maximum lighting levels in your application.


BPV11 Silicon NPN Phototransistor

To expand on this a bit, the graph shows the current through the phototransistor (y-axis) as a function of the light intensity (x-axis).

  1. Since the resistor is in series with the phototransistor, the same current must pass through the resistor.

  2. From Ohms law, the voltage across the resistor then is that current multiplied by the resistance value. To get 5 V across the 10k Ohm resistor implies a current of 0.5 mA, which corresponds to about 0.06 mW/cm2 of light intensity. To get a logic level low, say less than 1 V across the 10k Ohm resistor implies a current of less than 0.1 mA which corresponds to a little more than 0.01 mW/cm2 light intensity on the x-axis of the plot.

  3. Thus one can adjust the sensitivity of the circuit by changing the value of the resistor, a smaller resistor makes output voltage less sensitive to light intensity. In the degenerate case of the emitter connected directly to ground, or zero Ohms resistance, the voltage will never change from zero.

Note that the graph, the linear approximation to the circuit, and hence the above analysis breaks down when the circuit hits the supply voltage, so the voltage across the resistor can only be in the range 0 to a shade less than 5 V.