Wednesday, November 16, 2011

PIC Based Auto Dimmer

The operation of the dimmer is based on phase control; during a full cycle of an AC waveform, a thyristor will only allow a part of the waveform to be delivered to the load. Take a look at the following waveforms:


The only difference is that the waveform on the left will bright the lamp higher than the waveform on the right. That is because, on the left waveform, the triac will be conductive earlier than the triac shown in the right waveform.

 The time that the triac becomes conductive is symbolized with the Greek letter α (ALPHA) , called firing angle, so controlling this angle you can control the phase voltage, and is measured in angles from the zero point of the waveform. This zero point is the point that the voltage is 0 volts, and this happens 2 times every one full period of the wave form. When the α becomes smaller, then the dimmer becomes conductive sooner and the lamp is brighter. When the α becomes bigger, then the triac delays more to become conductive and thus the lamb is dimmer. 

A full wavelength period is 360 degrees (2π). Due to the fact that during a full wave length the zero cross occurs twice, α can take values from 0° to 180 degrees (0 - π). When α = 0°, the full power is delivered to the load and when α = π, no power is delivered to the load.

The zero cross detection circuit is the most critical part when designing a dimmer. This circuit will watch the input power waveform and detect when this waveform crosses the 0 point and becomes 0 volts.

Zero cross detection circuits are mainly used in cases when the dimmers needs to be controlled from a micro controller. In that case, the micro-controller needs to know the zero cross detection point of the waveform, so that it can calculate the angle offset to send the trigger pulse to the gate of the triac.

In this case i am using three second delay for auto changing the brightness and interrupt for zero crossing. The range required for my test is 10% to 90% means  22v to 198v for 220v ac.
Also note me using 4Mhz crystal with 22pF capacitors. 


Download: Code n Files

MCU Based Auto Dimmer
Components Required:
R1-R3, R6-------------------------10k ohm
R7-R8-----------------------------1k ohm
C1----------------------------------10nF Ceramic
U2----------------------------------BT136 Triac
Bridge Rectifier
4MHz Crystal
22pF Ceramic   (2)


  1. What program used for code in C,Mikroc,what?

  2. Hi, I am looking for an application for running a 220v heating element at partial power. Is your hookup from the two opposite ends of the 220v wave? I find a lot of Triac designs showing Hot to Neutral, is this the hot to hot on the 220v phase?

    1. its Hot to Neutral; and Neutral is also connected to ground of the circuit (Be careful this circuit is not isolated).

  3. Amigo un saludo interesante tu trabajo pero me podrias decir cual de las resistencia le cambio por el potenciometro gracias