Subversion Repositories FlightCtrl

Rev

Rev 1 | Rev 188 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 173
Line 21... Line 21...
21
void rc_sum_init (void)
21
void rc_sum_init (void)
22
//############################################################################
22
//############################################################################
23
{
23
{
24
        TCCR1B=(1<<CS11)|(1<<CS10)|(1<<ICES1)|(1<<ICNC1);//|(1 << WGM12); //timer1 prescale 64
24
        TCCR1B=(1<<CS11)|(1<<CS10)|(1<<ICES1)|(1<<ICNC1);//|(1 << WGM12); //timer1 prescale 64
Line 25... Line -...
25
 
-
 
26
 
25
 
27
// PWM
26
// PWM
28
//TCCR1A = (1 << COM1B1) | (1 << WGM11) | (1 << WGM10);
27
//TCCR1A = (1 << COM1B1) | (1 << WGM11) | (1 << WGM10);
29
//TCCR1B |= (1 << WGM12);
28
//TCCR1B |= (1 << WGM12);
Line 41... Line 40...
41
SIGNAL(SIG_INPUT_CAPTURE1)
40
SIGNAL(SIG_INPUT_CAPTURE1)
42
//############################################################################
41
//############################################################################
Line 43... Line 42...
43
 
42
 
44
{
43
{
45
        static unsigned int AltICR=0;
44
        static unsigned int AltICR=0;
46
    signed int signal = 0;
45
    signed int signal = 0,tmp;
Line 47... Line 46...
47
        static int index;              
46
        static int index;              
48
               
47
               
Line 64... Line 63...
64
            if((signal > 250) && (signal < 687))
63
            if((signal > 250) && (signal < 687))
65
                {
64
                {
66
                signal -= 466;
65
                signal -= 466;
67
                // Stabiles Signal
66
                // Stabiles Signal
68
                if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10;}
67
                if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10;}
69
                signal = (3 * (PPM_in[index]) + signal) / 4;  
68
                tmp = (3 * (PPM_in[index]) + signal) / 4;  
70
                //373 entspricht ca. 1.5ms also Mittelstellung
69
                if(tmp > signal+1) tmp--; else
-
 
70
                if(tmp < signal-1) tmp++;
71
                PPM_diff[index] = signal - PPM_in[index];
71
                PPM_diff[index] = tmp - PPM_in[index];
72
                PPM_in[index] = signal;
72
                PPM_in[index] = tmp;
73
                }
73
                }
74
            index++;  
74
            index++;  
75
    /*     if(index == 5) PORTD |= 0x20; else PORTD &= ~0x20;  // Servosignal an J3 anlegen
75
         if(index == 5) PORTD |= 0x20; else PORTD &= ~0x20;  // Servosignal an J3 anlegen
76
         if(index == 6) PORTD |= 0x10; else PORTD &= ~0x10;  // Servosignal an J4 anlegen
76
         if(index == 6) PORTD |= 0x10; else PORTD &= ~0x10;  // Servosignal an J4 anlegen
77
         if(index == 7) PORTD |= 0x08; else PORTD &= ~0x08;  // Servosignal an J5 anlegen */
77
         if(index == 7) PORTD |= 0x08; else PORTD &= ~0x08;  // Servosignal an J5 anlegen 
78
        }
78
        }
79
        }
79
        }
80
}
80
}