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

Thread Starter

kajman

Joined Dec 30, 2022
26
Hi, I'm very new to electronics and just did my first circuit in real life :)

I cannot understand why it behaves so differently from the one that I simulated, can anyone explain the difference to me?

The circuit is a dark detector where I've (for testing) replaced the photoresistor with a potentiometer.
According to the simulation: https://everycircuit.com/circuit/6126457715425280 the diode is turned off completely by 800 Ohm and turned on by 1200 Ohm on potentiometer. I've measured the same on the real board and the values are completely different and the range span is lower. So IRL the diode turns on by 5.07k Ohm and turns off completely by 4.85k Ohm.
The resistance values on the simulator are the measured resistance from my breadboard. I've used a red LED and the transistor I've used is: bc 547b. I'm taking power from a power adapter which is set to 3.3v.

This is a short movie with it: https://photos.app.goo.gl/Y2XeiweXAoCeL11Q9

Can someone please explain to me where does the difference come from and what should I change in my simulation so that it behaves as in real life? I tried playing with transistor and diode parameters but couldn't find any values that affect the behaviour as much. Any tips would be greatly appreciated.
 
Last edited by a moderator:

Ian0

Joined Aug 7, 2020
9,667
What voltage do you measure at the point you have labelled 2.88V?
What is the voltage across your LED when it is illuminiated? A red LED will have a lower voltage than a green one, and will probably be lower than the 2.0V you have on your diagram.
(Do the moving dots like miniature pacmans really help?)
 

Thread Starter

kajman

Joined Dec 30, 2022
26
I'm not sure they help :) This is the first simulator that I found that was really user friendly but I'm open to suggestions.
I'm not at home right now so cannot measure, but remember that the voltage on LED was around 2v when I gave it full power. It was light up even by lower values but I can answer only in the evening.

Just for test I've changed the voltage of LED in simulator to 1.7v and then it turns off by 450 and turns on by around 600. To make it change around 5k Ohms I've needed to put the voltage of LED to 2.5v (and for sure the voltage on diode was never above 2.1v when I measured it) in simulator but then the range of values it is slightly lit is much higher (in real life the 200 Ohm difference are between very bright and almost completely off).
 

WBahn

Joined Mar 31, 2012
29,976
Your measured numbers don't make a lot of sense. It's as if you are using a transistor with a really low current gain and high Vbe.

Could you post some close-up pictures of your circuit that show the exact connects made and let us see the device markings, such as the resistor color bands, clearly?

Are you sure that you have the transistor connected correctly (that you haven't swapped the collector and emitter)?

1672390479821.png

Note that this is the reverse order of many other transistors, such as the 2n3904:

1672390573417.png
 

Thread Starter

kajman

Joined Dec 30, 2022
26
@WBahn sure, I will try to post closeups in around 7-8 hours when I get home. Its absolutely possible that I messed up something, but I think the transistor is correctly mounted (I mean the same as in simulator)
Base goes to 200Ohm and potentiometer, collector to 23Ohm and emitter to LED. Im using this one:
1672391102081.png

It is mounted with the flat surface facing the potentiometer and connected directly to the compontents I mentioned above.
 

dl324

Joined Mar 30, 2015
16,842
I cannot understand why it behaves so differently from the one that I simulated, can anyone explain the difference to me?
Simulators don't always give reasonable results and the User needs to be able to determine what the case may be.

It would be helpful if you posted the schematics on this site. Monochrome is much preferred over the colorful schematics most simulators provide.
 

Thread Starter

kajman

Joined Dec 30, 2022
26
@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.
 

dl324

Joined Mar 30, 2015
16,842
@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.
When I use a simulator for analog circuits, which is rarely, I use LTspice. I've had numerous problems where it said circuits I knew should work wouldn't. Instead of wasting time figuring out how to make LTspice work, I just breadboard the circuit.

It does have its uses. I wanted to check the performance of 4 different temperature sensors I designed to see if it was worth the bother to compensate for the base-emitter temperature dependency. Varying parameters is something that a simulator does well. It turned out that the simplest was good enough and all the extra work was for naught.

I wouldn't use LTspice for digital. There are much more capable simulators available.

LTspice still won't stop you from doing stupid things.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi kajman,
What is the type number of your photo resistor.?
They do vary widely in their light response performance.

BTW: I would recommend using LTSpice for checking both digital and analogue circuits, providing the user has the necessary experience to interpret the LTS results.

Some users expect LTS to design the circuit for them, that is not it's purpose, it should be used to check your design.

E
 

Thread Starter

kajman

Joined Dec 30, 2022
26
@ericgibbs right now I'm waiting for the photoresistor to arrive and I've substituted it with a 10k potentiometer.

@dl324 when you design analog circuit without a simulator you calculate all the voltages, needed resistors etc in your head? I was hoping that using a simulator I would get to play with my design and find the best values quickly and then just put it once on breadboard and be done with it.

Honestly I'm surprised that a (paid) simulator cannot predict a circuit with 3 resistors, transistor and a diode correctly. That must be the simplest circuit out there (apart from resistor + led). I'm much more inclined to believe that I made a mistake somewhere, but I have to little skill to find it yet.

What is also confusing for me is that I cannot adjust the values in simulator in such a way that the circuit behaves as in real life. It should be possible to adjust transistor and LED values in such a way that it does, right? Or is this simulator really a fluke and cannot simulate the simplest circuits?
 

Thread Starter

kajman

Joined Dec 30, 2022
26
@ericgibbs It's GL5528, unfortunately it's rated as 10k to 20k which I missed when choosing the potentiometer which has max of 10k, thus using it may require further changes in circuit.
 

Thread Starter

kajman

Joined Dec 30, 2022
26
@ericgibbs is it possible to plot a diagram of voltage led depending on resistance of potentiometer/photoresistor? So it would be easy to see at what resistance value the light goes on?
What I liked in the simulator I linked was that I could change the values live and see their effect but using some online SPICE based simulator was not possible. Is there such functionality (live changes or plotting selected values when for ex. resistance changes) in LTSpice?
 

dl324

Joined Mar 30, 2015
16,842
@dl324 when you design analog circuit without a simulator you calculate all the voltages, needed resistors etc in your head?
I'll sometimes use a calculator when the calculations are too complex to do mentally; or I'm too lazy. I find it more rewarding to do designs using the simulator between my ears.
I was hoping that using a simulator I would get to play with my design and find the best values quickly and then just put it once on breadboard and be done with it.
That's the difference between actually designing circuits and just slinging components and values around until you find something that works.

Simulators don't always give the right answer. The key is to know enough to know when the simulator isn't giving you the right answer. They usually give reasonable answers, but you need to know the difference between reasonable and unreasonable results.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi k,
This is a LTS simulation using that LDR.
Note: you will not get a snap action switch ON of the LED with that basic circuit.
The 10k pot will enable you to set the intensity of the LED.
E

Added LTS asc file

EG57_ 418.png
 

Attachments

Thread Starter

kajman

Joined Dec 30, 2022
26
@dl324 I know this may seem absolutely unprofessional but this was actually my attempt at learning electronics this time, that means just slinging some components, changing their values and seeing what happens. I wanted to build some intuition this way, test some stuff and take up any theory along the way that i feel I'm missing the most. I already attempted this other way around (theory first) few times years ago and failed. I hoped using this "live simulators" would be a great help in this. But it seems this is not that easy as I hoped :p
 

WBahn

Joined Mar 31, 2012
29,976
I'm attaching the photos from the circuit up close. Hope it's visible enough.
The photos are fine and I agree that it looks like you have everything hooked up correctly, including the orientation of the transistor.

Do you have another transistor you could use to rule out the possibility that the one you have is damaged?

How are you measuring the pot's resistance? A difference of 200 Ω is just 2% of the pot's range. If the pot's rotation angle is 300°, that's just 6° of movement, which isn't much at all. I can't tell from the video is this is consistent with how much it's being turned between "off" and "on". When you make your measurement, don't remove the pot from the breadboard as this risks moving the pot's position a bit. Instead, disconnect one of the wires, such as the red wire at the transistor, and measure the resistance between that end of the wire and your circuit's 0 V reference node.

Do you have a smaller-resistance pot, say 1 kΩ or even less, that you could put in series with a fixed resistor?

If not, then you can do something like the following:

Use a fixed 4.7 kΩ resistor in series with a 510 Ω resistor. Now put the pot across the 510 Ω resistor. As you vary the pot, the total resistance will vary from ~4700 Ω to ~5210 Ω. This will give you a lot better resolution on your adjustment. Of course, you can adjust this range up or down as needed by just using different fixed resistors.

Have you verified the results by replacing the pot with fixed resistors that match the resistances you got?

Adjust the pot so that the circuit has just barely turned "off" (say where the LED is still putting out just a tiny bit of light). Now measure the voltage at each of the transistor's terminals (relative to 0 V).

Repeat this with the pot adjusted so that the circuit barely "on" (say where the LED is pretty bright, but you can still make it a bit brighter).

What are those voltage values?

Also include, for sanity's sake, the measured voltage of your 3.3 V supply in both cases.
 
Top