Silicon ChipVersatile Trailing Edge Dimmer with Touch Plate & IR - February 2019 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Beware of dodgy and counterfeit electronics
  4. Feature: Medical, Health and First Aid Smartphone Apps - Part 1 by Dr David Maddison
  5. Project: Versatile Trailing Edge Dimmer with Touch Plate & IR by John Clarke
  6. Review: Rigol’s MSO5354 Mixed Signal Oscilloscope by Tim Blythman
  7. Feature: El Cheapo Modules 22: Stepper Motor Drivers by Jim Rowe
  8. Project: Motion-sensing 12V Power Switch by Nicholas Vinen
  9. Product Showcase
  10. Serviceman's Log: (What) were the designers thinking? by Dave Thompson
  11. Project: USB Mouse and Keyboard Interface for Micros by Tim Blythman
  12. Project: Build-it-yourself DAB+/FM/AM radio by Duraid Madina & Nicholas Vinen
  13. Review: Philips “Brilliance” Ultrawide Monitor by Nicholas Vinen
  14. Vintage Radio: 1970s BWD 216 Hybrid Bench Supply by Ian Batty
  15. PartShop
  16. Subscriptions
  17. Market Centre
  18. Advertising Index
  19. Notes & Errata: Isolated Serial Link, January 2019; 800W(+) UPS, May-July 2018; Full Wave, 230V Universal Motor Speed Controller, March 2018; BackPack Touchscreen DDS Signal Generator, April 2017; SC200 Audio Amplifier, January-March 2017; 12AX7 Valve Audio Preamplifier, November 2003
  20. Outer Back Cover

This is only a preview of the February 2019 issue of Silicon Chip.

You can view 47 of the 112 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:
  • Medical, Health and First Aid Smartphone Apps - Part 1 (February 2019)
  • Medical, Health and First Aid Smartphone Apps - Part 1 (February 2019)
  • Medical, Health and First Aid Smartphone Apps – Part 2 (March 2019)
  • Medical, Health and First Aid Smartphone Apps – Part 2 (March 2019)
Items relevant to "Versatile Trailing Edge Dimmer with Touch Plate & IR ":
  • Touch and IR Remote Control Trailing Edge Dimmer Main PCB [10111191] (AUD $10.00)
  • Touch and IR Remote Control Trailing Edge Dimmer Mounting PCB [10111192] (AUD $10.00)
  • Touch and IR Remote Control Trailing Edge Dimmer Extension PCB [10111193] (AUD $10.00)
  • PIC12F617-I/P programmed for the Touch and IR Remote Control Trailing Edge Dimmer [1011119B.HEX] (Programmed Microcontroller, AUD $10.00)
  • Hard-to-get parts for the Touch and IR Remote Control Trailing Edge Dimmer (Component, AUD $20.00)
  • Infrared receiver parts for the Touch and IR Remote Control Trailing Edge Dimmer (Component, AUD $12.50)
  • Firmware (ASM and HEX) files for the Touch and IR Remote Control Trailing Edge Dimmer [1011119A.HEX] (Software, Free)
  • Touch and IR Remote Control Trailing Edge Dimmer PCB patterns (PDF download) [10111191-3] (Free)
  • Warning label for the Touch and IR Remote Control Trailing Edge Dimmer (PDF download) (Panel Artwork, Free)
Articles in this series:
  • Versatile Trailing Edge Dimmer with Touch Plate & IR (February 2019)
  • Versatile Trailing Edge Dimmer with Touch Plate & IR (February 2019)
  • Versatile Trailing Edge Dimmer – Part 2 (March 2019)
  • Versatile Trailing Edge Dimmer – Part 2 (March 2019)
Items relevant to "El Cheapo Modules 22: Stepper Motor Drivers":
  • Sample code for El Cheapo Modules 22 - Stepper Motor Drivers (Software, Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Motion-sensing 12V Power Switch":
  • Motion-Sensing 12V Power Switch SMD PCB [05102191] (AUD $2.50)
  • SW-18010P Vibration Sensor Switch (Component, AUD $1.00)
  • Short form kit for the Motion-Triggered 12V Switch (Component, AUD $10.00)
  • Motion-Sensing 12V Power Switch SMD PCB pattern (PDF download) [05102191] (Free)
Items relevant to "USB Mouse and Keyboard Interface for Micros":
  • USB Mouse and Keyboard Interface PCB [24311181] (AUD $5.00)
  • PIC32MX270F256B-50I/SP programmed for the USB Mouse and Keyboard Interface for Micros [2431118A/B.HEX] (Programmed Microcontroller, AUD $15.00)
  • MCP1700 3.3V LDO (TO-92) (Component, AUD $2.00)
  • Software for the USB Mouse and Keyboard Interface for Micros [2431118A.HEX] (Free)
  • USB Mouse and Keyboard Interface PCB pattern (PDF download) [24311181] (Free)
Items relevant to "Build-it-yourself DAB+/FM/AM radio":
  • DAB+/FM/AM Radio main PCB [06112181] (AUD $15.00)
  • Dual Horizontal PCB-mounting RCA sockets (white/red) [RCA-210] (Component, AUD $2.50)
  • PCB-mount right-angle SMA socket (Component, AUD $3.00)
  • 465mm extendable VHF whip antenna with SMA connector (Component, AUD $10.00)
  • 700mm extendable VHF whip antenna with SMA connector (Component, AUD $15.00)
  • PCB-mount right-angle PAL socket (Component, AUD $5.00)
  • Short Form Kit for the Micromite Plus Explore 100 (Component, AUD $75.00)
  • Case pieces for the DAB+/FM/AM Tuner (PCB, AUD $20.00)
  • Firmware (BAS and HEX) files for the DAB+/FM/AM Radio project (Software, Free)
  • DAB+/FM/AM Radio main PCB pattern (PDF download) [06112181 RevC] (Free)
Articles in this series:
  • DAB+ Tuner with FM & AM and a touchscreen interface! (January 2019)
  • DAB+ Tuner with FM & AM and a touchscreen interface! (January 2019)
  • Build-it-yourself DAB+/FM/AM radio (February 2019)
  • Build-it-yourself DAB+/FM/AM radio (February 2019)
  • Our new DAB+ Tuner with FM and AM – Part 3 (March 2019)
  • Our new DAB+ Tuner with FM and AM – Part 3 (March 2019)

Purchase a printed copy of this issue for $10.00.

Smooth . . . Our Ne With Touch and/or Remote Control Our new dimmer works with most modern lighting, including dimmable LEDs, dimmable fluorescents      and dimmable halogen downlights, as well      as the now old-fashioned incandescents.        It also has a really easy-to-use touch          control and even infrared           remote control, for ultimate            convenience! It’s ultra           modern, easy to build            and simple to wire up. By John Clarke S leek looks, smooth dimming over a wide range, touch control and infrared remote control are just some of the outstanding features of this new Touch and Infrared Trailing Edge Light Dimmer from SILICON CHIP. It is ideal for dimming modern LED lamps and it does not have a “last century” style adjustment knob. You don’t control your phone or tablet with a knob, do you? You use the touchscreen. So don’t you also want a touch interface for your lighting? And so that you don’t even have to get up from your chair and walk across the room, you can also use a stylish slimline infrared remote control to control the lights. It even provides presets to quickly set the mood that you want! Virtually all lighting in new or renovated homes is now LED-based, 20 Silicon Chip which often means that these homes lack dimmers. If the lamps are dimmable (or can be easily replaced with dimmable versions), then a dimmer like this one is great to retrofit since there are times when you don’t want full brightness. Like when you have just woken up in the morning! But if you have a modern home, you will want a modern dimmer, so this one is a great choice. Visually, its minimalistic style with a brushed aluminium plate means it will blend into a modern home – although it looks great in a more traditional setting too. And the infrared remote control option seals the deal. You can keep it on your bedside table, dining table, lounge. . . wherever you spend a lot of time. Watching a movie? Don’t get up Australia’s electronics magazine from the couch; you can dim the lights just like in a cinema. The baby needs changing during the night? There’s no need to use bright light which can disturb sleep patterns. Just slept in? Ease yourself into the day by slowly ramping up the bedroom lighting. It’s unobtrusive too, because the only part of the dimmer that you see is the wall plate. We use a commercially available Clipsal Classic 2000 blank plate, so it looks very professional and contemporary. A small lens is added to allow for reception of the infrared transmission from the handheld remote control unit. Extra wall plates can be added in other locations if needed, too. The infrared handheld controller is not one you have to build yourself. Instead, it is a small low cost, commercially available unit and it looks attractive and professional. siliconchip.com.au ew Universal Dimmer Features: Trailing edge control – suits LEDs Slimline appearance Touchplate dimming – no knob Optional infrared remote control Soft on/off (rapidly ramps brightness up or down) Supports multiple touch plates Wide dimming range Low electromagnetic interference (EMI) Can operate without a Neutral connection Hopefully, we’ve sold you on the idea of this Dimmer. So read on to find out what it can do and how it works. Requirements for dimming LED lights You need a universal or trailing-edge dimmer for dimming LEDs or compact fluorescent lights (see panel on trailing edge dimmers). But you also need to make sure that your lights are designed to be dimmable. If they are, it will say so on the packaging and it will probably also be printed on the lamps themselves. Many LED and fluorescent lights are not dimmable. And we’ve found that even some that claim they are dimmable don’t always “play nice” with certain dimmers! So it pays to test the lights with the dimmer you intend using before installing either. Our Dimmer was tested with a few different dimmable LEDs and we found that it worked fine (as it should) but there may be some LED lights out there which will not work when driven from it, so you need to test them siliconchip.com.au yourself. The same goes for halogens with electronic transformers. The underside of our new Touch/ Remote Control Dimmer. It mounts on a standard Clipsal plate, which in turn accepts a standard aluminium dress panel. Australia’s electronics magazine Some are explicitly labelled as dimmable and most of them will work with this Dimmer. Halogens powered via traditional iron-cored transformers are also dimmable. If you are running several halogen or incandescent lights with this Dimmer, be careful not to exceed its 250W maximum load rating. Dimming control The lamp(s) connected to the Dimmer can be controlled in two ways, using the touch plate or via infrared remote control. With the touch plate, dimming is initiated by simply holding your hand on the touch plate. The light brightness will smoothly decrease or increase. Momentarily lifting your hand and then re-applying it to the touch plate will switch between decreasing or increasing brightness. It takes three seconds for the light to go from fully off to fully on or vice versa. Dimming stops when either minimum brightness or full brightness is reached. Want instant light? A quick tap of the touch plate will switch the light on and another quick tap will turn it off. When switching on, the lamp immediately goes to full brightness over a brief period of around 0.4s (400ms). This produces a smooth on/off effect rather than an abrupt change in light level. Note that a quick tap is any touch that measures between 140ms and 600ms. Taps shorter than 140ms are ignored (to prevent spurious light switching due to electrical noise etc) while February 2019  21 Specifications Operating mains voltage range: .............200-255VAC Mains frequency: ...............................50Hz or 60Hz Minimum load: .................................8W Maximum load: .................................250W Minimum brightness: ..........................0% (entirely off) Maximum brightness: .........................100% when a Neutral connection is available; adjustable when it is not, up to about 95% Brightness steps: ...............................2% (50 steps from off to full brightness) Touch dimming time: ..........................three seconds from fully on to fully off or vice versa Touch control commands: ....................switch on/off, brighter/dimmer Infrared remote control commands: ........switch on/off, increase/decrease brightness fast (2s) or slow (9s), plus three presets Dimming steps: ................................50 for touch control, 100/450 for infrared (fast/slow dimming) Soft on/off time: ................................400ms Quiescent power: ..............................around 1W Touch control timing: ..........................Touched for <140ms: no action ....................................................Touched for 140-600ms: on/off alternate action ....................................................Touched for >600ms: begins dimming up or down; hold down to continue (alternate action) presses longer than 600ms initiate the dimming up/down function. Infrared remote control While the touch plate has effectively only one control that has to perform several functions, the handheld remote control unit has nine buttons, as shown below. All of these buttons control the Dimmer in some way. The “Operate” or on/off button at the top switches the lights entirely The nine-button remote control we used for this project. There are no doubt many others available which will do the job, but ours came from Little Bird Electronics (www.littlebird. com.au) for the princely sum of $5.87. 22 Silicon Chip on or off, just like a quick tap of the touch plate. The circle button in the middle of the directional arrows also switches the light on or off, however, it works slightly differently. When you press it to switch the light on, it will return to the same brightness level the lamp had before it was last switched off. Holding the up and down arrow buttons provide a slow increase or decrease in brightness respectively, with nine seconds required to go from fully off to fully on or vice versa. The left and right arrow buttons also decrease or increase the brightness but do so faster, taking only two seconds from one extreme to the other. The A, B and C buttons provide for three different fixed brightness levels. These are dim, medium and bright lamp settings respectively. As with the on/off control, rather than jumping instantly to the new brightness level, the unit quickly ramps the brightness up or down as required, providing a smooth transition. When the Dimmer is initially powered up, the lamp remains off. The Fig.1(a): when Mosfets Q1 & Q2 are switched off, current cannot flow through the lamp regardless of the polarity of the Active voltage because one of the two Mosfet body diodes will always be reverse-biased and block current flow. If a single Mosfet was used, it would always conduct at least half the time, severely limiting the possible dimming range Fig.1(b): when the gates of Mosfets Q1 & Q2 are pulled at least 8V above their source terminals (shown here connected to circuit ground), both Mosfets conduct and so current can flow through the lamp regardless of the Active voltage or the point in the mains cycle. The forward-biased body diode may conduct some current depending on the voltage across the Mosfets. Australia’s electronics magazine siliconchip.com.au +5V +5V K 100nF 47 Q1 470 F SiHB15N60E D 16V 2.2k OPTO1 4N25 1 1M 100 F TOSOP4136 CLKIN/GP5 3 4 2 GP4/CLKOUT 3 T1 A K 470 1W D LAMP K D2 1N4148 ZD2 100nF 12V A T0CKI/GP2 ISOLATED SUPPLY 5 ZERO VOLTAGE CROSSING DETECTION 1.5M 1W N GP1/AN1 4.7M TOUCH PLATE A 1W S G Q2 SiHB15N60E 22k IC1 PIC 12F6 17 –I/P 6 CON1 470 GP3/MCLR 100nF 470nF X2 470 1  2 A K S 1M 4 2 ISOLATED DRIVE Vdd A G  1 IRD1 470 5 ZD1 5.6V D1 1N4004 AN0/GP0 VR37 4.7M 47k 7 Vss VR37 10k 4.7nF 8 EXTN SAFETY RESISTORS A K EXTENSION BOARD CIRCUIT TOUCH PLATE 4.7M VR37 4.7M VR37 ZD3 6.8V D3 1N4148 A K 47nF 2.2M A 1M E B SAFETY RESISTORS 1N4148 K A SC  20 1 9 1N4004 A BC559 IRD1 K A Q3 BC559 A 220 SiHB15N60E 4N25 D B 1 2 EXTN ZD4 6.8V C ZD1–4 K K 3 E C 3 6 TOUCH & REMOTE CONTROL TRAILING EDGE DIMMER 1 G S Fig.2: the circuit of the Touch and Remote Controlled Universal Dimmer. The yellow shaded box shows the optional extension circuit, only required if you need two or more touch plates for control. Micro IC1 does most of the work, controlling Mosfets Q1 and Q2 via optocoupler OPTO1 and an isolated power supply based on transformer T1. It monitors the mains phase at pin 5 and times the switching of the two Mosfets to achieve the desired lamp brightness level. standby power drawn by the Dimmer circuit from the mains is just over 1W. What if there is no Neutral wire? In most domestic installations, the mains Neutral wire is not brought to the light switch. The Neutral connection to the lamp is usually made in the ceiling; only the lamp Active wire and Active supply wire need to be run through the wall cavity to the switch or dimmer (it saves cable!). That presents a problem for powering the dimmer circuit. When the lamp is switched on at full brightness, in theory, there is no potential difference between those two wires and so there is no power available to run the siliconchip.com.au Dimmer itself. But we need it to work in this situation since it is so common. The solution is to limit the maximum lamp brightness to be just a little bit less than that achieved when it receives the full 230VAC. Since dimming is done by switching the mains off before the end of each cycle, that leaves a small window where mains voltage is still present but the lamp is off. It is during that time that the dimmer draws the power it needs to operate from the mains. If there is a Neutral connection available, then the dimmer is powered regardless of whether the lamp is on all the time, so maximum brightness will be available. Australia’s electronics magazine Our Dimmer caters for both wiring possibilities. When the Neutral wire is not available, you can set the maximum brightness of the lamp, so there is enough mains voltage to power the dimmer without the lamp flickering. We will describe how this is done in the constructional article next month. LED light snap-on effect Many mains-powered LED lamps will “snap on” as the dimming control is increased from off to a low brightness level. This means that the lamp brightness may not rise slowly as expected; instead, the lamp remains off entirely and then springs into life suddenly when you reach a specific brightness setting, with a higher brightness February 2019  23 than you would expect. This is due to the LED driver requiring a certain amount of voltage and current to start up. Once it has started, you can usually drop the brightness back down to a lower level and the light will remain on. In other words, you can’t get the lamp to light up dimly when increasing its brightness from the off-state. You instead need to switch it on at an intermediate brightness and then reduce its brightness to get it to dim correctly. This effect is more noticeable when you are running the Dimmer without a separate Neutral connection. Circuit description The circuit of the Universal Dimmer is shown in Fig.2. Despite providing many useful features, the circuit is quite simple because most of the work is done in the software running on the PIC12F617 microcontroller (ICI). Mosfets Q1 and Q2 switch mains voltage to the lamp(s), to control their brightness. The way that these control the lamp load is shown in Fig.1. This configuration allows us to control power over the entire mains waveform, switching mains power at the lamp on or off at any time. The reason that two Mosfets are required for this job is that a power Mosfet contains an intrinsic (or body or “parasitic”) diode which cannot be removed; it is inherent to the structure of a Mosfet. Since the current flow reverses for half of the mains waveform, if we used a single Mosfet, its body diode would conduct half the time and apply the full voltage to the load, whether the Mosfet was switched on or not. By connecting the two Mosfets in series, with the body diodes in opposite directions and the Mosfets switched off, current flow is blocked in both directions, as shown in Fig.1(a). When the Mosfets are switched on by pulling their gate voltages high, as in Fig.1(b), current can flow in either direction via the Mosfet channels, mostly bypassing the body diodes. The body diodes will only conduct if the current through the channel high enough to create a voltage difference across the Mosfet (due to channel resistance) that’s higher than the body diode forward voltage. Driving the Mosfet gates Mosfets Q1 & Q2 switch on when their gate voltages are higher than the common source terminal voltage. For these particular Mosfets, the difference needs to be at least 8V for conduction with minimal losses. But the gate voltage can’t be too high as any more than 30V could damage the Mosfets. That makes it a bit tricky to provide just the right voltage to keep them switched on when necessary. The easiest solution is to galvanically isolate the gate voltage source from the rest of the circuit. This is mainly since the +5V rail is connected directly to mains Active, which is necessary for the touch control to work. The problem is that even if we could generate the required 8-30V supply and then apply this to the Mosfet gates, with their source terminals connected to circuit ground, as soon as Q1 switched on, it would connect Active (+5V) to ground, effectively shorting out the 5V supply and thus shutting the whole circuit down. By “floating” the gate supply, we eliminate this prob24 Silicon Chip Leading vs trailing edge dimming Our mains electricity supply (nominally 230VAC) is a 50Hz sinewave. To provide a dimming function, this is normally “chopped” in some manner by a switching device which interrupts the mains supply to the lamp, to reduce its brightness. The more of the time this switching device is on, the brighter the lamp. The most common method of chopping the mains waveform is “phase control”, where power is applied continuously for some portion of each half of the mains cycle. Each half of the mains cycle lasts for 10ms and for the entire period, the Active conductor voltage is either higher or lower than the Neutral voltage. Between each half-wave, there is a “zero crossing” where the Active and Neutral voltages are equal. Each full mains waveform (taking 20ms) is considered to have a phase from 0-360°, with the two zero crossings having phase angles of 0° and 180° and the voltage peaks being at 90° and 270°; see Fig.3. The terms “leading-edge dimming” and “trailing-edge dimming” refer to the fact that there are two main ways to provide phase control. They work similarly but are generally used in different circumstances. If you delay applying the mains waveform to the load until a particular phase angle – say, 45° – then allow it to continue to be applied until the start of the next half-cycle, you have reduced the RMS voltage at the load and therefore reduced the power the load draws. This is known as leading edge dimming since you are delaying the leading edge of the mains waveform “seen” by the load; see Fig.4. Alternatively, if you apply power to the load from the start of the waveform (ie, at 0°) and then cut it before the end of the cycle – say, at 315° – then you are moving the trailing edge of the mains waveform as seen by the load and that is known as trailing edge dimming; see Fig.5. In both of these examples, the RMS voltage applied to the load is the same – around 219V RMS in a nominally 230VAC system. The leading edge dimmer has been used for around 50 years, mainly for dimming incandescent lamps. That is because it can be implemented using a simple circuit based on a Triac, as shown in Fig.6. The Triac is a four-layer semiconductor device which switches on when its gate is driven. But it can’t be switched off via the gate; instead, it switches itself off when the current flow through it drops to near zero. In practice, when driving a resistive load like an incandes- Fig.3: the Australian mains voltage is roughly sinusoidal and repeats at 50Hz (ie, every 20ms). The negative-topositive transition of the Active voltage is considered the start of each cycle and has a phase angle of 0°. The other zero crossing is at 180° and the two peaks are at 90° and 270°. During phase control, the power to the load is switched at a consistent point in the cycle. Australia’s electronics magazine siliconchip.com.au cent lamp, the Triac switches off when the mains voltage is near 0V. Hence, it’s simple to provide leading edge phase control. Dimming LEDs Leading edge dimmers are not suitable for use with LED lamps or halogen lamps with electronic transformers. That’s because in both cases, the control circuitry rectifies the mains and then filters it with a capacitor. It is the charge on that capacitor which then runs the remaining circuitry, including the lamp. If a voltage is suddenly applied to this type of circuit, the diodes in the Fig.4: a leading edge dimmer varies Fig.5: a trailing edge dimmer achieves rectifier immediately conduct and the switch-on point during the mains a similar result but it instead switches cycle but always switches off at the zero the lamp on at the zero crossing and draw a high current to charge the cacrossing. So the earlier it switches on, the then switches it off at some point pacitor quickly. more power is applied to the load and later in the mains cycle. The later the Such a high inrush current is manthe brighter the resulting light is. But this switch-off, the brighter the lamp. This ageable if it only occurs infrequentdoes not work well with LEDs or with scheme is compatible with lamps that ly, such as when a light is switched other lamps that have electronic drivers. have electronic drivers, including most on, but if it’s happening every mains dimmable LEDs. cycle (when the Triac in the dimmer switches on), it could lead to overTrailing edge dimmers need to use a switching device other heating and failure. than a Triac; one that can be switched off with gate control And even if the dimmer and lamp can tolerate this situation, at any part of the mains waveform. Fig.7 shows a simpliyou would still expect to see ringing, voltage excursions, exfied circuit of a typical trailing edge dimmer. The switching cessive electromagnetic interference (EMI) and lamp flashing device is normally one or two Mosfets or IGBTs (insulated rather than dimming. So clearly it is not workable. gate bipolar transistors). The solution is to use a trailing-edge dimmer instead. The In the circuit presented here, we are using two Mosfets, switching device now turns on at the mains zero crossing connected source-to-source. Refer to the circuit description where there is no potential difference between Active and for details on why we’ve used that configuration. It allows Neutral. The lamp voltage then rises relatively slowly and the us to switch mains power to the lamp load on or off at any rectifier diodes conduct once the mains voltage exceeds the points in the mains cycle. capacitor voltage. Current is drawn from the mains in much For more information on leading and trailing edge dimmers smaller and more tolerable pulses. and their use with LED lamps, see the article titled “LED Since LEDs are now basically taking over the lighting mardownlights and dimmers” in the July 2017 issue of SILICON ket, leading-edge dimmers are giving way to trailing edge or CHIP (www.siliconchip.com.au/Article/10712). universal dimmers (which can operate in either mode). S1 A Ls – Cs N LAMP LOAD Ls Fig.6: this shows how simple a Triac-based leading edge dimmer can be. While this looks like a simplified circuit, an actual dimmer is barely any more complicated. Rt and Ct provide a variable time constant that varies how late in the cycle the Diac “breaks over” and triggers the Triac, which admits current to the lamp. It automatically switches off at the next zero crossing. Cs and Rs form a snubber to reduce EMI, and Ls helps with EMI reduction too. siliconchip.com.au + ZERO CROSSING DETECTOR AND PULSE GENERATOR HIGH VOLTAGE MOSFET D G S SC 20 1 9 Fig.7: the circuit of a trailing edge dimmer is a little more complex. This simplified diagram hides most of the complexity inside the yellow box at right. The mains supply is rectified to provide this control circuitry with a power supply and also so that a single Mosfet can be used, as it only has to switch voltage with a single polarity. A capacitor is required (not shown) to maintain power supply for the control circuitry while the Mosfet is on. Australia’s electronics magazine February 2019  25 The dimmer is constructed using two PCBs which “sandwich” one on another. The assembly is mounted onto a Clipsal plate with a touch plate on the opposite side. lem; the Mosfet source terminals no longer need to be connected for circuit ground to allow us to control the Mosfet gate voltage. Transformer T1 both provides this isolation and also steps up the 5V control voltage to give a gate voltage above 8V. This transformer comprises a high-frequency toroidal ferrite core with two copper windings. The primary winding is driven by a 2MHz square wave generated at IC1’s clock output (pin 3), via a 100nF AC-coupling capacitor. The secondary winding has four times as many turns as the primary and is isolated from it. The secondary AC waveform is half-wave rectified by diode D2 and filtered with a 100nF capacitor. The result is a nominal 10V DC with the negative side connected to the source of Q1 and Q2, and the positive side to the gates via a 22kresistor and two 470resistors. The gate voltage is controlled using optocoupler OPTO1. It’s necessary to maintain the isolation between IC1, with its 5V rail connected to Active, and Mosfets Q1 and Q2. When IC1’s GP5 output (pin 2) goes high, OPTO1’s internal infrared LED is off. When this pin goes low, around 2mA flows through that LED, limited by the 2.2kresistor from the 5V supply. When this LED lights up, it shines 26 Silicon Chip on OPTO1’s internal phototransistor, shorting out the 10V gate supply to Mosfets Q1 and Q2, switching them off. When the phototransistor switches off, the 10V supply can again pull the Mosfet gates high and so they switch back on. The Mosfet gates are isolated from each other with 470resistors to prevent oscillation at switch on. A 1Mresistor between the collector and emitter of OPTO1’s output transistor ensures that Q1 and Q2 remain off when IC1 is not powered. Mains zero crossing detection To time the switching of Q1 and Q2 correctly, to get the desired dimming level, IC1 has a timer which is synchronised with the mains zero crossing, ie, the time when the Active and Neutral voltages are equal (which happens 100 times per second with our 50Hz mains sinewave). It therefore needs a way to detect this condition, to synchronise its timer. This is detected at pin 5 of IC1, via a 1.5Mresistor connected to the Neutral conductor (which may be via the lamp(s), in cases where a separate Neutral wire is not available). Detection of the zero crossing is only made at the negative transition, with the positive transition timing being timed as 10ms later. Australia’s electronics magazine The 1.5Mcurrent-limiting resistor forms an RC low-pass filter in conjunction with the 4.7nF capacitor, which is necessary to reduce the effects of electricity authority control tones which may be superimposed on the 50Hz mains. These would otherwise cause a noticeable flickering in the lamp due to modulated zero voltage detection. This does, however, delay the detection of the zero crossing. IC1 compensates for this known delay to determine the actual zero crossing timing. Note that only one of the two zero crossings is actually detected. The other is calculated from it based on the expected delay from either a 50Hz or 60Hz mains frequency. This improves the stability of the dimmer, especially when operating without a Neutral wire. Also, the software only checks the state of pin 5 around the expected time of the zero crossing. If zero voltage detection was active for the entire cycle, switching the lamp on and off would cause false detection due to the change in voltage at the zero voltage input when the lamp is switched. This is important when zero crossing detection is via the lamp rather than directly from the Neutral. Power supply As you may have gathered from the explanation above, the power supply configuration for this circuit is intimately related to its operation. That’s because it runs from the same mains supply which it is also monitoring (for zero crossing events) and switching. And in the case where you don’t have a Neutral wire connected to the device, it becomes quite tricky indeed. Besides the isolated Mosfet gate driver section described above, the rest of the circuit “floats” with the nominally 230VAC mains Active waveform. In fact, the Active wire is tied directly to its +5V rail. So you can think of it as if the circuit’s supply current is drawn from the Neutral connection; in practice, it flows between Active and Neutral, with the current reversing 100 times per second. This current flows to/from the Neutral wire through two 4701W series-connected resistors and a 470nF mains-rated capacitor. When the Active voltage is below the Neutral voltage, the 470nF capacisiliconchip.com.au Parts list – Trailing Edge Dimmer Here’s the extension touch plate control which is similar to the main PCB and mounts in the same way (see below) . . . tor charges via the two 470resistors and ZD1, which is forward-biased and acts like a standard diode. When the Active voltage subsequently goes above the Neutral voltage, the 470nF capacitor discharges through diode D1, charging up the 470µF electrolytic capacitor which then powers the rest of the circuit. Once the charge on the 470µF capacitor reaches 5V, any extra current drawn by the circuit is shunted by ZD1, to prevent the supply voltage rising any further. It limits the supply to 5V, not 5.6V, due to the 0.6V forward voltage of diode D1 when it is in conduction. When ZD1 conducts, it is the im- . . . and here’s the extension mounted on the Clipsal plate. siliconchip.com.au 1 double-sided PCB coded 10111191, 66 x 104mm 1 PCB coded 10111192, 58.5 x 104mm 1 Clipsal CLOPTO1031VXBA C2000-series standard blank plate with blank aluminium cover 1 CLI449AWE mounting block (optional; see construction article text next month) 1 fresnel lens for IR sensor (Murata IML0688) [RS components Cat 124-5980] 1 infrared remote control [Little Bird Electronics SF-COM-14865] 1 CR2025 3V cell, to suit IR remote control 1 DIL-8 IC socket (IC1) 1 4-way terminal strip, 25A 300VAC with 9.5mm pitch (CON1) [Jaycar HM-3162] 1 18 x 10 x 6mm toroidal core, L8 material (T1) [Jaycar LO1230] 1 1.26m length of 0.25mm diameter enamelled copper wire (T1) 3 100mm Nylon cable ties 1 25mm length of 16mm heatshrink tubing 4 M3 x 6mm panhead machine screws 8 M3 hex nuts 1 15mm length of 0.71mm diameter tinned copper wire Semiconductors 1 PIC12F617-I/P microcontroller programmed with 1011119A.HEX (IC1) OR 1011119B.HEX (depending on remote; see errata August 2019) 1 4N25 optocoupler (OPTO1) 1 TSOP4136 infrared receiver (IRD1) 2 SIHB15N60E N-channel Mosfets, 15A 600V (Q1,Q2) 1 1N4004 1A 400V diode (D1) 1 1N4148 small signal diode (D2) 1 5.6V 1W zener diode (ZD1) 1 12V 1W zener diode (ZD2) Capacitors 1 470µF 16V PC electrolytic 1 100µF 16V PC electrolytic 1 470nF 275VAC X2-class, 22.5mm pitch 3 100nF 63/100V MKT polyester 1 4.7nF 63/100V MKT polyester Resistors (0.25W, 1% unless otherwise stated) 2 4.7MW Vishay VR37 3.5kV safety resistors [RS Components 484-4400] 1 1.5MW 1W 5% 2 1MW 1 47kW 1 22kW 1 10kW 1 2.2kW  2 470W 1W 5% 2 470W 1 47W Additional parts for each extra touch plate 1 double-sided PCB coded 10111192, 58.5 x 104mm 1 PCB coded 10111193, 58.5 x 104mm 1 Clipsal CLOPTO1031VXBA C2000-series standard blank plate with blank aluminium cover 1 CLI449AWE mounting block (optional; see text) 1 4-way terminal strip, 25A 300VAC with 9.5mm pitch (CON1) [Jaycar HM-3162] 4 M3 x 6mm panhead machine screws 8 M3 hex nuts 1 15mm length of 0.71mm diameter tinned copper wire Semiconductors 1 BC559 PNP transistor (Q3) 1 1N4148 small signal diode (D3) 2 6.8V 1W zener diodes (ZD3,ZD4) Capacitors 1 47nF MKT polyester Resistors (0.25W, 1% unless otherwise stated) 2 4.7MW Vishay VR37 3.5kV safety resistors [RS Components 484-4400] 1 2.2MW 1 1MW 1 220W Additional parts for external switch control 1 Clipsal 30MBPR momentary press switch and matching architrave or standard single-gang switch plate Australia’s electronics magazine February 2019  27 Infrared remote control using the Pulse Distance Protocol (PDP) Most infrared controllers use a modulation frequency of 36-40kHz, typically 38kHz, where the infrared LED is switched on and off at this frequency. This is done in bursts (pulses), with the length of and space between the bursts (pauses) indicating which button was pressed. The series of bursts and pauses is usually in a particular format (or protocol) and there are several different protocols commonly used. This includes the Manchester-encoded RC5 and RC6 protocols originated by Philips. There is also the Pulse Width Protocol used by Sony. The handheld remote used in this project uses Pulse Distance Protocol, originating from NEC. If you are interested in details on all these protocols and others, see the application note AN3053 by Freescale Semiconductors (formerly Motorola) at: http://cache.freescale.com/files/ microcontrollers/doc/app_note/ AN3053.pdf The adjacent diagram (Fig.8) shows the details of this protocol. This is broken up into four panels. The top panel shows how binary bits zero and one are transmitted. They both start with a 560µs burst modulated at 38kHz. A logic 1 is followed by a 1690µs pause while a logic 0 has a shorter 560µs pause. The second panel shows the structure of a single transmission. It starts with a 9ms burst and a 4.5ms pause. This is then followed by eight address bits, another eight bits which are the “one’s complement” of those same eight address bits (the 0s become 1s and the 1s become 0s). The address bits identify the equipment being controlled by the remote (TV, DVD, radio etc). pedance of the two 470resistors and the 470nF capacitor which prevents excessive current from being drawn from the mains. The 470resistors also limit the inrush current each time the light switch is turned on, as the instantaneous applied voltage could be as high as 350V DC (the typical Active-Neutral voltage with a 230V mains supply is 325VPK but in some areas with abnormally high mains, this could be significantly higher). If there is no Neutral connection available in the location where the 28 Silicon Chip Fig.8: timing details of the PDP infrared remote control protocol. The first panel shows the timing of logic 0s and 1s (consisting of 38kHz bursts of IR energy). The second panel shows how these data bits are combined with the start frame and tail burst to encode a remote control button press. The third panel shows the repeat signal transmitted when a button is held down and the fourth panel shows the series of commands which result from pressing and then holding a button. These are followed by eight command bits, plus their one’s complement, indicating which function should be activated, then finally a 560µs “tail” burst to end the transmission. Note that the address and command data is sent with the least significant bit first. The complementary address and command bytes are sent as a way of detecting errors. If the complement data value received is not the complement of the data received then one or the other has been incorrectly detected and decoded. A lack of complementary data suggests that the received data is not in the PDP protocol and so the signal is being sent by a different handheld remote. After a button is pressed, if it continues to be held down, it will produce repeat frames. These consist of a 9ms burst, a 2.25ms pause and a 560µs burst. This is repeated at 110ms intervals. The repeat frame is used to inform the receiver to possibly repeat that particular function, depending on what it is. For example, “volume up” or “skip forward” actions may be repeated but “mute” may not. Dimmer is installed, the Neutral connection is made via the lamp load. In this case, power is only available to the circuit when the lamp is switched off. When the lamp is on, the voltage across Q1 and Q2 is less than 1V and this is insufficient to develop the 5V power supply voltage. Thus, the phase control range needs to be limited to less than the full mains cycle when there is no separate Neutral wire. That way, the lamp is not lit for the entire cycle, to make sure that there is still enough power available to run the rest of the circuit. This means the maximum lamp brightness is limited without the Neutral connection. Australia’s electronics magazine Dimming control The touch plate is connected to IC1’s pin 6 via two high-voltage 4.7Mresistors, while the optional extension board (for a second touch plate – or more) is connected to pin 7 via a standard 47kresistor. It is essential to use the resistors nominated (ie, Vishay VR37 series 4.7M). As well as limiting any current flow to a person touching the touch plate to besiliconchip.com.au low about 36µA, these particular resistors give a good safety margin as they are rated at 2.5kV (AC) each. Two resistors in series increase the voltage rating to 5kV, giving extra safety. Trust us; you definitely don’t want to risk becoming directly connected to the mains Active conductor – it hurts! And that applies to anyone else who will be using the dimmer, not just you. Usually, the input from the touch plate at pin 6 is held at 5V (ie, mains Active potential) by the 1Mpullup resistor but if the touch plate is touched, the ground capacitance of the person touching it brings the touch plate to ground potential when the Active voltage is trending upwards. This effectively pulls pin 6 down to supply ground for long enough to IC1 to detect this condition. The extension input at pin 7 is normally held low by the 10kresistor. It is pulled high to the 5V supply when the extension circuit touch plate is touched. The 47kresistor protects input pin 7 from transients or incorrect connections. Note that we need to use a separate input for extra touch plates. If we merely extended the pin 6 input to another switch plate, the extra capacitance and pickup from the extra line length would lead to false triggering on that high impedance input. Even if your loungeroom, etc has multiple LED lights on one switch, our trailingedge dimmer will handle them – up to a maximum of 250W. And as most domestic LED lights are in the order of 8-20W each, that’s an awful lot of LEDs that you can control. Infrared remote control Extension circuit If fitted, infrared receiver module IRD1 receives and demodulates the codes from the handheld infrared remote control. It incorporates an amplifier and automatic gain control plus a 38kHz bandpass filter to accept only remote control signals. It then detects and removes the 38kHz carrier. The resulting signal is applied to the pin 4 input of IC1, ready for code detection. The handheld IR remote is a small unit measuring only 80 x 40 x 7mm. It is powered by a CR2025 3V button cell. It has nine snap action pushbuttons on its front panel. The buttons include a Power on/off (“operate”) button, three buttons labelled A, B and C buttons and a 5-switch array for up, down, left, right and a central accept or OK button. The 5-button array is commonly used for volume and channel selectors or forward, reverse, left and right functions. There isn’t too much information about the electronics in the handheld The circuit of the extension board, required to add a second (or third…) touch plate to control the same set of lights is shown at the bottom of Fig.2. It is pretty simple as it is only a means for the extra touch plate(s) to send a signal to microcontroller IC1 on the main board, which then treats the event identically to a touch of its local plate. While the extension touch plate is not touched, PNP transistor Q3 is held off via the 1Mresistor between its base and emitter. When the touch plate is touched and the Active voltage is above Earth, Q3’s base is pulled low via the two safety resistors, diode D3 and the 2.2Mresistor. This switches on Q3 and the EXTN connection is pulled up to the Active potential, which is also the +5V supply for IC1 on the main board. This pulls pin 7 (digital input GP0) of IC1 high, sending it a signal that the plate has been touched. The 47nF capacitor acts as a filter siliconchip.com.au remote except that it uses a 16-pin surface-mount remote control IC, designated HB8101P. Each time a button is pressed, it transmits a unique code is by pulsing an infrared (IR) LED. The infrared signal is sent as 38kHz bursts, using what is known as Pulse Distance Protocol (PDP). This protocol is described in the adjacent panel. IC1 receives this signal and decodes it. If the signal is recognised as a valid code associated with a pushbutton on the IR remote, the required dimming function is activated. Australia’s electronics magazine and prevents sudden electrical transients (eg, lightning or EMI) from switching on Q3. This capacitor also acts to holds Q3 on sufficiently long enough for detection by IC1 on the main dimmers, even with a very quick tap on the plate. Zener diode ZD3 protects against excessive voltages at the cathode of diode D3 when the plate is being touched, as the potential difference could be hundreds of volts. Current is limited to a very low level by the safety resistors. Zener diode ZD4 and the 220resistor at the collector of Q3 provides protection if the connections to the main circuit are wired in reverse. In this case, ZD4 will be forward-biased, protecting Q3, while the 220resistor limits the fault current. A thinned section on the PCB will fuse if this connection is made for long. You would then have to repair it after fixing up the wiring. You also have the option of using a momentary contact mains-rate switch (eg, Clipsal 30MBPR and switch plate) instead of the extension board, as a secondary dimmer control/light switch. This just needs to be wired up to connect the Active and Extension (EXTN) terminals when pressed. Multiple extension boards can be wired in parallel, between the A and EXTN terminals, if you need more than two dimmer controls. Coming up next month In part 2 next month we will have all the construction and wiring details, testing and adjustment steps and some usage tips. SC February 2019  29