light dimmer using PIC16

Thread Starter

naresh5555

Joined Mar 3, 2017
11
Hi every one I am planing to do light dimmer project . I am new to coding . I completed all hardware portion . Hardware portion includes Zero crossing with with isolation and TRAIC driver (MOC3020). Any one suggest me one example code for the light dimmer .
 

ErnieM

Joined Apr 24, 2011
8,108
Microchip themselves have some app notes on doing this or similar. May not be a dimmer, just on and off, but that is a start.
 

MaxHeadRoom

Joined Jul 18, 2013
22,346
Microchip AN958 and Fairchild AN-3006.
Microchip have the code for a electronic burst thermostat and a dimmer.
I am working on one of right now.
Max.
 

Thread Starter

naresh5555

Joined Mar 3, 2017
11
Microchip AN958 and Fairchild AN-3006.
Microchip have the code for a electronic burst thermostat and a dimmer.
I am working on one of right now.
Max.
Hi MaxHeadRoom , Thank you for reply .
I am looking for the code can you suggest me some example code for pic controllers .
 

Sensacell

Joined Jun 19, 2012
2,720
Pay special attention to the Zero-Xing detector, it's the heart of it- and surprisingly hard to get right.

Your code could be perfect, but it will work like crap because the thing creates extra pulses, operates erratically, etc.
It's tricky because it's looking for a very small voltage change around zero, and must also deal with full mains voltage.
The biggest problem usually is extra noise pulses, check it on the scope before making any assumptions.
 

Thread Starter

naresh5555

Joined Mar 3, 2017
11
Here is a PDF from microchip with C and ASM programs. The circuit didn't use step down transformer power supply so it is only good for reference.

And here is an extensive discussion on AC load control and the AC zero crossing is well explained.

Allen
Hello absf thank you for your reply i tried with code and i did the coding .All working fine but iam dimming with ir so when I am pressing the ir control light also getting interrupt . Ir is in interrupt routine . And for light dimming I am using a compare mode to archive 10 ms Pwm . suggest me .
 

MrAl

Joined Jun 17, 2014
7,965
Hello,

I saw the Microchip reference design some time ago but did not go over the hardware design or the code. A few notes here anyway.

First, you dont need a 16F device as the lower end devices like 12F will work fine for this.

Second, one thing to be careful about, very careful, is the code timing vs the line frequency. The line frequency can change slightly (check local specs) so what works today may not work tomorrow if the code timing is too tight. In particular, the timing for the longest delay before the triac gate trigger pulse occurs. If the delay is too close to the half cycle period and the line frequency increases slightly, you end up missing an entire half cycle and then triggering at the start of the next half cycle. This causes half cycles to be spit out rather than tiny portions of the full cycle which should cause a very low output power. The half cycles not only contain more energy, they also can screw up various devices that depend on both half cycles for proper operation.

Third, always use a pulse to turn on the triac, not a continuous gate signal. This keeps gate power dissipation down. Check data sheets for specs on this. Make sure the pulse always ends before the start of the next half cycle.
 

DickCappels

Joined Aug 21, 2008
6,962
A small aside, I think there is a problem in your triac circuit.
upload_2017-3-13_20-17-58.png
The pin marked "2" is Main Terminal 1 ("MT1"). When you connect the gate to MT1 you keep it from coming on. If you want the optocoupler to turn on the Triac (what else could it be for?) you will need to connect the gate to the same polarity as MT2 which is pin #1 in your schematic, usually through a current limiting resistor. A second resistor connects between the gate and MT1 to keep the triac off when no actively driven by the coupler.

An arrangement such as shown in the schematic fragment below should work well.

upload_2017-3-13_20-25-24.png

For reference:
https://en.wikipedia.org/wiki/TRIAC
 
Top