Llight operated switches are not new ideas, but neither are they the easiest items to purchase ready-made. Originally, this unit was built to switch on the author's outside Christmas lights when it became dark. No doubt readers will have other uses in mind. One such might be as a security porch light controller.
This unit can control up to 500W of lighting. However the load must be resistive, i.e. normal lamps. Lights containing transformers are not suitable. The load is switched at the mains zero-crossing point, to minimize radio interference.
The light level required for the unit to switch on or off is fixed, but since this is set by a single resistor value it can easily be altered. A degree of hysteresis is included to reduce the chance of the unit being affected by the light it is controlling. Reasonably careful siting, though, will still be necessary to prevent the controlled light from directly illuminating the sensor.
The PCB is designed to fit behind a single electrical blanking plate, with a hole to allow light to reach the photocell. This plate can be fitted to a single 25mm surface box, giving a cheap and tidy wall mounting case. For my original purpose the unit was placed on a window sill with the photocell facing outwards. If the unit is to be used outdoors or exposed to moisture, a sealed waterproof case will be needed.
THIS CIRCUIT OPERATES AT POTENTIALLY LETHAL MAINS VOLTAGES. IF YOU ARE IN ANY DOUBT ABOUT YOUR ABILITY TO CONSTRUCT IT SAFELY, PLEASE OBTAIN ADVISE FROM A SUITABLY QUALIFIED OR EXPERIENCED PERSON. ALTHOUGH THE CONSTRUCTION IS STRAIGHTFORWARD, THIS PROJECT IS NOT SUITABLE FOR BEGINNERS.
The low voltage power supply is derived from the mains without isolation. The AC input is clamped to -15V and +0.6V relative to neutral by D1, a 15V zener diode. The remaining voltage is dropped by C1. A capacitor is used because it dissipates virtually no power (unlike a resistor) due to the 90 degree phase shiftbetween voltage and current. The -15V pulses are rectified by D2 and smoothed by C2 to give a steady -15V supply rail.
C1 must be a Class X component rated for continuous connection directly across the mains. These devices are normally sold as suppression components. A normal high voltage capacitor is NOT suitable and MUST NOT BE USED.
R1 is a surge limiting component. This reduces the in-rush current if the unit is powered up when the mains cycle is near a peak. Use a small wirewound resistor, because these have better surge handling than carbon or metal film.
IC1a, IC1b and associated components produce the zero-crossing pulses. Refer to the timing diagram shown in figure *. The inputs of IC1a are normally held low by R3, and the output will be high. When the mains cycle (waveform 1) rises above about 40V, the voltage on the input will be sufficient for the gate to switch and the output of will go low. When the voltage falls below 40V at the end of the positive half cycle, the output of IC1a will go high again (waveform 2). Diodes D3 and D4 clamp the waveform to the supply rail extremes, protecting IC1 from excessive input voltages.
The input on pin 6 of IC1b is connected similarly, but is normally held high by R5. This gate therefore operates on the negative half cycles. The differing values of R3 and R5 are due to the fact that one gate is biased to neutral and the other is biased to 15V below neutral. The other input of IC1b is connected to the output of IC1a, so that this gate sums the two half cycles, giving the zero crossing waveform shown (waveform 3). This is inverted by TR1, giving a signal which pulses high around the zero crossing points.
IC1 has Schmitt trigger inputs. This ensures reliable switching at about the mid-position between the supply rails (50%), with a varying voltage input. The Schmitt effect also gives a degree of hysteresis. Normal logic gates (such as the 4011) regard anything between 30% and 70% levels as indeterminate, and give an unpredictable output.
IC1c and IC1d form a two input AND gate. One input (pin 9) is driven by the previously mentioned zero-crossing pulses. The output (pin 11) will follow this only if the level on the other input (pin 8) is above 50% of the supply voltage. The voltage here is determined by the light level reaching LR1 (ORP12).
LR1 is a Light Dependent Resistor (LDR). The resistance of this device decreases as he light level increases. In bright light the resistance can be as low as 100R, while in darkness it may exceed 10M. In this circuit LR1 is half of a potential divider, the other half being R8. The switching point will be when the resistance of LR1 is about equal to R8. The value of 100K was found to be about right on the prototype, but R8 can be varied to suit your needs.
A preset could be fitted, but this must NEVER be adjusted with the power on. For this reason a fixed resistor was felt to be the safer choice. Presets are just asking to be twiddled with by someone non-technical, which in this case could be lethal!
The voltage from the potential divider is damped by C3, to reduce the chances of the unit being triggered by rapid fluctuations in the light level, such as shadows caused by people or animals passing.
When the light level is low enough to cause the unit to switch on, the positive zero-crossing pulses at the output of IC1d are coupled back to the potential divider by D7 and R9. These are smoothed by C3, giving a voltage increase. This gives the circuit hysteresis, as mentioned previously. The light level required for the unit to switch off again is higher than the level that caused it to switch on. Thus if some light from the lamp being controlled reaches the LDR, the unit will hopefully not switch off again. There is a limit to this effect however - if the controlled light shines directly onto the LDR, the lamp will probably start flashing.
The positive pulses on the output of IC1d switch on transistor TR2, which in turn drives triac TR3. The triac is therefore driven only briefly at around the zero crossing points of the mains. Once the triac is triggered it will remain on until the current passing through it drops below a minimum value. This will occur as the mains cycle reaches the next zero crossing point. If the lamp still needs to be lit the triac will be triggered again at this point.
If the load were inductive, the current passing would be out of phase with the voltage. This basic zero-crossing arrangement would not work correctly in this case. For this reason inductive loads cannot be driven by this unit.
The arrangement used ensures that the lamp is not switched on near the peak of a mains cycle. If this were to happen the surge could cause momentary radio interference. Although not a major problem with a unit that switches infrequently, it was felt best to do the job properly.
Another important advantage of applying only brief drive pulses to the triac is that the average current consumption from the low voltage supply is much lower. This enables the simple power supply arrangement described earlier to be used.
Construction is very straight-forward because all the components fit onto the PCB. This single sided PCB is available form the EPE PCB service (code *), see page *. The component overlay and track layout is shown in figure *. You will need to drill out the two PCB mounting holes to 4mm and the triac mounting hole to 3mm.
Assembly should cause no problems to constructors with some experience. Do not forget the single link below TR1. The triac (TR3) should be bolted to the PCB with an M3 nut and screw. A number of holes are provided for C1 and C2 to enable various size components to be accommodated. SK1 and SK2 are PCB mounting terminal blocks and should be fitted with the cable entries outwards.
IC1 could be fitted in a socket if you wish, but this is not really necessary since the IC is cheap and reliable. In any case fit the IC last. The LDR (LR1) should be fitted to the track side of the PCB. Do not solder this until you have sorted out the PCB mounting.
Double check the PCB assembly when you have finished, particularly around C1, R1, D1, D2 and TR3. Mistakes on a mains powered circuit like this can cause a horrible mess when the power is applied!
Panel and Case
The front of the case is a single electrical blanking panel. You will need to make a 13mm (1/2" approx) hole in the centre of this for the LDR to protrude through. If you do not have a big enough drill bit or the chuck of your drill will not accommodate one, drill the biggest hole you can and then either file it out or mount the LDR behind it.
The plastic used for these blanking panels is very brittle. It may be worth buying two if you have to travel any distance - just in case! You should get the mounting screws with it. Try to get a panel that is plain on the inside, some have extra moldings and bits which may get in the way. It is not easy to tell when it is mounted on cardboard display packing in a DIY super-store - so try a local electrical shop or trade counter instead.
The panel may be carefully drilled using a hand drill or a SLOW electric drill. A normal DIY power drill will be too fast. A rechargeable cordless drill is ideal since it is relatively slow with good torque - one of these tools is ideal for electronics work.
I found it best to drill a small pilot hole (about 3mm or 1/8") and then go straight to the large size. If you increase the size in stages, the bit is more likely to catch and break the panel. Take it VERY gently when you near the point of breaking through. A WorkMate is useful to hold the panel while drilling.
On the prototype the PCB is held with screws and spacers, however this arrangement is not recommended for safety reasons unless you use the nylon spacers with a threaded insert at each end. A much better solution would be to use two self-adhesive PCB stand-offs. If the board feels unsteady, use two more self-adhesive stand-offs with the top bits cut off, to support the top and bottom of the PCB.
The rear of the case is a 25mm (socket depth) single electrical surface box. Before buying this, make sure it has only two threaded holes for the front panel screws. Some boxes have four of these, one on each edge - the top and bottom ones will foul on the PCB. You will need to remove one or two knock-outs on the side or back for the cables to enter.
Since there is nothing to adjust, testing simply involves seeing if the unit works. Remember that the whole PCB is at mains voltage and is therefore potentially lethal.
Fit the PCB into the case before switching on. Connect one end of length of two core mains flex to the SK1 terminals (Live nearest to edge of PCB) and connect the other end to a 13A plug fitted with a 3A fuse. Connect another length (at least 1 metre) of two core cable between the SK2 terminals (Live to edge of PCB again) and a lampholder. Fit a 60W lamp in the holder. Position the lamp holder about a metre away from the LDR.
Connect the unit to the mains, preferably via an earth leakage or residual current circuit breaker (the type intended for power tools), and switch on. Hopefully nothing dramatic happened!
Place your hand over the LDR. After a couple of seconds the lamp should come on. Move your hand away and it should go off again. That's all there is to it. Hopefully your unit worked fine - there isn't much to go wrong!
Installation will vary depending upon what you are using the unit for. My unit is mounted on a piece of wood next to a single 13A socket. Three core mains cable was used, the Live and Neutral pass through this unit, and the Earth connects directly to the socket. The other end of the cable terminates in a 13A plug with a 3A fuse.
It is important to use three core cable if you are using this unit to control a 13A socket, even if you only intend to a load that does not need an earth. At some future point someone may plug an earthed load into the unit.
The prototype was sited indoors on a window sill, with the lead to the outside Christmas lights passing through a hole in the window frame.
The unit can be more permanently installed if required. However it is not suitable for permanent connection to household wiring. This is due to wiring regulations, not a fault with this unit. The unit must always be connected to the mains via a 13A plug and socket, or some other method than can be properly isolated such as a double pole switch.
Do not assume that a load is safe if it is switched off by this unit. This unit switches the neutral line, to reduce the potential difference between the circuit and earth. Also there is sufficient leakage through an untriggered triac to give a fatal electric shock. When working on this unit or a load connected to it, the power must be properly isolated (live and neutral disconnected).
Take care to position this unit so that light from the lamp it is controlling does not fall directly on the LDR. You may be able to mount the unit on a different side of the building for example. Street lamps have the light sensor mounted on the top, above the lamp which shines downwards. You may be able to arrange something along these lines.
If you are mounting the unit outdoors you will need to arrange a suitably waterproof case. The suggested case is suitable for indoor use only. It is imperative that the circuit cannot get wet. The area where the light gets to the LDR may be difficult so seal effectively. A sealed plastic case (to IP65) with a clear lid would be a tidy solution. Use sealed cable glands for the cable entries. Drill a small (2mm) breather hole at the lowest point in the case, to prevent condensation and let out any moisture which might get in despite your efforts.
Resistors (all 0.25W 5% or better unless stated)
R2,R4 1M0 0.5W
250V AC Class X
C2 100u 25V axial elect
C3 22u 25V axial elect
CMOS Quad NAND Gate
TR1,TR2 BC548 Transistor (2 off)
TR3 C206D Triac
D1 BZX79C15 15V Zener
D2 1N4002 Rectifier Diode
D3 to D7 1N4148 Diode (5 off)
Way PCB Terminal
LR1 ORP12 Light Dependent Resistor
Single electrical blanking plate
Single 25mm electrical surface box
Self-adhesive PCB stand-offs (4 off)
13A plug with 3A fuse
Cable etc as required for installation