Silicon ChipSunset Switch For Security & Garden Lighting - June 2003 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Low voltage halogen lamps are huge power wasters
  4. Order Form
  5. Feature: A Look At The 2003 Mars Rovers by Sammy Isreb
  6. Project: The PICAXE, Pt.5: A Chookhouse Door Controller by Stan Swan
  7. Project: PICAXE-Controlled Telephone Intercom by David Lincoln
  8. Project: PICAXE-08 Port Expansion by David Lincoln
  9. Project: Sunset Switch For Security & Garden Lighting by John Clarke
  10. Product Showcase
  11. Project: Test Your Reflexes With A Digital Reaction Timer by Jim Rowe
  12. Project: Adjustable DC-DC Converter For Cars by John Clarke
  13. Project: Long-Range 4-Channel UHF Remote Control by Greg Swain
  14. Vintage Radio: Building A Browning-Drake Replica by Rodney Champness
  15. Weblink
  16. Back Issues
  17. Notes & Errata
  18. Market Centre
  19. Advertising Index
  20. Book Store
  21. Outer Back Cover

This is only a preview of the June 2003 issue of Silicon Chip.

You can view 29 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • PICAXE: The New Millennium 555? (February 2003)
  • PICAXE: The New Millennium 555? (February 2003)
  • The PICAXE: Pt.2: A Shop Door Minder (March 2003)
  • The PICAXE: Pt.2: A Shop Door Minder (March 2003)
  • The PICAXE, Pt.3: Heartbeat Simulator (April 2003)
  • The PICAXE, Pt.3: Heartbeat Simulator (April 2003)
  • The PICAXE, Pt.4: Motor Controller (May 2003)
  • The PICAXE, Pt.4: Motor Controller (May 2003)
  • The PICAXE, Pt.5: A Chookhouse Door Controller (June 2003)
  • The PICAXE, Pt.5: A Chookhouse Door Controller (June 2003)
  • The PICAXE, Pt.6: Data Communications (July 2003)
  • The PICAXE, Pt.6: Data Communications (July 2003)
  • The PICAXE, Pt.7: Get That Clever Code Purring (August 2003)
  • The PICAXE, Pt.7: Get That Clever Code Purring (August 2003)
  • The PICAXE, Pt.8: A Datalogger & Sending It To Sleep (September 2003)
  • The PICAXE, Pt.8: A Datalogger & Sending It To Sleep (September 2003)
  • The PICAXE, Pt.8: The 18X Series (November 2003)
  • The PICAXE, Pt.8: The 18X Series (November 2003)
  • The PICAXE, Pt.9: Keyboards 101 (December 2003)
  • The PICAXE, Pt.9: Keyboards 101 (December 2003)
Items relevant to "Sunset Switch For Security & Garden Lighting":
  • Sunset Switch PCB pattern (PDF download) [10106031] (Free)
  • Panel artwork for the Sunset Switch (PDF download) (Free)
Items relevant to "Test Your Reflexes With A Digital Reaction Timer":
  • Reaction Timer PCB pattern (PDF download) [04106031] (Free)
Items relevant to "Adjustable DC-DC Converter For Cars":
  • Adjustable DC/DC Converter for Cars PCB pattern (PDF download) [11106031] (Free)
  • Panel artwork for the Adjustable DC/DC Converter for Cars (PDF download) (Free)

Purchase a printed copy of this issue for $10.00.

Want to switch on an appliance at dusk and off again after a few hours or at dawn? This sunset switch can do this automatically. It is ideal for security and garden lighting. By JOHN CLARKE P ATHWAY LIGHTS, entrance foyer lighting, house numbers and outside security lights all need to be lit at the onset of dark­ness; ie, sunset. Of course you can switch these lights on manu­ ally each day when darkness falls and switch them off in the morning but it is too easy to forget. The result is that lights are often left on all day and that can waste a lot of electrici­ty. What you need is a sunset switch – a 34  Silicon Chip fully automatic switch which turns on at dusk and off at sunrise. You probably also want a timer that switches the power off after a few hours (select­able). And we’ll throw in manual ON and OFF switching so that you can override the system. So that’s what we’ve done. The SILICON CHIP Sunset Switch has all of the above features and can switch up to 6A at 240VAC. This gives a total load of 1440W of lights or whatever. The unit Main Features • • • • • Switches on mai ns power at preset darkness level Optional timeout Four timeout sele ctions Manual on and of f switching 6A mains switchi ng is housed in a rugged plastic case with a clear lid which allows the ambient light to be detected by the internal light dependent resistor. There is also a LED inside the box to indicate whenever power is applied. Fig.1 is a block diagram of the Sunset Switch. An LDR monitors ambient light and when the light drops below a certain threshold, the following www.siliconchip.com.au Fig.1: block diagram of the Sunset Switch. An LDR monitors ambient light and this triggers the electronic circuitry when the light falls below a certain level. Schmitt trigger changes its output level and this is sent through a delay. It takes a few seconds before the second Schmitt trigger changes its output level. This delay prevents momentary changes in light level from causing the circuit to trigger. The second Schmitt trigger clocks a flipflop and its output drives a transistor (Q1) and the relay. The relay switches power to the mains outlet. At the same time, the flipflop starts the timer and after the selected time (set via the DIP1 switches) it resets the flipflop and the relay is switched off. If the switches are left open, the flipflop will be reset when the LDR receives sufficient light to trip the Schmitt trigger outputs again and reset the flipflop. Under manual control, the flipflop is set (ON) with switch S3 to turn on the relay and reset (OFF) with switch S2. rises above that at pin 3 and the output of IC1a goes low. The 100kΩ resistor between pins 1 & 3 of IC1a provides about 200mV hysteresis which prevents the output from erratically switching low and high as the light level changes. Trimpot VR1 sets the light threshold for the Sunset Switch. You can set it from twilight to quite dark. The output from IC1a is fed via an RC delay network con­sisting of a 100kΩ resistor and 100µF capacitor. This delays the triggering of the following Schmitt trigger, IC1b, by a few seconds. This prevents false triggering due to sudden changes in light level. Low light levels result in IC1b’s output going high and this triggers the clock input of the D-type flipflop IC2 at pin 3. This causes the Q output at pin 1 to go high. This turns on transistor Q1 which powers relay RLY1. LED1 lights to indicate whenever the relay is switched on. At the same time as pin 1 of IC2 goes high, the complemen­tary output at pin 2 goes low and this releases the reset on counter IC3. IC3 includes a free running oscillator at 1.2Hz, as set by the components at pins 9, 10 and Circuit details Fig.2 shows the full circuit of the Sunset Switch. There are just three ICs and a 3-terminal regulator. IC1 is an LM393 dual comparator and both comparators are connected as Schmitt triggers IC1a monitors the LDR voltage at its inverting input, pin 2. The resistance of the LDR when ex­ posed to daylight is around 10kΩ, so the voltage at pin 2 of IC1a in daylight is normally below 1V. This is lower than the voltage at pin 3 so the output of IC1a will be high. In darkness, the resistance of the LDR rises and so the voltage at pin 2 www.siliconchip.com.au This is the view inside the completed unit. Be sure to use mains-rated cable for all 240V AC wiring to the fuse, power switch & mains socket (GPO). June 2003  35 Fig.2: the complete circuit of the Sunset Switch. IC1a & IC1b function as Schmitt triggers, while flipflop IC2 drives the relay (via Q1) and resets timer IC3 (a 4060 counter). VR1 sets the light threshold at which triggering occurs. 11. As a result, the outputs at Q10, Q12, Q13 and Q14 go high after 15 minutes, 1 hour, 2 hours and 4 hours, respectively. If one of the DIP switches is closed, the selected output will reset flipflop IC2. This causes the relay to switch off. Should all the DIP switches be open, flipflop IC2 will not be reset by the timer; ie, the timer has no control. In this case, the only way the flipflop can be reset is if the Off switch, S2, is pressed or the ambient light on the LDR increases and causes IC1a and IC1b to respond accordingly; ie, IC1b’s output goes low and transistor Q2 turns on. This resets the flipflop via the 100nF capacitor and diode D10. Manual switch-on is via switch S3 36  Silicon Chip which sets the flipflop so that pin 1 is high and pin 2 is low. Power for the circuit comes from a mains transformer with a centre-tapped 12.6V winding. This feeds a bridge rectifier consisting of diodes D1-D4 and the rectified output is filtered with a 470µF capacitor. The 3-terminal regulator, REG1, provides the required 12V for the relay and ICs. IC2 is reset at switch-on via D11 and the associated 10µF capacitor. Construction The Sunset Switch is built on a PC board coded 10106031 (138 x 76mm). This is housed in a plastic case measuring 165 x 85 x 55mm which has the control switches and mains socket mounted on the transparent lid. Note that, to ensure safety, you should use the specified plastic case for this project. Note also that everything must be contained inside the case – there must be no metal screws or other metal parts passing through from inside the case to the outside (or vice versa). The wiring layout and component overlay for the PC board is shown in Fig.3. You can begin construction by checking the PC board against the published pattern (see Fig.6). Check for any shorts or breaks in the tracks and fix any faults as necessary. Start assembly by inserting PC stakes at all the exter­nal wiring points on the PC board (8 required), then insert the links and the resistors. www.siliconchip.com.au S3 ON S2 OFF SLEEVE WIRING TO SWITCHES S2 & S3 WITH HEATSHRINK (SEE TEXT) 1 3 F1 10A FUSE BROWN GREEN/YELLOW BLUE (NEUTRAL) BROWN BROWN A SDIP1 4148 A 100 µF 10k LDR NP 10 µF IC1 LM393 100k 3 REG1 7812 100k 100k 2.2k 10k 1 10k 10 µF 10 µF 100k 2.2k 100k 1 1 10k 4148 13060101 H C TI W S T E S N U S VR1 500k 3.9k 1 D11 K 100k IC2 4013 10 µF 2.2k 1 6.3V 2 K 10nF T1 M2851L LED1 A 100k Q2 10 µF 2.2k 6.3V N WARNING! LETHAL VOLTAGES ARE PRESENT ON THE PC BOARD 100nF D10 Q1 BROWN D6 1 1 D7 D8 D9 10k A 4148 4148 4148 4148 IC3 4060 RELAY1 GREEN/ YELLOW BLUE N 1N4004 EVIT CA DE H CTI WS BLUE MAINS GPO (REAR VIEW) BLUE D5 GREEN/ YELLOW (EARTH) E 100k BROWN (ACTIVE) CABLE TIE S1 POWER 10k MAINS CORD ENTERING VIA CORD GRIP GROMMET 100k 2 NOTE: ALL CONNECTIONS TO FUSE F1 AND SWITCH S1 SHOULD BE COVERED WITH HEATSHRINK SLEEVING TO PREVENT SHOCKS. USE ADDITIONAL CABLE TIES TO SECURE MAINS WIRING – SEE PHOTOS 470 µF D1–D4: 1N4004 100 µF Fig.3: install the parts on the PC board and complete the wiring as shown here. Exercise care when installing the mains wiring and make sure that all exposed mains terminals are sleeved with heatshrink tubing to avoid accidental contact with the mains voltages. The mains wires should also be secured using cable ties (see photos). Next, you can install the ICs, taking care with their orientation. The DIP switch and trimpot VR1 can also now be inserted and soldered in place. When installing the diodes, transistors and 3-terminal regulator, take care with their orientation and be sure that the correct transistor is in each position. The electrolytic capaci­tors must be oriented with the polarity as shown with the excep­tion of the 10µF bipolar (NP or BP) type which can be mounted either way around. The LDR can be mounted with its body about 5mm above the PC board. The LED and relay is mounted next. Drilling the case Drill out and shape the hole in the end of the case for the cordgrip Table 1: Resistor Colour Codes o No. o  9 o  6 o  1 o  4 www.siliconchip.com.au Value 100kΩ 10kΩ 3.9kΩ 2.2kΩ 4-Band Code (1%) brown black yellow brown brown black orange brown orange white red brown red red red brown grommet. When fitted, the cordgrip grommet must be such a fit that it will continue to hold the mains cord in place even if the cord is pulled with considerable force. Mark out and drill the front panel Table 2: Capacitor Codes Value   IEC Code EIA Code 100nF (0.1µF)    104  100n 10nF (.01µF)     103   10n 5-Band Code (1%) brown black black orange brown brown black black red brown orange white black brown brown red red black brown brown June 2003  37 Parts List 1 PC board, code 10106031, 138 x 76mm 1 sealed enclosure with clear lid, 165 x 85 x 55mm, Altronics H-0326 or equivalent 1 mounting foot pack (4), Altronics H-0350 1 12V relay with 10A 250VAC contacts; Altronics S-4250A, S-4170A or equivalent (RLY1) 1 chassis-mount mains socket (Altronics P-8241 or equivalent) 1 12.6V 150mA mains transformer with thermal fuse; Altronics M-2851L or equivalent (T1) 1 M205 mains safety panel-mount fuseholder (Altronics S-5992) 1 M205 10A fast-blow fuse (F1) 1 DPDT 6A mains rocker switch with Neon (S1) 1 LDR dark resistance 1MΩ light resistance 5kΩ (Altronics Z-1621 or equivalent) 1 4-way DIP switch (SDIP1) 6 100mm long cable ties 1 500kΩ horizontal trimpot (VR1) 1 3mm crimp eyelets 1 red momentary 250VAC push-button switch; DSE P-7552, Altronics S-1080 or equivalent (S2) 1 black or blue momentary 250VAC pushbutton switch; Altronics S-1081, DSE P-7550 or equivalent (S3) 1 7.5A mains cord and moulded plug 1 cordgrip grommet to suit mains cord 1 150mm length of 4.8mm heatshrink tubing 1 250mm length of 3.2mm heatshrink tubing 1 150mm length of blue 7.5A mains wire 1 150mm length of brown 7.5A mains wire 1 150mm length of green/yellow 7.5A mains wire 1 200mm length of 3-way rainbow cable 1 100mm length of 0.8mm tinned copper wire 1 M3 x 6mm screw for the mains outlet, switches and fuseholder. The cutting template for the mains socket is shown in Fig.5. Then mount the mains socket, switches and fuseholder. The incoming earth lead (green/yellow) goes direct to the mains socket as shown in Fig.3. A second (mains-rated) earth lead is then run from the mains socket and is either soldered or crimped to a solder lug attached to one of the transformer mounting screws. Fig.4 shows the mounting details for this solder lug. It is secured using an M3 x 15mm metal screw, two nuts and a star washer. Make sure the transformer case is indeed earthed; ie, check for a short circuit between earth and the transformer mounting. In some cases, it may be necessary to scrape away the lacquer coating on the transformer mounting foot to allow a good contact. Secure the other side of the transformer to the PC board using an M3 x 10mm screw and nut. Next, secure the PC board to the integral spacers inside the case using the small self-tapping screws supplied. That done, run the remaining connections to the fuseholder, mains switch and mains socket as shown and use heatshrink tubing over the terminals. Tie the wires with cable ties to prevent them breaking and coming loose from their terminations. Note that the fuseholder must be a mains safety type. If your plastic case doesn’t have matching integral standoffs, then you can secure the PC board USING NYLON SPACERS AND NYLON SCREWS. Do not, under any circumstances, use metal spacers and screws to secure the board – we repeat, there must be no exposed metal screws on the outside of the case. Switches S2 and S3 are wired using 3-way rainbow cable which is sheathed in heatshrink tubing. This prevents the wires from accidentally making contact with any mains terminals. WARNING Before going any further, refer to the warning panel at left. Set all DIP switches off, plug a test lamp into the mains socket and apply power. Cover the unit and the light should come on immediately. Uncovering the unit should turn the light off. Trimpot VR1 is best adjusted by trial and error. Switch off power and remove the mains plug. To set the unit to trigger at a darker light level, turn VR1 anticlockwise. To have it switch on at a brighter level, turn VR1 clockwise. Also test the operation of the Off and On switches. Then check DIP switch S1. Set it to on, plug in the test lamp, apply power and cover the unit. The test lamp should stay on for about 15 38  Silicon Chip This circuit is connected to the 240VAC mains supply and LETHAL VOLTAGES are present on the PC board. Do not operate the unit unless it is fully enclosed in a plastic case and DO NOT TOUCH ANY PART OF THE CIRCUIT when it is plugged into a mains outlet. Always remove the plug from the mains before working on the circuit or making any adjustments. Finally, do not build this project unless you are completely familiar with mains wiring practices and techniques. 1 M3 x 15mm screw 3 M3 nuts 2 M3 star washer 10 PC stakes Semiconductors 1 LM393 dual comparator (IC1) 1 4013 dual D flipflop (IC2) 1 4060 counter (IC3) 1 BC337 NPN transistor (Q1) 1 BC557 PNP transistor (Q2) 1 7812 1A 12V regulator (REG1) 5 1N4004 1A diodes (D1-D5) 6 1N4148, 1N914 diodes (D6-D11) 1 3mm green LED (LED1) Capacitors 1 470µF 25V PC electrolytic 2 100µF 16V PC electrolytic 4 10µF 16V PC electrolytic 1 10µF bipolar electrolytic 1 100nF MKT polyester 1 10nF MKT polyester Resistors (0.25W, 1%) 9 100kΩ 1 3.9kΩ 6 10kΩ 4 2.2kΩ Setting up www.siliconchip.com.au Fig.4: the mounting details for the earth solder lug attached to the transformer. Fig.5: this diagram shows the cut­ out template for the mains socket which goes on the front panel. minutes. If this is the case, then you can expect S2 to switch the lamp on for one hour, S3 for two hours and S4 for four hours. By the way, if you have more than one DIP switch on, say, S2 and S3, it will give the low setting (15 minutes), not the sum of the two. If you want longer times, swap the two 100kΩ resistors at pins 10 and 11 of IC3 for A length of heatshrink tubing should be used to sleeve the wiring to switches S2 & S3 (see text). Secure all mains wiring using cable ties. larger values. Two 220kΩ resistors should about double these times. Installation The Sunset Switch should be installed where it receives outside light but must not be exposed to the weather. It should also be shielded from the lights that it controls, otherwise it may get into a “race” condition whereby it switches on and off continuously. Do not drill inside the case to mount it on a wall. In­stead, use mounting feet and self-tapping screws into the special screw holes provided on the underside of the case. The mounting feet are avail­able in a pack of four from SC Altronics. (Cat H-0350). Fig.6: this is the full-size etching pattern for the PC board. Check you board carefully against this pattern before installing any of the parts. www.siliconchip.com.au June 2003  39