# Calculating resistor values for transistor circuit?

Discussion in 'General Electronics Chat' started by Robotics Guy, Aug 18, 2013.

1. ### Robotics Guy Thread Starter New Member

Mar 11, 2011
15
1
I've been trying to make a light sensor circuit that uses a photoresistor and transistor to turn an LED on when it's dark and turn it off when it's light. I've learned enough about transistors to know the general layout of the circuit, but I'm kind of confused on how to go about calculating the necessary resistor values.

The photoresistor I'm using has about 8kΩ resistance in normal indoor light conditions and I want the LED to turn on when it reaches about 80kΩ resistance (it goes up to about 150kΩ when it's totally dark). Fooling around in Multisim I came up with the following circuit that works:

I made the circuit on a breadboard and it actually works pretty well:

Although I got it to work, I feel like I cheated by just fiddling around in Multisim until it started working -- I'd like to know how you would go about actually determining the resistor values computationally. I understand how to calculate the different transistor currents, my textbook shows how to start with known values given and then compute the other currents and voltages, but it doesn't show how to actually design a circuit from scratch.

Can anyone explain that process to me?

Thanks

2. ### LDC3 Active Member

Apr 27, 2013
920
160
From your photo, U7 is the important voltage reading. In the second photo, note that it reads about 0.7 V. This is the minimum voltage needed to get current to flow from the base to the emitter, which allows current to flow from the collector to emitter. So to calculate R2, you would set up the equation:
Code ( (Unknown Language)):
1.
2. V = Vb * (R4 / (R2 + R4))
3. 0.7 V = 5 V * (80 kΩ / (R2 + 80 kΩ))
4. 0.7 V * (R2 + 80 kΩ) = 5 V * 80 kΩ
5. 0.7 * R2 + 56 kΩ = 400 kΩ
6. 0.7 * R2 = 344 kΩ
7. R2 = 491 kΩ
8.
I don't know why my calculation requires a resister that is 5 times greater than the one you are using.

3. ### MrChips Moderator

Oct 2, 2009
12,622
3,451
How to choose resistor values for simple common emitter amplifier?

Suppose you wish 10mA through the LED.
(Vcc - Vled - Vce)/Ic = about 3V/10mA = 300Ω

R3 = 330Ω is good enough.

You don't need R5.

The current gain of the transistor is anything between 10 and 300. If you want the transistor to go into saturation mode use a gain of 10.

With Ic = 10mA you need Ib to be between 1mA and 30μA.

R2 needs to be (Vcc - Vbe)/Ib , i.e. between 4.3V/1mA and 4.3V/30μA,

If R4 is lower than 1/10 of R2 the transistor should turn off.

Hence adjust R2 for desired sensitivity.

Robotics Guy likes this.
4. ### crutschow Expert

Mar 14, 2008
13,462
3,353
First, in this case you don't need R5 since R2 and R4 determine the transistor base current.

Then you calculate the R2 resistor value that gives you about 0.7V at the transisor base-emitter junction (typical BJT ON voltage) when the light sensor (R4) is at 80KΩ. There are several ways to calculate this but the easiest way for me is to calculate the currents and go from there.

So the current through R4 when the transistor base is at 0.7V is 0.7V / 80kΩ = 8.75μA.

Now we need to add some base current to this value. The LED current is affected by its ON voltage. Assuming a minimum value of 2V and a transistor ON voltage of 1V gives an LED/transistor current is (5-3) / 330Ω = 6mA. When the transistor starts to turn on depends upon its gain. From the data sheet the 2N3904 has a gain that varies from 100 to 300 at 10mA with a collector emitter voltage of 1V. Using the mean value of 200 gives a nominal base current of 6mA / 200 = 30μA

The total current through R2 when the transistor is ON is thus 8.75μA + 30μA = 38.8μA.

We now calculate the value of R2 as (5V - 0.7V) / 38.8μA = 110.8kΩ. This is close to the value of 100k you experimentally determined. The actual value depends upon the gain of the particular transistor you use and what LED current (brightness) you consider as being ON. You could use a pot in series with a smaller value of R2 to adjust that point, if desired.

Last edited: Aug 18, 2013
Robotics Guy likes this.
5. ### ScottWang Moderator

Aug 23, 2012
4,923
776
Because the Vce is too small, so if In series with R5 can be increasing the sensitivity of photoresistor in the circuit, and adjust the values of R5 can be affecting the sensitivity of photoresistor.

Last edited: Aug 18, 2013
6. ### Robotics Guy Thread Starter New Member

Mar 11, 2011
15
1
My textbook says that the Rc doesn't affect the current Ic, but your calculations imply that it does? Specifically, my textbooks says:

But how do we know that the transistor won't draw too much current?

But that equation doesn't account for the current flowing through R4 to ground, right?

7. ### Robotics Guy Thread Starter New Member

Mar 11, 2011
15
1
How do R2 and R4 determine the base current? If the transistor wasn't there, then the current through the resistors would just be V1/(R2+R4), but since the transistor is there, how do we know how much current the transistor will draw?

This helps a lot, but I'm still confused as to how you know that the current flowing through R2 will go into the transistor instead of through R2 to ground? Because if it did, then Ib would be different and you wouldn't get your desired Ic.

8. ### crutschow Expert

Mar 14, 2008
13,462
3,353
The base-emitter junction has a very low resistance when the junction is forward biased, similar to a diode, thus the current through the base is mainly determined by the applied base voltage and the equivalent resistance in series with the base. You can look at that as the Thevenin equivalent resistance of R2 and R4 in parallel with a source voltage equal to the voltage at the junction of R2 and R4 with the transistor not connected.

We know the extra current flows through Ib instead of R2 because the resistance of R2 is much higher than the input resistance of the base when the base is conducting. As the old saying goes, the current takes the path of least resistance.

Robotics Guy likes this.
9. ### MrChips Moderator

Oct 2, 2009
12,622
3,451
The maximum current through R2 and hence the base current is limited by R2.
Hence if R2 = 100kΩ, the max Ib would be 5V/100kΩ = 50μA.

With R5 in circuit, the maximum base current is 5V/(R2 + R5).

R2 is much greater than R5 and hence R5 has little effect.

With no light on the LDR (R4) all of the current through R2 goes to the base and turns on the transistor.

When the resistance of R4 falls it diverts current from the base and the base current is reduced.

Robotics Guy likes this.
10. ### WBahn Moderator

Mar 31, 2012
18,064
4,904
You are going about things in a good way -- experimenting and then trying to figure out how to achieve those results via design and not via a happening. A lot of good stuff has been thrown out by others, as well.

I've thrown together a blog post where I walk through a slightly different process that, as expected, results in roughly comparable values in the end. But it also goes into a significant drawback of this circuit, namely a pretty mushy and poorly-defined turn on value for the LDR resistance, and how to overcome it with the addition of a second transistor.