Subversion Repositories FlightCtrl

Rev

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

Rev 2486 Rev 2488
Line 88... Line 88...
88
//############################################################################
88
//############################################################################
89
// Interrupt function for the PPM-Input
89
// Interrupt function for the PPM-Input
90
ISR(TIMER1_CAPT_vect)
90
ISR(TIMER1_CAPT_vect)
91
//############################################################################
91
//############################################################################
92
{
92
{
93
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
-
 
94
if(!(EE_Parameter.ExtraConfig & CFG_SENSITIVE_RC))
-
 
95
#endif
-
 
96
 {
-
 
97
        static unsigned int AltICR=0;
93
        static unsigned int AltICR=0;
98
    signed int signal = 0,tmp;
94
    signed int signal = 0,tmp;
99
        static int index;
95
        static int index;
Line 100... Line 96...
100
 
96
 
Line 120... Line 116...
120
                    if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10; else SenderOkay = 200;}
116
                    if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10; else SenderOkay = 200;}
121
                                  }    
117
                                  }    
122
                tmp = (3 * (PPM_in[index]) + signal) / 4;
118
                tmp = (3 * (PPM_in[index]) + signal) / 4;
123
                if(tmp > signal+1) tmp--; else
119
                if(tmp > signal+1) tmp--; else
124
                if(tmp < signal-1) tmp++;
120
                if(tmp < signal-1) tmp++;
125
                PPM_in[index] = tmp;
-
 
126
                if(SenderOkay >= 195)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3;
121
                if(SenderOkay >= 195)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3;
127
                else
122
                                else PPM_diff[index] = 0;
128
                                 {
-
 
129
                                  PPM_diff[index] = 0;
123
                                PPM_in[index] = tmp;
130
                                  if(SenderOkay < 50)
124
                                if(SenderOkay < 50)
131
                                        {                                
125
                                        {                                
132
                                                PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
126
                                                PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
133
                                                PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
127
                                                PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
134
                                                PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
128
                                                PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
135
                                                PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] = 0;
129
                                                PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] = 0;
136
                                        }
130
                                        }
137
                                 }
-
 
138
                }
131
                }
139
            index++;
132
            index++;
140
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
-
 
141
#else
-
 
142
/*
133
/*
143
                   if(PlatinenVersion < 20)
134
                   if(PlatinenVersion < 20)
144
            {  
135
            {  
145
             if(index == 5) J3High; else J3Low;  // Servosignal an J3 anlegen
136
             if(index == 5) J3High; else J3Low;  // Servosignal an J3 anlegen
146
             if(index == 6) J4High; else J4Low;  // Servosignal an J4 anlegen
137
             if(index == 6) J4High; else J4Low;  // Servosignal an J4 anlegen
147
             if(index == 7) J5High; else J5Low;  // Servosignal an J5 anlegen
138
             if(index == 7) J5High; else J5Low;  // Servosignal an J5 anlegen
148
                        }
139
                        }
149
*/
140
*/
150
#endif
-
 
151
        }
141
        }
152
        }
142
        }
153
 }
-
 
154
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
-
 
155
 else
-
 
156
 {
-
 
157
        static unsigned int AltICR=0;
-
 
158
    static int ppm_in[13+4];
-
 
159
    static int ppm_diff[13+4];
-
 
160
    static int old_ppm_in[13+4];
-
 
161
    static int old_ppm_diff[13+4];
-
 
162
    signed int signal = 0,tmp;
-
 
163
        static unsigned char index, okay_cnt = 0;
-
 
164
        signal = (unsigned int) ICR1 - AltICR;
-
 
165
        AltICR = ICR1;
-
 
166
    //Syncronisationspause? (3.52 ms < signal < 25.6 ms)
-
 
167
        if((signal > 1100) && (signal < 8000))
-
 
168
        {
-
 
169
        tmpChannels = index;
-
 
170
        if(tmpChannels >= 4 && Channels == tmpChannels)
-
 
171
                 {
-
 
172
          if(okay_cnt > 10)
-
 
173
                   {
-
 
174
                   NewPpmData = 0;  // Null bedeutet: Neue Daten
-
 
175
                   for(index = 0; index < 13+4; index++)
-
 
176
                    {
-
 
177
                         if(okay_cnt > 30)
-
 
178
                          {
-
 
179
                           old_ppm_in[index] = PPM_in[index];
-
 
180
                           old_ppm_diff[index] = PPM_diff[index];
-
 
181
                          }
-
 
182
                     PPM_in[index] = ppm_in[index];
-
 
183
                     PPM_diff[index] = ppm_diff[index];
-
 
184
                    }
-
 
185
                   }
-
 
186
          if(okay_cnt < 255) okay_cnt++;
-
 
187
                 }
-
 
188
         else
-
 
189
                  {
-
 
190
                   if(okay_cnt > 100) okay_cnt = 10; else okay_cnt = 0;
-
 
191
                   ROT_ON;
-
 
192
                  }
-
 
193
        index = 1;
-
 
194
        if(!MotorenEin) Channels = tmpChannels;
-
 
195
        }
-
 
196
        else
-
 
197
        {
-
 
198
        if(index < 13+4)
-
 
199
            {
-
 
200
            if((signal > 250) && (signal < 687))
-
 
201
                {
-
 
202
                signal -= PPM_Neutral;
-
 
203
                // Stabiles Signal
-
 
204
                if((abs(signal - ppm_in[index]) < 6))
-
 
205
                                 {
-
 
206
                                  if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100)  // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe
-
 
207
                                  {
-
 
208
                                   if(okay_cnt > 25)  SenderOkay += 10;
-
 
209
                                   else
-
 
210
                                   if(okay_cnt > 10)  SenderOkay += 2;
-
 
211
                                   if(SenderOkay > 200) SenderOkay = 200;
-
 
212
                                  }
-
 
213
                                 }
-
 
214
                tmp = (3 * (ppm_in[index]) + signal) / 4;
-
 
215
                if(tmp > signal+1) tmp--; else
-
 
216
                if(tmp < signal-1) tmp++;
-
 
217
                if(SenderOkay >= 190)  ppm_diff[index] = ((tmp - ppm_in[index]) / 3) * 3;
-
 
218
                else ppm_diff[index] = 0;
-
 
219
                ppm_in[index] = tmp;
-
 
220
                }
-
 
221
                        else ROT_ON;
-
 
222
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
-
 
223
#else
-
 
224
                   if(PlatinenVersion < 20)
-
 
225
            {  
-
 
226
             if(index == 5) J3High; else J3Low;  // Servosignal an J3 anlegen
-
 
227
             if(index == 6) J4High; else J4Low;  // Servosignal an J4 anlegen
-
 
228
             if(index == 7) J5High; else J5Low;  // Servosignal an J5 anlegen
-
 
229
                        }
-
 
230
#endif
-
 
231
          }
-
 
232
                  if(index < 20) index++;
-
 
233
          else
-
 
234
                  if(index == 20)
-
 
235
                  {
-
 
236
            unsigned char i;
-
 
237
            ROT_ON;
-
 
238
                    index = 30;
-
 
239
            for(i=0;i<13+4;i++) // restore from older data
-
 
240
                         {
-
 
241
                      PPM_in[i] = old_ppm_in[i];
-
 
242
                      PPM_diff[i] = 0;
-
 
243
//                        okay_cnt /= 2;
-
 
244
                 }
-
 
245
                  }
-
 
246
            }
-
 
247
 }
-
 
248
#endif
-
 
249
 
-
 
250
}
143
}
Line 251... Line 144...
251
 
144
 
252
#else
145
#else
253
//############################################################################
146
//############################################################################