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.

Dimming Three AC lamps

Status
Not open for further replies.

ArdyNT

Full Member level 2
Joined
Nov 6, 2012
Messages
126
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Activity points
2,304
I need to dim three ac lamps and i decide to use timer0 tmer1 and timer2. I use the principle of phase firing angle and I want the lamps have different intensity. Now I don't understand why this code in timer0 and timer2 overflow is not working.

Code:
interrupt [EXT_INT0] void ext_int0_isr(void)
{
    // Activate Timer0 with prescaler 1024
    TCCR0=0x05;    
}


// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
    if(ldr1>=700)
    {
        if(TCNT0>=250)
        {
            TCNT0=TCNT0+5;
        }
    }
    
    
    if(ldr1<=600)
    {
        if(TCNT0<=155)
        {
            TCNT0=TCNT0-5;
        }
    }
    
    PORTD.0 = 0;      
    delay_us(30);     
    PORTD.0 = 1;     
    TCCR0=0x00;    
}

And this code in timer1 compare is working very well

Code:
interrupt [EXT_INT0] void ext_int0_isr(void)
{
    // Activate Timer1 with prescaler 8
    TCCR0=0x02;    
}

interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
    if(ldr2<=600)
    {
        if(OCR1A>=150)
        {
        OCR1A=OCR1A-100;
        }
    }
        
    if(ldr2>=700)
    {
        if(OCR1A<=13500)
        {
        OCR1A=OCR1A+100;
        }   
    }
       
    TCNT1H=0x00;
    TCNT1L=0x00;

    PORTB.1 = 0; 
    delay_us(50);     
    PORTB.1 = 1;   

    TCCR1B=0x00;
}

Help me please
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top