Unable to understand big difference between simulation and real life circuit (simple light detector)

WBahn

Joined Mar 31, 2012
30,060
@dl324 Do you have a preferred tool for this that you usually use? The one I linked is the first one I've found actually, it would be good to get some recommendations of what people actually use.
The quality of simulation results depends on a few things. First, there's the quality of the simulation engine itself. I have no idea what these online, visual simulators use, let alone how good it is. Second, there's the quality of the device models that are used. This is the real crux of things (assuming an adequate simulation engine to begin with). If the device models are crappy, then it's garbage in, garbage out. Based on the simulation results you showed, I suspect (could be wrong) that the transistor model they are using is very simple and has a fixed current gain of 100 in the active region. Having said that, that should be good enough for a circuit like this to get results that are in reasonable agreement and the simulator's results do not seem too unreasonable. The Vbe is a bit higher than I would expect, but not completely out of line.
 

Thread Starter

kajman

Joined Dec 30, 2022
26
Ok guys, I've spent the last two hours measuring this and checking various ideas and I think I've found the error I made! I hooked the pot only on second and third leg instead of first and second (that's correct now right?). Now I've read that the first one should go to the ground and after changing this everything in simulatot seems to be consistent enough with the voltages I measure (i think something like +/- 10% range most of the time).

I feel both very stupid and a little less stupid at once I'm very grateful for your help and willingness to look into this issue, I've learned a lot today and I think it will be much easier from now on.
 

WBahn

Joined Mar 31, 2012
30,060
Ok guys, I've spent the last two hours measuring this and checking various ideas and I think I've found the error I made! I hooked the pot only on second and third leg instead of first and second (that's correct now right?). Now I've read that the first one should go to the ground and after changing this everything in simulatot seems to be consistent enough with the voltages I measure (i think something like +/- 10% range most of the time).

I feel both very stupid and a little less stupid at once I'm very grateful for your help and willingness to look into this issue, I've learned a lot today and I think it will be much easier from now on.
But since your measurements were coming out at right about half the pot's total resistance, it shouldn't have mattered in this case.

It really doesn't matter if you use pins 1 and 2 or pins 2 and 3 (assuming pin 2 -- the middle pin -- is the wiper, which is a pretty good assumption). You just need to be sure to measure your resistance between the same two pins that you use. The numbers you posted in Post #1 are consistent with this, namely that a higher pot resistance turned the LED on and a lower post resistance turned it off.
 

Thread Starter

kajman

Joined Dec 30, 2022
26
I think it also possible that I've disconnected the smaller resistor by accident. The circuit still "works" even without it but the change is not that rapid. I also think that measured the resistance wrongly sometimes (without disconnecting the pot). This probably all led to those discrepancies. I'm really glad that now it's consistent and I know better how to measure this.
 

dl324

Joined Mar 30, 2015
16,922
I've spent the last two hours measuring this and checking various ideas and I think I've found the error I made! I hooked the pot only on second and third leg instead of first and second
Your circuit doesn't show a pot:
1672443110289.png
The way you're driving the LED is unusual. If you want to drive it high side, you should use a PNP transistor.

You don't specify what type of LED you're using. If it's a typical LED, the maximum continuous current is usually 20mA.

Where are you placing the pot? Which resistor represents the LDR?
 

Ylli

Joined Nov 13, 2015
1,087
The first thing I noticed it that the transistor used as a very low hFE. 3 ma of base current to get 30 ma of emitter current, and an unusually high Vbe of 0.84 volts.
 

WBahn

Joined Mar 31, 2012
30,060
The first thing I noticed it that the transistor used as a very low hFE. 3 ma of base current to get 30 ma of emitter current, and an unusually high Vbe of 0.84 volts.
The base current is only 0.3 mA (2.1 mA in the 200 Ω resistor minus the 1.8 mA in the 1.6 kΩ resistor). That yields an hFE 99.3. I suspect the actual model hFE is 100 and that the discrepancy is just due to the resolution that the other currents are displayed at.

The Vbe is a bit on the high side, but within the realm of most small-signal transistors at these currents as they start moving into saturation, which that one is.
 

PaulEE

Joined Dec 23, 2011
474
Kajman,

This is a cool first circuit, it was my first circuit in early grade school!

Simulations, unless very carefully thought out, don't always align with the real world. In this case, a potentiometer versus a fixed resistor and varying photo-resistor are subtly two different things, and as such, will produce different results.

Also, because any voltage seen at the base is around 0.65-0.7V LOWER at the emitter, the voltage at the base will need to be a few volts in order to light the LED how your schematic is drawn.

I would put a fixed resistor, then the LED, then the transistor, then a resistor about 1/10th the top one, to ground. In other words, resistor and LED on top, small resistor on the bottom.

The reason for the small resistor at the bottom is that, if you were to look into the base, that small resistor will "look like" a big one, as it is approximately multiplied by the beta of the transistor. B=100 for example, would make a 100 ohm resistor look like 10K. This has the effect of making the voltage divider portion work as more of a voltage signal than as a current source...which is what you want (in my humble opinion).

So, example...if you're LED has a forward voltage drop of, say, 2.5V, and the transistor will have a Vce of 0.1V, you know two resistors will drop the remaining (3.3V-2.5V-0.1V)=0.7V. If the LED will run on (let's just pick a number) 5mA, that works out to 140 ohms. If the resistor on top is 10x the resistor on the bottom and the sum equals 140 ohms, that's two equations and two unknowns, of which you get 127 ohms (top) and 12 ohms (bottom). I'd do 120 and 10 and that should get you close.

The 10 ohm resistor will look approximately like a 1K resistor looking into the base.

Now the front-end voltage divider.

If you're using a CDS photocell, the resistance typically goes UP when it gets DARK. When R rises, it will drop more voltage in a voltage divider across ITSELF.

You want the circuit to turn ON when it gets DARK. So the photocell should be on the bottom. Usually it is around 5-10K when it gets light enough such that you would want the LED to shut OFF, so then it is a simple voltage divider calculation to drop around 0.7V (Vbe) + 10 ohms * Ie (around 5-10mA) or around 0.75-0.8V.

The top resistor, therefore, (first order approximation here), should be around 31K. It would look something like below.

Note that you may want to make R1 a potentiometer connected as a simple rheostat in series with a fixed resistor so you can experiment with it. The software below is TINAspice by TI, and other good programs are LTspice, Pspice, circuit maker 2000,...

If you make the 10K resistor 9K in the image below, the green LED shuts off, which was what we were aiming for it to do (second image).

Note that with the emitter having a resistor, the turn on will be a bit gradual, as this is technically an amplifier with a gain of around 10-12. If you'd like it to be a bit more "snappy", you might consider a second transistor in darlington configuration to buffer the voltage divider first, and then you have to account for the second Vbe drop, etc etc. The gain of that composite transistor would be B1*B2, or 100^2. That 10 ohm resistor now looks like 100K...

1672453071276.png
1672453149116.png

Paul
KI5VNH
 
Last edited:

Ylli

Joined Nov 13, 2015
1,087
The base current is only 0.3 mA (2.1 mA in the 200 Ω resistor minus the 1.8 mA in the 1.6 kΩ resistor). That yields an hFE 99.3. I suspect the actual model hFE is 100 and that the discrepancy is just due to the resolution that the other currents are displayed at.

The Vbe is a bit on the high side, but within the realm of most small-signal transistors at these currents as they start moving into saturation, which that one is.
2.1 -1.8 = 3, right? Oops. :rolleyes:
 

Thread Starter

kajman

Joined Dec 30, 2022
26
Your circuit doesn't show a pot:
View attachment 284215
The R2 is the potentiometer in my circuit (I've updated the linked simulator). It represents the missing photoresistor. I do not know anything about the LED, I cannot see any marking there and I bought it years ago.

@WBahn You're right, the hFE value in simulator is set to 100. I've measured the transistor yesterday using my multimeter and it showed values between 500 to 700 so I've updated the simulator now to 600.

@PaulEE thank you very much for your extensive answer, I'll try the ideas you listed when I have some more time, this definitely helps me understand some more of what's going on here.
 

dl324

Joined Mar 30, 2015
16,922
I think i have the third one, the voltage rises upto 2V on it. Where did you get the info from?
That's generic information that is unlikely to apply to any LED you use; 50mA continuous current is higher than most. You need to use the data for your specific LED.

This is from Siemens (LS=super red, LA=amber, LO=orange, LY=yellow):
1672501508387.png

1672501590813.png
1672501612971.png

EDIT: data for some 3mm HP LEDs from the 1980's:
1672502298110.png
1672502231632.png
 
Last edited:

Thread Starter

kajman

Joined Dec 30, 2022
26
Small update, I've received photoresistor today and thanks to you guys I was able to modify the circuit in few minutes in such a way that the LED is lit when there is enough light. This time it was really easy and worked right away (and exactly as in simulator).

Thank you all for your time and help, I wish you all a Happy New Year!
 
Top