Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am trying to repeat a circuit from this post. For some reason it does not work properly, and trying to fix it I figure out strange behavior. LED turns on if I touch R3 with my finger or with something that conducts electricity. What can be the reason of that? Here is the video.

Schematic

Since the voltage supply is 3.3V instead of 5V, I changed resistors correspondingly: R1 = 66k, R4 = 99k. Also by mistake I changed the value of R3 to 150. Looks like the value of R3 is crucial. If make it large enough, the effect is gone, but the switch becomes proportional rather than discrete (lesser light leads to brighter LED).

share|improve this question
    
Can you confirm that you made the circuit I edited into your post (from the linked question)? R4 is 150, but your question suggests you swapped it to 99k? –  David Mar 30 at 8:07
    
It may not work on 3.3V - it depends on the LED you are using. Maybe you can provide a data sheet link? –  Andy aka Mar 30 at 9:33
    
@David Yep, everything is right. –  Alexander Solovets Mar 30 at 11:02
    
@Andyaka sorry, I do not remember. You can assume standard red LED with the voltage drop around 1.9V. –  Alexander Solovets Mar 30 at 11:03

2 Answers 2

When you change the supply voltage, resistor values don't necessarily change linearly. Especially with active devices like BJTs and LEDs. And note that the LDR will have about \$5-10k\Omega\$ when lit up and about \$200k\Omega\$ when in the dark.

Let me start by just suggesting some new values given the \$3.3V\$ supply rail. \$R_1=68k\Omega\$ is probably fine. But \$R_5=3.9k\Omega\$, \$R_3=390k\Omega\$, and \$R_4=56\Omega\$.

First off, recompute \$R_4\$. \$V_{BE1sat}\approx 200mV\$ and \$V_{LEDON}\approx 2V\$, so the voltage left for \$R_4\$ is \$3.3V - 200mV - 2V\approx 1.1V\$. To provide \$20mA\$, \$R_4=56\Omega\$. Previously, with a \$5V\$ supply, this remainder voltage was about \$2.8V\$. \$R_3\$ provides hysteresis and if you want to keep the hysteresis current about the same, you need to change \$R_3\$ by the ratio of \$\frac{1.1}{2.8}\$. That is how I arrived at \$R_3=390k\Omega\$. \$R_5\$ should provide the base current needed for \$Q_1\$ and I estimated about \$600\mu A\$. Given a loss of about \$1V\$ from the \$V_{BE1}\$ and \$V_{CE2sat}\$, I expect about \$\frac{2.3V}{600\mu A}\approx 3.9k\Omega\$.

Of course, this assumes a red LED with about \$2V\$. More drop could present a problem.

share|improve this answer

I was the one that posted the circuit you refer to in your question.

The basic problem is that you monkeyed around with something without understanding how it works. According to the description, here is the mess you ended up with:

This clearly isn't going to do what you want. The very high R4 is basically not there, and what you have is a latching circuit, as demonstrated in your video.

R4 should be sized so that it supports the LED current you want. Let's say this is a 20 mA green LED that drops about 2.1 V. Figure 200 mV accross Q2 when on, so that leaves 1.0 V accross R4. 1.0 V / 20 mA = 50 Ω. A 56 Ω resistor would be good, or maybe 51Ω if you really want the last bit of brightness and are willing to live on the edge.

Next you have to find what the resistance of the LDR is at the light level you want the circuit to switch at. I think that was determined to be 10 kΩ in the original question, so I'll use that as example. LDRs are available over a wide range, so this is something you either have to know from the datasheet for your particular LDR, or you have to measure it.

In any case, you want hte R1-R2 voltage divider to produce whatever voltage it takes to just turn on Q1. Let's say 550 mV since the current to turn on Q1 to cause positive feedback thru Q2 and R3 is quite small. Experiment to find the actual threshold. If R2 is 10k Ω then R1 must be 50 kΩ given the conditions we somewhat arbitrarily picked above. Your 66 kΩ value is therefore in the right ballpark, again assuming the LDR will be around 10 kΩ at the light threshold level. You'll have to adjust R1 to the desired light threshold level by experimentation anyway.

R5 is just there to limit the maximum current thru Q1 and thru the base of Q2. You want that to be a bit more than what it takes to keep Q2 saturated while maintaining the LED current. Let's say Q2 can be counted on to have a gain of 50. With the LED current set to 20 mA, that means you need at least 400 µA out of the base of Q2, although 50% more would be good. Figure the B-E drop of Q2 is 750 mV, and Q1 drops 200 mV. That leave 2.35 V accross R5. 2.35 V / 400 µA = 5.9 kΩ. I'd probably use 4.3 kΩ

That leaves R3. The circuit will work without R3. There is fairly high gain around the threshold point, but of course that gain is not infinite. There will be a range of light levels over which the LED will go from off to fully on. The purpose of R3 is to provide some positive feedback so that the circuit has snap action, or hysteresis. There are ways to calculate this, but this is getting long already. I'd start at 1 MΩ and keep reducing it by a factor of around 2 until you get the level of hysteresis you want. If you get down to 100 kΩ and you still don't get enough hysteresis, something else is probably wrong. Your value of 150 Ω is totally inappropriate (I can't even begin to imagine how you thought changing the original value by 7000 was a good idea) and will make the hystersis effect dominate and the light level become essentially irrelevant. What you end up with is just a latch, as your video demonstrated.

share|improve this answer
    
I don't see anything bad in "monkeying around" if I'm just learning. I did understand what scaling resistors down linearly was not appropriate, but the question was about the "touch" effect. From your answer I've learned that it was a "latch", but a quick search showed nothing relevant. Can you elaborate, please? –  Alexander Solovets Mar 30 at 21:43
    
@Alexan: As I said, the problem isn't making changes to a design, but making changes without understanding the design first. I explained in detail how it works in the original answer, and then explained in detail the process of converting it to a different power voltage here. Ask specific questions if you don't understand any of these explanations. Otherwise, I'm not sure what more I can say in general about the hysteresis. Do you understand how R3 provides positive feedback, and how positive feedback causes hystersis? Without specifics, it's hard to know where to start answering. –  Olin Lathrop Mar 31 at 14:13
    
Your analysis is comprehensive, thank you. But I am interested in "touch" effect. Why does it light up when I touch it? Am I right that in this case my finger is acting as a resistor that pulls the most of potential to ground? –  Alexander Solovets Apr 1 at 1:04
    
@Alexa: The thing you are touching is at a different potential than the circuit due to static electricity pickup, capacitive coupling to the power line, or whatever. It only takes a very short glitch to have it propagate thru the circuit and have the positive feedback cause it to latch. The potential on your hand with the few pF of capacitance is enough to produce such a glitch. –  Olin Lathrop Apr 1 at 13:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.