how to change blinking to dimming of AC light Bulb

General discussion on mikroC.
Post Reply
Author
Message
Danyel
Posts: 2
Joined: 18 Jun 2011 01:34

how to change blinking to dimming of AC light Bulb

#1 Post by Danyel » 18 Jun 2011 02:18

Hello,
I am dealing with Micro controller based light dimmer, my circuit consists of PIC 16F876A connected with zero crossing detector and an AC bulb,
After programming PIC bulb is blinking instead of dimming.
can you help me wit this situation
unsigned Duty;

void InitMain()
{

TRISC=0x00;
PORTC=0x00;
PWM1_Init(10000);
}

void main()
{
InitMain();
while(1)
{
PWM1_Start();
PWM1_Set_Duty(0); // 0% Duty cycle
Delay_us (10);

PWM1_Start();
PWM1_Set_Duty(51); // 20% Duty cycle
Delay_us (10);

PWM1_Start();
PWM1_Set_Duty(102); // 40% Duty cycle
Delay_us (10);

PWM1_Start();
PWM1_Set_Duty(153); // 60% Duty cycle
Delay_us (10);

PWM1_Start();
PWM1_Set_Duty(204); // 80% Duty cycle
Delay_us (10);

PWM1_Start();
PWM1_Set_Duty(255); // 100% Duty cycle
Delay_us (10);

}
}

rayann
Posts: 14
Joined: 20 Jan 2010 20:25
Location: Faroe Islands

Re: how to change blinking to dimming of AC light Bulb

#2 Post by rayann » 28 Jun 2011 19:21

Hey, I am maybee not the right one to help your programming, I am an electrician. I assume you are talking about 50 hz AC power. You need to create the power part with a triac, and then let the pic control the triggering. You can use rising or falling edge triggering, (for a normal bulb it make no difference). you have to count 0 to 10 m sek for each half period (use a timer) and then (say rising edge) trigg after 5 msek after zero crossing(for half speed). to use the PWM function you need to run it 50 Hz with syncronisation to the AC power, and that may be a bit difficult.
raymund

Post Reply

Return to “mikroC General”