Safety First: The high voltage circuitry is covered with a plastic transparent cup.
Actually, i plan to make a 4-channel DC controlled lamp dimmer. Unfortunately, looking in my stock cabinet, i found out that i had run out of 16F690... Yet, i had to make the programming ASAP! Thus, i made a single channel PIC with the 12F615. I will use the same routine for the 4-channel dimmer, when the courier arrives.
If you do not know how the AC Dimmer works, try this link:
This dimmer, like the 555 dimmer that i made some weeks ago, will be controlled with a DC voltage level. The original design will be controlled with 0 to 5 volts, but using a voltage divider, you can increase this number as much as you like. I use a potentiometer to adjust the control DC voltage, you can use whichever DC voltage source. You may use for example a photocell and a resistor to make an ambient light equalizer...
Here is the schematic diagram:
The transformer is used to provide both power to the circuit and to get the zero cross detection pulse. The 7805 is used to fix the supply to 5 Volts. There are 2 potentiometers connected in series. The first one (R7), is used to set the minimum luminosity (that needs the maximum trigger delay). The R3 is used to control the dimmer! This is actually the control potentiometer.
I hate messing high and low voltages. SAFETY FIRST! That's why i use the transformer for the zero cross detection (and not just some 4 MOhm resistors), and that's why i use the optocoupler. I use the MOC3021, for Greece has 220V mains. For 110/120 volts you may consider using the MOC3011. Check out the datasheet of the MOC series (find it in the Bill Of Materials section at the end of this article).
I use the BT136D TRIAC to control the lamp. It can handle up to 4 Amperes load. Translated into wattage for 220 Volts lamp, this is up to 880 Watts lamp... It is enough for your household lamps, isn't it? If not, then use another TRIAC.
Adjusting the circuit
The adjustment of this circuit is very simple. First of all you need to connect the potentiometer R3 correctly, so that when is turned to the left, the lamp will fade. If you are sure that is connected correct, proceed to the next step.
Put the R7 in the middle. Turn the R3 completely to the left (OFF position). Then turn it a few degrees to the right, not too much, about 2 degrees. Using a insulated small screwdriver, turn the R7 slowly and steady, so that the lamp is turned off. When the lamp is off completely, the dimmer is adjusted! That's it.
The Firmware
Not much to say about the firmware. There are 2 parameters that you may need to change, if the frequency of your power supply is not 50Hz. The GLMinVal, sets the minimum trigger delay value - that is the maximum luminosity. This parameter defines the point above which the lamp will be 100% powered. The GLMaxVal on the other hand, controls the max trigger delay - that is the minimum lamp luminosity. This is the value below which the lamp is turned off completely. Change the values with caution if you are not 100% sure what you are doing.
Here is the full assembly listing for the firmware, to compile and upload:
Hi there again (wrote on 13 Jan). Tried the circuit, works well. Only I found that I needed a 2k2 Ohm resistor between 5V and the 2k2 trimpot to get a turn off point middway otherwise the trimpot had to be fully anticlockwise. Any downside in the PIC ADC calculation by adding this ?
Hi there, great circuit, looking forward to trying this out next week. Can you tell me one thing - why do you have a heat sink on the 7805, I would expect only a relatively small current used in the 5 volt section with only the PIC and optocoupler devices ?
@Rich i've been told that again from people using a specific IE version. Try with mozilla or chrome
At 10 December 2011, 2:26:58 user Rich wrote: [reply @ Rich]
Hi:
2nd e-mail about this. For some reason I can not view the assembly code listing. I like to build this circuit and need to program the PIC. Could you e-mail me the assembly code listing? Many thanks in advance. Richard
@Pratik if you know how dimmer works and a little bit about assembly, then this is a simple program. The main idea is that within the MainLoop, it constantly reads the ADC to get new TriggerDelay value, which is actually the delay from the time that the circuit detects a zero-cross, until the PIC triggers the triac.
Then, in Cont1 the pic tests the timer0 module. This module becomes zero every time that the PIC detects zero-cross (interrupt routine). If the tmr becomes higher than the TriggerDelay, then the PIC activates the triac (bsf Trigger). The triac gate is also cleared within the interrupt routine.
Dimmers always add some kind of noise in the power lines. To avoid noise, you need to add filters, but i am not good at this. A small load will not add significant noise. But remember that a hair dryer adds much more noise than any dimmer.
As for the halogens, i have never test anything with them, so i cannot answer.
At 1 November 2011, 12:50:49 user Pratik wrote: [reply @ Pratik]
Great post and great work,
I am doing this same project and i want to dim three halogen. It would be great of you if i get some help in understanding your assembly program. I need to know what are you doing in the program. About How and when is the triac triggered . A good flowchart and little explanation will clear my doubts.I have heard that noise is generated with this methos . Is it true.If yes what is the other solution.
Also i want to know whether i can convert ac to dc and then make use of IGBTS or Mosfet to dim the halogens. If so How can I do this. Any ideas can be useful to me.
regards,
Pratik
@DAVID there is no mistake. I checked. This is what datasheet states about ANSEL,3
bit 3 - ANS3: Analog Select Between Analog or Digital Function on Pin GP4
1 = Analog input. Pin is assigned as analog input(1).
0 = Digital I/O. Pin is assigned to port or special function.
It is for GP4 (pin 3)
At 16 April 2011, 11:30:02 user DAVID wrote: [reply @ DAVID]
bsf ansel,3 ; 1000 GPIO 3 IS ADC INPUT
YOUR CODE SEEMS TO SET gpio3 AS INPUT FOR ADC BUT IS INFACT CONNECTED TO GPIO4 ON PIN 3 WHICH bit is wrong the code or the schematic..
I was interested in the zero-crossing too but that is unfiltered "DC" after the rectifiers. Enough to trigger the pulse in his circuit. I used this to learn circuit modeling and the model generates a beautiful pulse just like his video.
Zero crossing point detection is only used on AC circuits, so why did you bother putting it on this DC circuit, its not doing anything. the bridge rectifier is producing DC from the AC, so anything after the bridge is DC, and does not have a sinusoidal wave for the zero point to detect. Your just wasting components and potentially endangering your life by messing around with mains voltage when you obviously have no idea what your doing.
Hello Everyone.
I have a doubt regarding the programming of the microcontroller. You have actually given the binary file, is it possible for the programmer(the brain behind the heart of the circuit) to upload the algorithm and if possible the c program of the same binary file.
Thank You well in advance and I hope for a quick reply.
R7 is to be changed but the specification you have to find it yourself
At 3 March 2011, 14:48:16 user dee wrote: [reply @ dee]
hi,
for using it for automatic light regulation , which part is to be replaced with photocell and which photocell(specifications)we have to use.
pls help its urgent.
This is an excellent and well-explained analog and digital project. Being new to PICs, while the circuit and video make sense, I am struggling with programming since I use basic. Would you mind helping myself and others with a description of the logic of your programming? Much appreciated!
I would never sleep quiet if i had a dimmer without galvanic insulation between mains and PIC. I began with a huge resistor (4 o 8 MOhms i do not remember), and worked perfectly, until i asked myself one single thing: And if the resistor fails??? It is most unlikely, but again, this galvanic insulation keeps the circuit itself safer as there is no connection with ground.
At 23 December 2010, 7:34:52 user Matt wrote: [reply @ Matt]
Excellent approach, especially with regards to electrical safety. I have seen other designs which are directly coupled to the mains but I prefer this way to get the zero-crossing signal after isolating from the mains with the transformer. Use of the optocoupler on the triac side again keeps the pic safely isolated from the mains. Brilliant - I will choose this approach for my dimmer circuit design and I hope others will too.