Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Triac firing angle control C code using microcontroller

Status
Not open for further replies.

McPlay

Newbie level 5
Joined
Feb 28, 2012
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,372
Good Morning

How do I write a code in C programming language to change the firing angle of a triac so I can alter the PWM (dimness) of a light bulb? I am using a. Atmega16 chip.

Regards,
McPlay
 

2 interrupts would do a precise job. First you can connect INT0 or 1 to the output of the zero-crossing detector. Then start a timer in the Interrupt Service Routine (ISR) initialized with the time you want to trigger the TRIAC. And then you can fire the TRIAC in corresponding timer's ISR. Usually a 16-bit timer can't attain its maximum value over Main's frequency cycle when microcontrollers are running at high frequencies. You can overcome this by using a counter to count the number of interrupts the running timer generates.

Regards...
 

I can't help with code but first you must decide if you are using PWM or phase control. Unless you are talking about very slow speed PWM with the light bulb flashing like morse code, it is phase control you want to use.
All you have to do is look for the zero crossing point in the AC waveform, call this "time zero", use it to reset and start a timer in the IC. Presumably you know the frequency of the AC so you can easily calculate the period, in other words how long one cycle lasts. All you have to do is produce a delay, starting at time zero and not exceeding one half cycle, at the end of that period fire the triac to turn it on. The earlier after time zero you fire the triac, the longer in that half cycle it spends conducting so the brighter the light bulb will be. The triac will turn off by itself when there is insufficient voltage across it at the next zero crossing point.


Brian.
 

1, zero crossing detector circuit
2, interrupt driven based pulse firing program
3, varies the firing time from zero cross detecting interrupt to firing time [ delay should be less than half cycle time period ]
4 , more time delay means low brightness



22_1345805482.gif
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top