Sunday, 8 March 2009

sequel to slave concepts

2.making the gate triac pulses:

So every 20ms there's is a new sinus wave if you have a 50hz frequency distribution. The sinus wave is 50% positive and 50% negative which means also that the positive and negative have a duration of 10ms. The purpose is to let the triac conduct somewhere in these 10ms depending on the wanted duty cycle or lamp brightness. I noticed that the range between 0 -1ms and 9-10ms is not of much use anyway. It's also a fact that light strength (candelas) are not linear at all and have to be converted using some S-curve function (eg 1/1+e^x)

What I did was very simple. On every compare match interrupt ( see previous blog ) I fire a pulse with a wide of 5µs. The time needed for the pulse depends on the triac you use. The 5µs is made by the default avr lib delay function. At the end of the interrupt I put the PCINT back on again to catch the next zero crossing. See code snippet below:

ISR(TIMER1_COMPA_vect)
{
SETTRIAC;
_delay_us(TRIACPULSEWIDTH);
CLRTRIAC;
ENABLEPCINT;
}

That's basically it. So if you let say fire your pulse at 5ms you get 50% light intensity if you take 2ms you get 90% and finally 8ms you get 10%. Beware here that the light intensity is inverse equal on the fire time. Again if you really want to have a fluent light distribution you have to implement a S-curve.

No comments: