Using LDR

Thread Starter

lordeos

Joined Jun 23, 2015
33
Hi guys,

I want to start a simple experiment using an LDR to turn on a LED. But along the way i have some questions

1) When i read about LDR's they are used for dark/light detection and according their change of resistance. Mainly they are used to switch off lights during day for electricity reduction. But this part is unclear for me ...

- as i understand it during the day the resistance is low and the correct flows trough the LDR and not the Lightbulb/LED , so a current is flowing !!!. If i hook this up to a battery my battery would be drained even during the day. Am i correct or do i miss something ?

2) Calculating the resistance values. I found an article which explained how to calculate the fixed resistance value ... Square root (min value LDR * max Value LDR). In all the formula's i never see the amount of current that is needed in the circuit and based on that the calculation of the resistor.

- If my voltage ranges from for example 0 to 8 volts do i have to put a resistor in front of the LED to limit the amount of current (20MA for LED). Is the series resistor in front of the LED the one that decides how much current flows in the circuit ?

Thanks for the help
Mike
 

DerStrom8

Joined Feb 20, 2011
2,390
Hi Mike,

In order for an LDR to be used to switch off a light during the day and switch it on during the night, the logic must be inverted. This is commonly done using a circuit like this:



When the LDR has a low resistance (in the light, during the day), the base of the NPN transistor is held close to ground (0V) and stays switched off. This prevents current from flowing through the LED.

In order to calculate the current limiting resistor for an LED, you must know the LED forward voltage drop. The formula is:

R = (Vs - Vf)/If

where R is the resistance you're looking for, Vs is the source voltage, Vf is the forward voltage drop of the LED, and If is the current (20mA for your LED). When using the above circuit, most of the current will be flowing through the current limiting resistor, through the LED, through the transistor (C-E), then to ground. You will have some current, however, flowing through the resistors at the left (above the LDR) whether the LED is on or off. Something to keep in mind. Running a circuit like this for an extended time off of batteries will indeed drain them.
 

Thread Starter

lordeos

Joined Jun 23, 2015
33
Hi derstrom8,

Thx for the detailed explanation. The circuit with the transist is also one of the circuit setups i encountered. However to begin with the project i'm looking at the most simple designs first (understand them) and the improve on them.

Currently i'm looking at this simple design (screenshot included as attachment "circuit.jpg"). Hence my question that in this design wether the LED is turned ON or OFF current is flowing in the circuit, either trough the top resistor and LDR or trough the LED, am i correct ???

But how much current is flowing in OFF mode trough the resistor and LDR ??since i never see the value of the resistor being calculated based on the amount of current. With a led a max of 20MA must go trough the circuit. so i believe i must put a resistor on the output infront of the LED ... Because with a 9V battery my range is from +- 0V trough 8.5 V --> the LED only takes 2V and 20Ma, Am i correct ??

thx for the help
 

Attachments

DerStrom8

Joined Feb 20, 2011
2,390
Hi derstrom8,

Thx for the detailed explanation. The circuit with the transist is also one of the circuit setups i encountered. However to begin with the project i'm looking at the most simple designs first (understand them) and the improve on them.

Currently i'm looking at this simple design (screenshot included as attachment "circuit.jpg"). Hence my question that in this design wether the LED is turned ON or OFF current is flowing in the circuit, either trough the top resistor and LDR or trough the LED, am i correct ???

But how much current is flowing in OFF mode trough the resistor and LDR ??since i never see the value of the resistor being calculated based on the amount of current. With a led a max of 20MA must go trough the circuit. so i believe i must put a resistor on the output infront of the LED ... Because with a 9V battery my range is from +- 0V trough 8.5 V --> the LED only takes 2V and 20Ma, Am i correct ??

thx for the help
The circuit you attached is not an on/off circuit. It is a voltage divider. The more light there is that hits the LDR, the closer to 0V the output voltage gets. The purpose of the transistor was to switch on at a specific output voltage from the divider. An even better option than the transistor would be to use a comparator, but that's a whole other animal. In your circuit, the output will range between (theoretically) 0V at full light (LDR resistance = 0 ohms) and



where Vs is the source voltage,
is the maximum resistance of the LDR, and R is the value of the fixed resistor.

If you want to simply turn something on and off with the above circuit, you'll need to convert that analog voltage to a digital signal (either "ON" or "OFF"). That's what the transistor was used for.
 

Thread Starter

lordeos

Joined Jun 23, 2015
33
But if during dark the LDR has a high resistance and the voltage on the output rises to above the forward voltage drop of the LED then a current limiting resistor and LED directly attached to the output could be turned on, correct ?

If there is enough light the the voltage drops on the output to below the forward voltage drop of LED and the LED is turned OFF, correct ?
 

ian field

Joined Oct 27, 2012
6,536
The circuit you attached is not an on/off circuit. It is a voltage divider. The more light there is that hits the LDR, the closer to 0V the output voltage gets. The purpose of the transistor was to switch on at a specific output voltage from the divider. An even better option than the transistor would be to use a comparator, but that's a whole other animal. In your circuit, the output will range between (theoretically) 0V at full light (LDR resistance = 0 ohms) and



where Vs is the source voltage,
is the maximum resistance of the LDR, and R is the value of the fixed resistor.

If you want to simply turn something on and off with the above circuit, you'll need to convert that analog voltage to a digital signal (either "ON" or "OFF"). That's what the transistor was used for.
Professional circuits usually use a Schmitt trigger circuit to give clean switching at dawn and dusk, if you used a relay with a non-Schmitt circuit, you'd have relay chatter problems at dawn and dusk. Unfortunately the web seems to be swamped with basic non-Schmitt circuits!

Somewhere I have a hand trace of a professional circuit, it uses an IR photodiode and apparently worked just fine like that.

AFAIK: the LDrs which contain cadmium sulphide are prohibited by the RoHS directive, they're getting pretty scarce. They're coming in from China via Ebay - I ordered a couple of packets while I still could.
 

DerStrom8

Joined Feb 20, 2011
2,390
But if during dark the LDR has a high resistance and the voltage on the output rises to above the forward voltage drop of the LED then a current limiting resistor and LED directly attached to the output could be turned on, correct ?

If there is enough light the the voltage drops on the output to below the forward voltage drop of LED and the LED is turned OFF, correct ?
That is true, though that's really not a very good way to do it. I suppose if your fixed resistor is chosen well you could do it that way, but that will not give you the on/off functionality. As it gets darker out the LED will gradually grow brighter. This may sound like a good idea in some applications, but it will drain your batteries much more quickly because the LED will likely be "on" for a longer amount of time. It does not simply "switch on" when the forward voltage drop is reached, it will start off very dim. LEDs are current-driven devices, so you need a steady current to keep the brightness steady. Consider if the output from the voltage divider is 2.0V (let's just say the forward voltage drop of your LED is 1.7V), and you have a 100-ohm resistor. The current flowing through your LED would be:

(2.0V - 1.7V) / 100 ohms = 3mA

You would only have 3mA flowing through your LED, which probably won't even make it bright enough to see. Suppose your voltage divider goes up to 3V. Your current will be:

(3.0V - 1.7V) / 100 ohms = 13mA

The brightness will vary, even if you meet the forward voltage drop of your LED.

What exactly are you trying to do with this circuit? Generally if you want the output that is either full-on or full-off you'd want to use a MOSFET (not a BJT) or a comparator.
 

DerStrom8

Joined Feb 20, 2011
2,390
Professional circuits usually use a Schmitt trigger circuit to give clean switching at dawn and dusk, if you used a relay with a non-Schmitt circuit, you'd have relay chatter problems at dawn and dusk. Unfortunately the web seems to be swamped with basic non-Schmitt circuits!

Somewhere I have a hand trace of a professional circuit, it uses an IR photodiode and apparently worked just fine like that.

AFAIK: the LDrs which contain cadmium sulphide are prohibited by the RoHS directive, they're getting pretty scarce. They're coming in from China via Ebay - I ordered a couple of packets while I still could.
Schmitt trigger = comparator.

I heard that as well, about LDRs. They are definitely becoming more difficult to find. I think they have a modern alternative that is RoHS-compliant, but I'm not sure. I'd have to do some research.
 

ian field

Joined Oct 27, 2012
6,536
Schmitt trigger = comparator.

I heard that as well, about LDRs. They are definitely becoming more difficult to find. I think they have a modern alternative that is RoHS-compliant, but I'm not sure. I'd have to do some research.
A comparator doesn't become a Schmitt trigger until you add positive feedback.

The only alternative I can think of to Cd-S, is cadmium selenide - which is still based on the highly toxic cadmium.

There were lead and zinc photo sensitive materials, but they were no match for cadmium and were never very commercial.

For quite a long time, professional manufacturers have been adapting circuitry to get by with silicon detectors that are better suited to IR.

Somewhere I have a hand trace of a commercial "dusklight" outdoor lighting fixture that doesn't waste enenergy when the sun shines - it uses a fairly common photodiode similar to the ones in TV front panels for the remote, I think it uses a LM358 - one section set up as a comparator and some positive feedback to make it a Schmitt, the other section drives the triac gate.

The schematic was on this PC, but W10 search hasn't found it yet!
 

DerStrom8

Joined Feb 20, 2011
2,390
A comparator doesn't become a Schmitt trigger until you add positive feedback.
Fair point. Guess I'm a bit rusty on my op-amp circuits :p

The only alternative I can think of to Cd-S, is cadmium selenide - which is still based on the highly toxic cadmium.

There were lead and zinc photo sensitive materials, but they were no match for cadmium and were never very commercial.

For quite a long time, professional manufacturers have been adapting circuitry to get by with silicon detectors that are better suited to IR.

Somewhere I have a hand trace of a commercial "dusklight" outdoor lighting fixture that doesn't waste enenergy when the sun shines - it uses a fairly common photodiode similar to the ones in TV front panels for the remote, I think it uses a LM358 - one section set up as a comparator and some positive feedback to make it a Schmitt, the other section drives the triac gate.

The schematic was on this PC, but W10 search hasn't found it yet!
Hmm, I found this LDR that is still based on the CdS chemistry, but is RoHS-compliant:

http://www.digikey.com/product-sear...e=1&rohs=1&quantity=0&ptm=0&fid=0&pageSize=25

I suppose there's not enough in there to exceed the limits for RoHS. I doubt you'll be able to find a larger one that's also RoHS-compliant.

You're right, I'm not seeing any alternatives.
 

ian field

Joined Oct 27, 2012
6,536
Fair point. Guess I'm a bit rusty on my op-amp circuits :p



Hmm, I found this LDR that is still based on the CdS chemistry, but is RoHS-compliant:

http://www.digikey.com/product-sear...e=1&rohs=1&quantity=0&ptm=0&fid=0&pageSize=25

I suppose there's not enough in there to exceed the limits for RoHS. I doubt you'll be able to find a larger one that's also RoHS-compliant.


.
RoHS is riddled with random exemptions - its entirely possible that a certain standard of encapsulation qualifies for an exemption, the ones out of China are usually plated onto a ceramic disk and given a coat of lacquer - a tiny scratch could expose toxic material.

Some months ago I found some on a mainstream suppliers website with a; "not ROHS compliant" warning notice.
 

Thread Starter

lordeos

Joined Jun 23, 2015
33
@DerStrom8

I got the idea with the change in brightness from the LED. In the circuit with a transistor wouldn't this be the same case. Since my output voltage varies from (theoreticcal) 0 tot 8 V my base current also constantly varies ?

- I suppose i also need a resistor in front of my transistor to drop to 0.7V, correct ? So i assume i calculate this resistor on the highest voltage available on the output ? , correct ?

Does the fluctuation in base current (output voltage going from 0 V tot +-Vs) effects the brightness of my LED ? --> with for example an transistor HFE of 100 the current trough my LED resistor will accordingly with the change in base current ?

thx
 

ScottWang

Joined Aug 23, 2012
7,400
Hi Mike,

In order for an LDR to be used to switch off a light during the day and switch it on during the night, the logic must be inverted. This is commonly done using a circuit like this:



When the LDR has a low resistance (in the light, during the day), the base of the NPN transistor is held close to ground (0V) and stays switched off. This prevents current from flowing through the LED.

In order to calculate the current limiting resistor for an LED, you must know the LED forward voltage drop. The formula is:

R = (Vs - Vf)/If

where R is the resistance you're looking for, Vs is the source voltage, Vf is the forward voltage drop of the LED, and If is the current (20mA for your LED). When using the above circuit, most of the current will be flowing through the current limiting resistor, through the LED, through the transistor (C-E), then to ground. You will have some current, however, flowing through the resistors at the left (above the LDR) whether the LED is on or off. Something to keep in mind. Running a circuit like this for an extended time off of batteries will indeed drain them.
In series with a resistor between B of bjt and the common pin of 10K and LDR, that will more easy to turn off the bjt.
 

DerStrom8

Joined Feb 20, 2011
2,390
@DerStrom8

I got the idea with the change in brightness from the LED. In the circuit with a transistor wouldn't this be the same case. Since my output voltage varies from (theoreticcal) 0 tot 8 V my base current also constantly varies ?
To an extent, yes you are correct. It's difficult to use a BJT to turn something directly on or directly off using an analog signal on the base. That's why I was recommending a comparator, and Ian was suggesting a Schmitt trigger.
 

ian field

Joined Oct 27, 2012
6,536
To an extent, yes you are correct. It's difficult to use a BJT to turn something directly on or directly off using an analog signal on the base. That's why I was recommending a comparator, and Ian was suggesting a Schmitt trigger.
Just off the cuff - for linear control of the LED by a LDR, maybe put the LDR in the emitter circuit of a single transistor current limiter.

At good light intensity, an LDR can get down to a few hundred Ohms, so you'd need a pretty high base voltage on the constant current transistor, or follow it with some form of current multiplier.

Its basically a common base stage, so the collector current will be just a smidge less than the emitter current, I'd suggest using a PNP emitter follower to give greater current capability to the voltage developed across the collector resistor.
 
Top