Everything for Electronics

Tech Forum





July 2014

Photoresister Switcher

I would like to know if I have correctly connected the photoresistors (CdS photocells) shown here in order to turn OFF during the day and to  turn ON during the night the two LED circuits attached to them. (If not, please indicate by a new diagram.)

Also, I would like to know:
  a) If any photoresistor would work?
  b) What would the optimum dark/light resistance values be for such a photoresistor?
  c) How would I calculate the values  (any formula?) from the transistor side (2N2222) that would best fit this ON/OFF photoresistor switcher?

#7141
Nate
via email



Answers

Depending on the current required by the different LED loads, the value of the Cds sensor is critical. In addition, you should include hysteresis to snap the load ON or OFF, rather than have it operate erratically at the dawn or dusk threshold. If the Cds sensor has a large value at the critical threshold, there will not be enough current to bias the transistor ON to it’s saturation state.

To remedy this problem, I have included two circuits which solve your issues. Figure 1 uses two transistors with positive feedback to create the needed hysteresis and gain to drive an output stage that provides 100 mA current limiting in case your load circuit shorts out.

Figure 2 circuit uses a 4093 quad-nand schmitt trigger (that has 1 volt hysteresis) and drives the same output stage as circuit one. The second circuit is probably the easiest one to implement, but requires the fourteen-pin 4093 IC. You will still need to select the a Cds cell that has around a megohm of resistance when dark and 10K or less resistance when light. Hope this helps you.

Ron Hoffman
Solon, OH

Power supply not specified.
Top circuit operating range using common 555 is from 5 to 15 volts by data sheet. IC 4017 data sheet specifies current drive limit about one milliamp. Some amplification required to drive LED at 10 to 20 milliamps


Bottom circuit requires at least 12 volts to operate series string of LEDs. Three LEDs in series add up to: G(3.2) + R(1.8) + G(3.2) = 8.2 volts. Requires at least 12 volt power to allow for current limit resistor voltage drop. LEDS will load down ring oscillator as shown. Need high impedance buffer to isolate LEDs from Resistor Capacitor time constant.
 

a) The logic of operation of CDS photocells is:
No Light = high resistance
Max Light = Low resistance
 

As shown, that logic will tend to turn on the transistor during the daytime and turn it off during the night. Simple solution is to swap 100K resistor with photoresistor in circuit. You will probably need to adjust resistor values to operate the way you require. You also need to limit current into the base of the transistor.


Not every photoresistor will work as the range of resistance variation must match the required transistor bias. You could measure the resistance of the photo resistor with an ohmmeter for both dark and light environment or look up the data sheet from Digikey, Mouser or the manufacturer.

See above circuit from Linear Technology Spice program.
 

Some CDS photo resistors are about 200K ohms in the dark and about 4K ohms in light. If the range is less, the transistors will always stay on. Measure the photoresistor in light with an ohmmeter. Cover the photo resistor to measure dark resistance.
 

b) Optimum bias would provide about 0.6 to 1.0 volts or more at the transistor base (relative to emitter) to turn on and less than that threshold to turn off. Depends on required current from collector to emitter.


You did not specify your power supply voltage. The 555 IC works best from about 5 to 15 volts. Three LEDS in series need at least 12 volts as shown.


Two red LEDS and 470 ohm minus (diode drops and IC drop)
(12 - (1.8 + 1.8)volt-1 -1 )= 6.4 volt
Max current = 6.4 volt / 470 ohm = 14 milliamps


The three LEDS with 1K resistor operating at 10 milliamps would require
VDC = (0.01 Amp * 1000 ohm)+(1.8)R+(3.2)G+(3.2)G   8.2
12 - 8.2 = 3.6 volts   3.6 volt/ 470 ohm = 7.6 milliamps
R8 is 330 ohm for 10 milliamps


Current limit for 4017 source about one milliamp out. need transistor drivers.
470 ohm drive about 14 milliamps


Ring oscillator may not work as LEDs are loading RC timing, transistor emitter followers may help. Linear Technology Spice program can be used to experiment with different values.
Calculation for transistor bias
R1 = base to power bus VCC
R2 = base to ground or common


Vbase = VCC * (R2 / (R1 + R2) )
This is first approximation as some current will go into base of transistor. Switch point is about in the range from 0.6 to 1.0 volts
High on , low off
Look up Ohm's law
 

See attached circuits
The .PDF extension is directly viewable. The .asc format is editable within Linear Technology Spice. LTSpice is free and downloadable from Linear Technology web site


Adjust the photo resistor value for the version you have at light and dark environment. Verify that the LOAD has a reasonable current (ON value) of about 10 to 100 milliamps or negligible current (OFF value)

Edward Wade
via email

The two circuits Nate submitted are configured to turn the LED sequencers ON during the day and OFF at night. This is because the resistance of the photocell decreases as light falling on the photocell increases, causing increased current flow from the base of the transistor to the positive power supply rail. The increase in base current will cause the transistor to conduct and supply current to the LED sequencer circuits in daylight. To modify the circuits so they turn OFF during the day and ON at night, swap the photocell and the resistor so that decreasing photocell  resistance will pull the base of the transistor toward ground, turning the transistor off in the daytime. The fixed resistor will turn the transistor on at night when the resistance of the photocell is high compared to the resistor. The circuit can be improved (see new diagram in Figure 1). Two issues are solved by the improved circuit.

Figure 1
1) Nate is using a 2N2222 transistor as a low side switch to control current to the light sequencer circuits. A MOSFET makes a better switch because it has a very high OFF resistance and a very low ON resistance, so more of the supply voltage is applied to the light sequencer circuit and less power is wasted in the transistor. For this reason, I replaced the 2N2222 transistor with a low cost IRF510 N-channel power MOSFET.


2) The other problem with Nate's circuits is they won't turn on and off quickly like a mechanical switch. At dawn and dusk — when the light changes gradually — the current through the transistor will also change gradually. The switching action should happen fast when a predetermined light threshold is crossed; a Schmitt trigger circuit is needed for that. The improved circuit contains four Schmitt trigger NAND gates in a single 4093 CMOS IC. Only one NAND gate is needed, so the other inputs should be tied to V- to prevent instability.


The 4093 has a hysteresis band which keeps the sequencer circuit from receiving rapid bursts of current at dawn and dusk when the control voltage hovers near the tripping point. The output of the 4093 drives the IRF510 MOSFET which switches the current to the LED light sequencer circuit on and off. The MOSFET is driven into saturation by the 4093 Schmitt trigger to provide clean switching and maximum current to the LED sequencer circuit. Next, the answers to questions a, b, and c.


a) Will any photoresistor work?
Most photocells will work with the improved circuit, but don't confuse a photocell (which is a photoresistor) with a phototransistor. I've included a pot wired as a variable resistor; this will adjust the voltage divider to match the photocell characteristics. To set the pot, go outside in the twilight near sunset and adjust the pot until the circuit turns ON, then back off slowly until it turns off. The LED sequencer circuit should then turn on at sunset and off at sunrise.


b) What are the optimum photoresistor light/dark resistance values?
The resistance of most photocells varies from a few hundred ohms (or less) in direct sunlight to a megohm (or more) in total darkness. The optimum resistance of R1 for a given photocell can be calculated using Ohm's Law, but the adjustment pot in the improved circuit makes it compatible with most CdS photocells.


c) What formula will calculate the optimum component values?
The 2N2222 transistor used in Nate's circuits is a current operated device which should be explained in terms of current. The improved circuit uses voltage controlled components. This explanation is only for the improved circuit.


Inputs 1 and 2 of the 4049 are tied together and connected to a voltage divider consisting of photocell PC1 and resistor R1, which are connected in series between V+ and V-. To predict circuit operation in different lighting conditions, calculate the voltage from V- to the point where R1 and PC1 join using Ohm's Law, and then compare this voltage to the upper and lower trip points of the 4093. The lower trip point will turn the LED sequencer circuit on because the 4093 is an inverter, which will drive the gate of the MOSFET to V+ when the 4093 input is low. When the MOSFET conducts, it will ground the LED sequencer circuit to V-. The lower trip point of the 4093 is +3.9 volts when V+ is 10 volts and the upper trip point is +5.9 volts.


EVENING CONTROL: The voltage across R1 must fall below 3.9 volts to turn the LED sequencer on at sunset; this example uses 3.5 volts to be well below the threshold. To calculate the optimum resistance of R1, it's necessary to know the resistance of PC1 in the twilight hours of sunset or dawn.


This example assumes the resistance of PC1 is 100K at sunset. The voltage drop across both resistors must add up to V+. So, if V+ is 10 volts, then 6.5 volts must be dropped across 100K (PC1) for 3.5 volts to be dropped across R1. Operation of the improved circuit is explained in four steps.


STEP 1: Calculate the current through the voltage divider at sunset.
If we know the resistance of PC1 and the voltage across it, then we can calculate the current through PC1 with Ohm's Law (I = E/R). Plugging in the known values, I = 6.5/100,000 = 65 µA. This is a series circuit, so 65 µA also passes through R1.


STEP 2: Calculate the resistance of R1.
We know the current through R1 is 65 µA and the voltage across R1 is 3.5 volts, so we can use another form of Ohm's Law (R = E/I) to calculate the resistance of R1. R1 = 3.5/.000065 = 53846 ohms. To check this, use E = IR, E = .000065 (53846) = 3.499 volts; 3.5 volts is under the lower trip point of the 4093, so output pin 3 of the NAND gate will go high, driving the gate of the IRF510 MOSFET to V+ through R2. This causes the MOSFET to conduct and provide a current path from V- to the LED sequencer circuit.


MORNING CONTROL: At the soft light near daybreak, a typical photocell has a resistance around 10K. If we use the value of 53.846K previously calculated for R1 and assume a PCI resistance of 10K at dawn, then the total resistance of PC1 + R1 is 10K + 53.846K = 63.846K.


STEP 3: Find the daytime current through the voltage divider.
If V+ is 10 volts, the current through the series resistances PC1 and R1 at sunrise can be calculated with I = E/R. I = 10/63846 = .0001566 A, or 157 µA.


STEP 4: Find the daytime voltage drop across R1.
Now that we know the morning current through R1 and the resistance of R1, we can calculate the morning voltage drop across R1 with E = I/R; E = .0001566 (53846) = 8.43. A daytime voltage drop across R1 of 8.43 volts is well above the 5.9 volt upper trip point of the 4093, so the output of the inverting 4093 will go low, grounding the gate of the MOSFET to V- and turning off current to the LED sequencer circuit. During the day, the input to the 4093 should vary between 8 and 10 volts, keeping the LED sequencer circuit turned off.

Ed Gore
Panama City, FL