Programmable Lamp Dimmer using pic microcontoller
Also known as the “Sketch as Fuck Lamp Dimmer” per my friend Eric, the design originating from this application note in general has the usual lamp dimmer topology: a zero detector, a timer, and a triac. These three components implement phase cutting, specifically the triac performs phase cutting on AC current from mains supplied to a load. The first two components, the zero detector and timer, are both implemented in a microcontroller, the subject of the application note.
However, this circuit is unusual in terms of its logic power supply, whose ground is not connected to the neutral of mains. Rather, the 5V node is connected to the hot wire of mains, and the 0V node is constructed 5 volts below that wire.
One consequence of this is that, while plugged into mains, the logic of this circuit cannot be connected to any logic that is grounded to the neutral of mains unless the signals have some isolation. For example, I couldn’t connect connect my PIC programmer to the circuit while the circuit was plugged into mains without something exploding! To get around this, I plugged my circuit into an isolation transformer prior to mains during the latter part of programming the circuit, after I had confirmed my circuit functioned correctly electrically. As discussed later, this design is necessary to achieve proper biasing in the circuit, and you can see this power supply in other circuits as well–for example the application note for another lamp dimmer from ST.
Amused by this application note, I decided to build my own programmable lamp dimmer circuit. There are a couple neat techniques I took to make this project, so I’ll go through them one by one.
Power Supply Component Sizing and Theory of Operation
The application note intends to point out the low power consumption of the PIC10F microcontroller. As an example, it suggests building a lamp dimmer whose logic power supply resembles a 5V linear zener regulator. The power supply schematic from Eagle is given below–the 5V and 0V nodes are the power supply for the microcontroller. pic of power supply caption: This regulator converts mains 120VAC to 5V; mains is plugged into the connection indicated, with hot connected to the upper wire and neutral the lower wire. Normally, a linear regulator is not appropriate for converting between such disparate voltages — 120V (rms) to 5V. The voltage change is implemented by dropping the difference in voltage across a resistor, the 22k resistor in this case. Really, the only advantages to this kind of circuit are the relatively low number of parts, the cheapness of those parts, and the small footprint of those parts. For example, a circuit of components of this size could be embedded in the plug of a lamp itself, perhaps as a feature or a prank.
However, since what we intend to be the 5V node of the power supply is connected to hot, let’s instead consider the relationship between hot and neutral with hot as our reference voltage. This is still a sine wave, we’re just using neutral as our fixed reference, as shown in the following plot, where neutral is blue and hot is red.
The rectifier diode may make this circuit hard to understand for someone who understands a regular zener regulator, so let me replace it with an ideal diode with no diode drop–rather, it conducts like a wire when it is forward biased and does not conduct when it is reverse biased. Then, the circuit is always one of the two circuits in the following image.
For more detail: Programmable Lamp Dimmer
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days
Current Project / Post can also be found using:
- pic microcontroller reverse phase cut dimmer
- light dimmer circuit using pic microcontroller
- ac dimmer using pic microcontroller explanation
- ac lamp dimmer using triac and pic16f877a