Maker Pro
Maker Pro

More efficient LDR "dark" switch?

hevans1944

Hop - AC8NS
The 1M resistor was replaced with a 10k resistor (brown-black-black-red - I write this to check myself, Adam not you - I am befuddled by a simple analog voltage divider right now! :mad::oops:)

The LDR is in place and the pot is a 104 100k with center tap between LDR and 100k resistor. 100k resistor going to Vcc. Pot shows smooth transition of resistance across spectrum. In circuit, voltage ranges from .124V-.68v while LDR is illuminated. When dark it rises to 2.1 (continues to climb extremely slowly).

led-light-gif.20506
You didn't change the schematic to reflect the change in resistance value.

Can I assume this thing now works? The 2.1 volts should mean both transistors are on and the LEDs are illuminated when the LDR is dark. Is that correct?
 
Centre tap between LDR and 100K, what you have another resistor now that's connected to Vcc? The pot should connect to the 10K LDR and base of the transistor.
Adam
 
I have to run to work - I appreciate your efforts. I will redraw the schematic to reflect what I am working with to be clear. I was just copying and pasting Colin's to keep close as a reference while I worked on all the suggestions you guys have made. The last thing I checked was part two of Hop's instructions and maybe this is part of the issue I am having:

Re-connect the wire between base of first transistor and pot wiper. The LED should light at full brightness (second transistor saturated) when the pot wiper is positioned toward the end connected to the 10 kΩ resistor. The LED should be extinguished (second transistor cut-off) when the pot wiper is positioned toward the end connected to the negative terminal of the battery. This should be true whether you use a 100 kΩ pot or a 500 kΩ pot! The Darlington-connected pair of transistors should have more than enough gain to fully saturate the second transistor when the pot voltage is greater than about 1.2 to 1.4 V. The 10 kΩ resistor limits the forward-biased base-emitter junction current to a safe value when the pot is rotated toward the maximum voltage end.

I am getting 1.2v max and the single LED is not lighting - that could indicate that the batch of 2n3904 I have have low gain or that something else is amiss. I will return later, thanks ever so much guys!!
 

hevans1944

Hop - AC8NS
If you can't get the LED to turn on and off by varying the pot wiper position, but you measure 1.2 V at the base of the first transistor, that indicates the voltage is the result of two forward-biased transistor junctions connected in series. But it doesn't necessarily mean those are emitter-base junctions! One or both could be collector-base junctions! It is a very common mistake when installing this transistor to get the emitter and collector leads reversed. The emitter and collector are on opposite sides of the transistor package with the base located in between them. With the transistor flat facing toward you, and the leads pointing down (as if to insert the transistor on a solderless prototype board), the collector is on the right and the emitter is on the left:

to-92.gif
 
Last edited:
That's a very good point Hop. This would mean the transistors had much reduced gain and this could account for what is happening.
Adam
 

hevans1944

Hop - AC8NS
I am somewhat embarrassed to admit that I have reversed the emitter and collector connections on several occasions.:)
 
I thought i'd have a go at designing a low power circuit but i used a potentiometer as the ldr, so it may need swapping (lights when it's light )..

3am and pretty wasted too, so forgive any oversights lol
 

Attachments

  • 2015-06-21 03.42.24.png
    2015-06-21 03.42.24.png
    190.1 KB · Views: 122
  • 2015-06-21 03.42.51.png
    2015-06-21 03.42.51.png
    190.1 KB · Views: 109
The above is what I am working with currently. Unfortunately the spice model is showing 0.8mA across the LED whether R3 (LDR) is light 2.5k or dark 25k. I don't think the pot is being simulated faithfully, so the above is just a reference for the physical model on my breadboard.

That is a very good point @hevans1944, but luckily I got my EBC's right ;-) On the breadboard, transistor 1 is facing me, while transitor 2 is facing away from me, that way I can stack the collector pins together in the same row. I checked the source that I bought the transistors from and it states that the pin layout is EBC (it is a TO92 package). Should I check transistors to verify if that is truly their arrangement?
 
Going back to your very detailed troubleshooting Hop

With the 10 kΩ resistor connected to positive terminal of the battery, the other end of 10 kΩ resistor connected to top of potentiometer, bottom of potentiometer connected to emitter of second transistor and negative terminal of the battery, you should now have a variable voltage divider between the wiper of the potentiometer and the negative terminal of the battery. Temporarily disconnect the connection between the base of the first transistor and the potentiometer wiper. Measure the voltage between the pot wiper and the negative terminal of the battery, It should vary from 0 to approximately 3 V (the battery voltage). Do this using the 100 kΩ pot. Replace the 100 kΩ pot with the 500 kΩ pot and do it again. The results should be approximately the same.

Yes, the voltage divider circuit portion is working correctly - voltage swings from 0-2.7vdc with both pots. Not quite 3v (the battery still tests out at a little over 3v, but it might be some draw from the breadboard??)


Re-connect the wire between base of first transistor and pot wiper. The LED should light at full brightness (second transistor saturated) when the pot wiper is positioned toward the end connected to the 10 kΩ resistor. The LED should be extinguished (second transistor cut-off) when the pot wiper is positioned toward the end connected to the negative terminal of the battery. This should be true whether you use a 100 kΩ pot or a 500 kΩ pot! The Darlington-connected pair of transistors should have more than enough gain to fully saturate the second transistor when the pot voltage is greater than about 1.2 to 1.4 V. The 10 kΩ resistor limits the forward-biased base-emitter junction current to a safe value when the pot is rotated toward the maximum voltage end.

We get no light at one side of the spectrum with a max of a dimly lit LED (only one) at 1.2v as measured between wiper of pot and neg. terminal of battery.


The 23.3 μA current you measure appears to be way too low. Where is this current measured? Depending on the color of the LED (and hence its forward voltage) the current drawn by the LED could be as little as 10 mA for a 2 V LED forward voltage drop, a 100 Ω current-limiting resistor, and a 3 V battery. If you are using a "coin cell" battery, you probably can get away with using the internal resistance of the battery to limit current through the LED <cringe!> but I can't recommend the practice.

The current was measured from collector through LED. The LED is a green one.

I really do not understand why your results were different using the 500 kΩ versus the 100 kΩ potentiometers. Unfortunately I cannot reproduce your results because I don't have the same components here in Virginia Beach. I will try it out when I get back to Dayton next week. Some things you should check in the meantime: make sure the Darlington connections are correct. It is quite common to have one of the transistors installed backwards. Make sure the transistors are actually working. You should be able to light up your LED by touching just the bottom of the 10 kΩ resistor to the base of each transistor. Disconnect the pot from the circuit so you have just the 10 kΩ resistor, with one end connected to the positive battery terminal, and the other end connected to one of the two bases.
My error more than likely. I am not sure what is up with the transistors - when doing the test you asked above, Q1 lights up the LED dimly, the addition of Q2 base to 10k resistor lights to full brightness. Oddly, Q2 by itself also lights to full brightness.

BTW, the PIC10F206 will run just fine from the 3 V battery and has a spiffy two-input comparator you can use to set the "trip point" of the LDR. I will see if I can gin one up for you when I get back to Dayton.:cool:
Your killing me Hop.... but at this point its looking very tempting. But I must see the analog through. I think there is some learning to be gleamed here!
 

Attachments

  • upload_2015-6-20_16-11-57.png
    upload_2015-6-20_16-11-57.png
    747.9 KB · Views: 157

hevans1944

Hop - AC8NS
... Should I check transistors to verify if that is truly their arrangement?
How are you going to do that, unless you have one of these:

upload_2015-6-20_16-24-7.jpeg

According to the Omegaette HHM93, the 2N3904 that is plugged into it has a beta of 202... whatever that means. I take it to mean this transistor is probably "good"
 
I thought there might be another way, but I had an old dmm with that feature - one was at 327, the other was 331. I should say that is pretty close! So transistors working, but something else is a miss...
 

hevans1944

Hop - AC8NS
Okay. It looks like Q1 may either be bad or installed backwards. Try flipping it around as a quick check and repeat the test with the 10 kΩ resistor providing base drive to Q1 through the base-emitter junction of Q2. Flipping it around probably won't harm it more than it already is, if it is damaged. Q2 looks like it's working fine. You can also test Q1 the same way you tested Q2. Just jumper the emitter of Q1 to the negative terminal of the battery and drive the base with the 10 kΩ resistor connected to the positive battery terminal and the LED in series with the collector, the 100 Ω resistor, and the positive terminal of the battery. All this test does is verify that transistor "works" as a switch. It says nothing about the "gain" of the devices or their suitability to your purpose, However, it has been my experience with similar projects, that two 2N3904 transistors connected in the Darlington configuration will drive the hell out an LED with just a few micro-amperes of base current. You do have to have enough voltage bias to get the base-emitter junctions forward-biased, and that can be tricky with larger resistance values.

This complexity in "getting it right" is just one of many reasons that I seldom "play" with discrete transistors as gain elements any more. To do it right takes a lot of calculations and Monte Carlo analysis of variations in component parameters to build a robust design. Most of that has already been done with COTS op-amps and such, so I just use them and save my headaches for things like PIC programming.

As for SPICE simulations, I hope you are beginning to understand the disconnect there with reality. The proof is always in the breadboard, although SPICE should help you get in the ballpark, component selection-wise, if the model is accurate. The breadboard model is always 100% accurate, as you can verify with sophisticated instruments such as oscilloscopes, multimeters, and other really expensive "stuff" if your designs get really complicated.:D
 
Thanks in advance for all the help and extremely detailed analysis. I have to cook dinner, but I will back in a few hours to pursue this!
 
I am back.... Both Q's (2n3904's) give 0.5mA when separated and tested individually. Interestingly they also give the same result when wired backwards!!
I fished two fresh ones out of the bucket - each tested as 340 hfe. They each acted accordingly, forwards and back giving 0.5mA to the LED as measured between the resistor from positive supply to anode of LED. LED cathode was attached to collector of transistor. The circuit was simply, battery, 10k resistor, transistor and load resistor to LED.

What do you make of this? Is there not enough power in the battery (it was fresh two days ago)? Are the transistors somehow failed despite giving a gain reading on the dmm? Can counterfeit transistors give false hfe?
 

hevans1944

Hop - AC8NS
All good questions! You need to gather some more data. What is the voltage at the terminals of the battery when the LED is lit? What is the voltage across the 100 Ω resistor, the LED, and from the collector to emitter of the transistor? The last three measurements should add up to the battery terminal voltage. Make sure the LED is lit and is carrying the 0.5 mA you measured earlier. The voltage from collector to emitter of a transistor in saturation should be a few tenths of a volt. If there is really only 0.5 mA in the LED, the voltage across the 100 Ω resistor should be about 50 mV. That leaves almost three volts to drop across the LED, which even for a green LED is too large.

One last thing you can do is use a wire jumper between the collector and emitter of Q2, effectively shorting it out and removing its operation from consideration. If the LED doesn't brighten considerably and the current increase to several milli-amperes when you do this, the only remaining element that would limit current in the LED is the internal resistance of the battery. You can measure this quite easily by shorting the anode of the LED to the cathode of the LED (negative terminal of battery), effectively placing only the 100 Ω resistor across the battery as a load. Measure the terminal voltage of the battery with this 100 Ω load. Immediately disconnect the 100 Ω load and measure the now unloaded battery terminal potential. The results of these two measurements will allow you to calculate the internal resistance of the battery when it is under load. Let me know what you find out and we'll go from there.
 
What is the voltage at the terminals of the battery when the LED is lit?
2.96v

What is the voltage across the 100 Ω resistor, the LED, and from the collector to emitter of the transistor?

I am actually using a 220Ω resistor. I didnt want to disturb the other circuit and figured it was close enough.
128mV at resistor, 2.798v at LED, 637mV at CE junction. This doesn't add up to the terminal voltage of the battery - its higher at 3.563v so either the meter is not very good (I doubt this, its an Extech EX330 which got good ratings ;-) or the addition of the meter probes alters the circuit somehow, or?

Current across LED is 0.57mA so voltage across 220Ω resistor (in place of 100) should have been 125.4mV so this confirms the 128mV reading.

I simply took the 220 ohm resistor out of circuit and shorted it on the battery while monitoring the Vdrop - went from 3.0v to 2.5v over about 5 seconds. Current was marked at 11mA.

So internal resistance is 2.5v=0.011(R)
~227Ω

Where does that put us? Is the overall resistance in the circuit too high when coupled with the internal resistance of the battery?

Edit: Found this to be pretty nifty: http://www.peakelec.co.uk/acatalog/jz_dca55.html
 

hevans1944

Hop - AC8NS
2.96v



I am actually using a 220Ω resistor. I didnt want to disturb the other circuit and figured it was close enough.
128mV at resistor, 2.798v at LED, 637mV at CE junction. This doesn't add up to the terminal voltage of the battery - its higher at 3.563v so either the meter is not very good (I doubt this, its an Extech EX330 which got good ratings ;-) or the addition of the meter probes alters the circuit somehow, or?

Current across LED is 0.57mA so voltage across 220Ω resistor (in place of 100) should have been 125.4mV so this confirms the 128mV reading.

I simply took the 220 ohm resistor out of circuit and shorted it on the battery while monitoring the Vdrop - went from 3.0v to 2.5v over about 5 seconds. Current was marked at 11mA.

So internal resistance is 2.5v=0.011(R)
~227Ω

Where does that put us? Is the overall resistance in the circuit too high when coupled with the internal resistance of the battery?

Edit: Found this to be pretty nifty: http://www.peakelec.co.uk/acatalog/jz_dca55.html
Those three voltage measurements add up to exactly 3.563 V. Isn't that the battery terminal voltage you measured? Or am I missing something here?
The internal resistance of the battery appears to be limiting the current through the LED. The LED forward voltage is high at 2.798 V because it isn't drawing enough current, only 0.57 mA. The battery terminal voltage is probably dropping like a rock too if it was originally 3 V and dipped to 2.5 V with a 220 Ω load. Yeah, the 2.798 V across the LED is about all the battery can push out. You need a beefier battery or a different circuit.

What exactly are you trying to do? Turn on a night-light when it gets dark? I bet I could do that for a dollar with a PIC!:eek:
 
Those three voltage measurements add up to exactly 3.563 V. Isn't that the battery terminal voltage you measured?
The battery measured 2.96v. I just rechecked it and it says 3.03v

So mystery solved! Thanks for the walkthrough and analysis. There is simply not enough current being provided at the voltage available to drive the circuit. Strange as I thought the whole purpose of the transistor was to amplify, thus a small signal in microamperes could be used to "gate" a larger current that is why I thought this circuit would work as well as the one I posted earlier in post #23.

What exactly are you trying to do? Turn on a night-light when it gets dark? I bet I could do that for a dollar with a PIC!:eek:
Oh boy, you beat it into me! Ok, Marty, take me Back to the Pic!
I wanted to use the LDR switch to turn on my timing circuit. The whole thing may be able to be built on one small pic - one comparator to check the analog output of the LDR - this can be the switch portion and then the timing can be handled internally by the pic's internal OSC function and finally one output to turn the LED on. There done - super simple design, minimum components, fairly inexpensive.

Learning MPLabs, making it through the 100+ page datasheet, months learning basic CS and python and still not being able to program a pic, well.... you can see why I needed an analog break LOL :rolleyes::eek::D
 
Top