Rev 1122 | Rev 1131 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1122 | Rev 1124 | ||
---|---|---|---|
Line 145... | Line 145... | ||
145 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
145 | signed int ExternStickNick = 0, ExternStickRoll = 0, ExternStickGier = 0, ExternHoehenValue = -20; |
146 | int MaxStickNick = 0,MaxStickRoll = 0; |
146 | int MaxStickNick = 0, MaxStickRoll = 0; |
147 | unsigned int modell_fliegt = 0; |
147 | unsigned int modell_fliegt = 0; |
148 | unsigned char MikroKopterFlags = 0; |
148 | unsigned char MikroKopterFlags = 0; |
Line 149... | Line 149... | ||
149 | 149 | ||
150 | void Piep(unsigned char Anzahl) |
- | |
151 | { |
150 | void Piep(unsigned char Anzahl) { |
152 | while(Anzahl--) |
- | |
153 | { |
151 | while (Anzahl--) { |
154 | if(MotorenEin) return; //auf keinen Fall im Flug! |
152 | if (MotorenEin) return; //auf keinen Fall im Flug! |
155 | beeptime = 100; |
153 | beeptime = 100; |
156 | Delay_ms(250); |
154 | Delay_ms(250); |
157 | } |
155 | } |
Line 158... | Line 156... | ||
158 | } |
156 | } |
159 | 157 | ||
- | 158 | //############################################################################ |
|
160 | //############################################################################ |
159 | // Nullwerte ermitteln |
161 | // Nullwerte ermitteln |
160 | |
162 | void SetNeutral(void) |
161 | void SetNeutral(void) |
163 | //############################################################################ |
162 | //############################################################################ |
164 | { |
163 | { |
Line 184... | Line 183... | ||
184 | AdNeutralRoll= AdWertRoll; |
183 | AdNeutralRoll = AdWertRoll; |
185 | AdNeutralGier= AdWertGier; |
184 | AdNeutralGier = AdWertGier; |
186 | AdNeutralGierBias = AdWertGier; |
185 | AdNeutralGierBias = AdWertGier; |
187 | StartNeutralRoll = AdNeutralRoll; |
186 | StartNeutralRoll = AdNeutralRoll; |
188 | StartNeutralNick = AdNeutralNick; |
187 | StartNeutralNick = AdNeutralNick; |
189 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) |
188 | if (eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) { |
190 | { |
- | |
191 | NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY; |
189 | NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY; |
192 | NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY; |
190 | NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY; |
193 | NeutralAccZ = Aktuell_az; |
191 | NeutralAccZ = Aktuell_az; |
194 | } |
- | |
195 | else |
192 | } else { |
196 | { |
- | |
197 | NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]); |
193 | NeutralAccX = (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK + 1]); |
198 | NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]); |
194 | NeutralAccY = (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL + 1]); |
199 | NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]); |
195 | NeutralAccZ = (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z + 1]); |
200 | } |
196 | } |
Line 225... | Line 221... | ||
225 | FromNaviCtrl_Value.Kalman_K = -1; |
221 | FromNaviCtrl_Value.Kalman_K = -1; |
226 | FromNaviCtrl_Value.Kalman_MaxDrift = EE_Parameter.Driftkomp * 16; |
222 | FromNaviCtrl_Value.Kalman_MaxDrift = EE_Parameter.Driftkomp * 16; |
227 | FromNaviCtrl_Value.Kalman_MaxFusion = 32; |
223 | FromNaviCtrl_Value.Kalman_MaxFusion = 32; |
228 | } |
224 | } |
Line -... | Line 225... | ||
- | 225 | ||
- | 226 | void LesePotis(void) { |
|
- | 227 | /* Warum 110? Knüppel geht von -125 bis 125! |
|
- | 228 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
|
- | 229 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
|
- | 230 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
|
- | 231 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
|
- | 232 | */ |
|
- | 233 | if (Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 125) Poti1++; |
|
- | 234 | else if (Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 125 && Poti1) Poti1--; |
|
- | 235 | if (Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 125) Poti2++; |
|
- | 236 | else if (Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 125 && Poti2) Poti2--; |
|
- | 237 | if (Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 125) Poti3++; |
|
- | 238 | else if (Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 125 && Poti3) Poti3--; |
|
- | 239 | if (Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 125) Poti4++; |
|
- | 240 | else if (Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 125 && Poti4) Poti4--; |
|
- | 241 | if (Poti1 < 0) Poti1 = 0; |
|
- | 242 | else if (Poti1 > 255) Poti1 = 255; |
|
- | 243 | if (Poti2 < 0) Poti2 = 0; |
|
- | 244 | else if (Poti2 > 255) Poti2 = 255; |
|
- | 245 | if (Poti3 < 0) Poti3 = 0; |
|
- | 246 | else if (Poti3 > 255) Poti3 = 255; |
|
- | 247 | if (Poti4 < 0) Poti4 = 0; |
|
- | 248 | else if (Poti4 > 255) Poti4 = 255; |
|
- | 249 | } |
|
229 | 250 | ||
230 | //############################################################################ |
251 | //############################################################################ |
- | 252 | // Bearbeitet die Messwerte |
|
231 | // Bearbeitet die Messwerte |
253 | |
232 | void Mittelwert(void) |
254 | void Mittelwert(void) |
233 | //############################################################################ |
255 | //############################################################################ |
234 | { |
256 | { |
235 | static signed long tmpl,tmpl2; |
257 | static signed long tmpl, tmpl2; |
Line 256... | Line 278... | ||
256 | Mess_Integral_Gier += MesswertGier; |
278 | Mess_Integral_Gier += MesswertGier; |
257 | // Mess_Integral_Gier2 += MesswertGier; |
279 | // Mess_Integral_Gier2 += MesswertGier; |
258 | if(ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR; // 360° Umschlag |
280 | if (ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR; // 360° Umschlag |
259 | if(ErsatzKompass < 0) ErsatzKompass += 360L * GIER_GRAD_FAKTOR; |
281 | if (ErsatzKompass < 0) ErsatzKompass += 360L * GIER_GRAD_FAKTOR; |
260 | // Kopplungsanteil +++++++++++++++++++++++++++++++++++++ |
282 | // Kopplungsanteil +++++++++++++++++++++++++++++++++++++ |
261 | if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) |
283 | if (!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) { |
262 | { |
- | |
263 | tmpl = (MesswertGierBias * Mess_IntegralNick) / 2048L; |
284 | tmpl = (MesswertGierBias * Mess_IntegralNick) / 2048L; |
264 | tmpl *= Parameter_AchsKopplung1; //125 |
285 | tmpl *= Parameter_AchsKopplung1; //125 |
265 | tmpl /= 4096L; |
286 | tmpl /= 4096L; |
266 | tmpl2 = (MesswertGierBias * Mess_IntegralRoll) / 2048L; |
287 | tmpl2 = (MesswertGierBias * Mess_IntegralRoll) / 2048L; |
267 | tmpl2 *= Parameter_AchsKopplung1; |
288 | tmpl2 *= Parameter_AchsKopplung1; |
268 | tmpl2 /= 4096L; |
289 | tmpl2 /= 4096L; |
269 | if(labs(tmpl) > 128 || labs(tmpl2) > 128) TrichterFlug = 1; |
290 | if (labs(tmpl) > 128 || labs(tmpl2) > 128) TrichterFlug = 1; |
270 | } |
- | |
271 | else tmpl = tmpl2 = 0; |
291 | } else tmpl = tmpl2 = 0; |
272 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
292 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
273 | MesswertRoll += tmpl; |
293 | MesswertRoll += tmpl; |
274 | MesswertRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109 |
294 | MesswertRoll += (tmpl2 * Parameter_AchsGegenKopplung1) / 512L; //109 |
275 | Mess_IntegralRoll2 += MesswertRoll; |
295 | Mess_IntegralRoll2 += MesswertRoll; |
276 | Mess_IntegralRoll += MesswertRoll - LageKorrekturRoll; |
296 | Mess_IntegralRoll += MesswertRoll - LageKorrekturRoll; |
277 | if(Mess_IntegralRoll > Umschlag180Roll) |
297 | if (Mess_IntegralRoll > Umschlag180Roll) { |
278 | { |
- | |
279 | Mess_IntegralRoll = -(Umschlag180Roll - 25000L); |
298 | Mess_IntegralRoll = -(Umschlag180Roll - 25000L); |
280 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
299 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
281 | } |
300 | } |
282 | if(Mess_IntegralRoll <-Umschlag180Roll) |
301 | if (Mess_IntegralRoll <-Umschlag180Roll) { |
283 | { |
- | |
284 | Mess_IntegralRoll = (Umschlag180Roll - 25000L); |
302 | Mess_IntegralRoll = (Umschlag180Roll - 25000L); |
285 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
303 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
286 | } |
304 | } |
287 | if(AdWertRoll < 15) MesswertRoll = -1000; |
305 | if (AdWertRoll < 15) MesswertRoll = -1000; |
288 | if(AdWertRoll < 7) MesswertRoll = -2000; |
306 | if (AdWertRoll < 7) MesswertRoll = -2000; |
289 | if(PlatinenVersion == 10) |
307 | if (PlatinenVersion == 10) { |
290 | { |
- | |
291 | if(AdWertRoll > 1010) MesswertRoll = +1000; |
308 | if (AdWertRoll > 1010) MesswertRoll = +1000; |
292 | if(AdWertRoll > 1017) MesswertRoll = +2000; |
309 | if (AdWertRoll > 1017) MesswertRoll = +2000; |
293 | } |
- | |
294 | else |
310 | } else { |
295 | { |
- | |
296 | if(AdWertRoll > 2020) MesswertRoll = +1000; |
311 | if (AdWertRoll > 2020) MesswertRoll = +1000; |
297 | if(AdWertRoll > 2034) MesswertRoll = +2000; |
312 | if (AdWertRoll > 2034) MesswertRoll = +2000; |
298 | } |
313 | } |
299 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
314 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
300 | MesswertNick -= tmpl2; |
315 | MesswertNick -= tmpl2; |
301 | MesswertNick -= (tmpl*Parameter_AchsGegenKopplung1)/512L; |
316 | MesswertNick -= (tmpl * Parameter_AchsGegenKopplung1) / 512L; |
302 | Mess_IntegralNick2 += MesswertNick; |
317 | Mess_IntegralNick2 += MesswertNick; |
303 | Mess_IntegralNick += MesswertNick - LageKorrekturNick; |
318 | Mess_IntegralNick += MesswertNick - LageKorrekturNick; |
Line 304... | Line 319... | ||
304 | 319 | ||
305 | if(Mess_IntegralNick > Umschlag180Nick) |
- | |
306 | { |
320 | if (Mess_IntegralNick > Umschlag180Nick) { |
307 | Mess_IntegralNick = -(Umschlag180Nick - 25000L); |
321 | Mess_IntegralNick = -(Umschlag180Nick - 25000L); |
308 | Mess_IntegralNick2 = Mess_IntegralNick; |
322 | Mess_IntegralNick2 = Mess_IntegralNick; |
309 | } |
323 | } |
310 | if(Mess_IntegralNick <-Umschlag180Nick) |
- | |
311 | { |
324 | if (Mess_IntegralNick <-Umschlag180Nick) { |
312 | Mess_IntegralNick = (Umschlag180Nick - 25000L); |
325 | Mess_IntegralNick = (Umschlag180Nick - 25000L); |
313 | Mess_IntegralNick2 = Mess_IntegralNick; |
326 | Mess_IntegralNick2 = Mess_IntegralNick; |
314 | } |
327 | } |
315 | if(AdWertNick < 15) MesswertNick = -1000; |
328 | if (AdWertNick < 15) MesswertNick = -1000; |
316 | if(AdWertNick < 7) MesswertNick = -2000; |
329 | if (AdWertNick < 7) MesswertNick = -2000; |
317 | if(PlatinenVersion == 10) |
- | |
318 | { |
330 | if (PlatinenVersion == 10) { |
319 | if(AdWertNick > 1010) MesswertNick = +1000; |
331 | if (AdWertNick > 1010) MesswertNick = +1000; |
320 | if(AdWertNick > 1017) MesswertNick = +2000; |
- | |
321 | } |
332 | if (AdWertNick > 1017) MesswertNick = +2000; |
322 | else |
- | |
323 | { |
333 | } else { |
324 | if(AdWertNick > 2020) MesswertNick = +1000; |
334 | if (AdWertNick > 2020) MesswertNick = +1000; |
325 | if(AdWertNick > 2034) MesswertNick = +2000; |
335 | if (AdWertNick > 2034) MesswertNick = +2000; |
326 | } |
336 | } |
327 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
337 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 333... | Line 343... | ||
333 | IntegralNick = Mess_IntegralNick; |
343 | IntegralNick = Mess_IntegralNick; |
334 | IntegralRoll = Mess_IntegralRoll; |
344 | IntegralRoll = Mess_IntegralRoll; |
335 | IntegralNick2 = Mess_IntegralNick2; |
345 | IntegralNick2 = Mess_IntegralNick2; |
336 | IntegralRoll2 = Mess_IntegralRoll2; |
346 | IntegralRoll2 = Mess_IntegralRoll2; |
Line 337... | Line 347... | ||
337 | 347 | ||
338 | if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) |
- | |
339 | { |
348 | if (EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) { |
340 | if(MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200); |
349 | if (MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200); |
341 | else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200); |
350 | else if (MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200); |
342 | if(MesswertRoll > 200) MesswertRoll += 4 * (MesswertRoll - 200); |
351 | if (MesswertRoll > 200) MesswertRoll += 4 * (MesswertRoll - 200); |
343 | else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200); |
352 | else if (MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200); |
344 | } |
- | |
345 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
- | |
346 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
- | |
347 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
- | |
348 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
- | |
349 | if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255; |
- | |
350 | if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255; |
- | |
351 | if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255; |
353 | } |
352 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
354 | LesePotis(); |
Line 353... | Line 355... | ||
353 | } |
355 | } |
354 | 356 | ||
- | 357 | //############################################################################ |
|
355 | //############################################################################ |
358 | // Messwerte beim Ermitteln der Nullage |
356 | // Messwerte beim Ermitteln der Nullage |
359 | |
357 | void CalibrierMittelwert(void) |
360 | void CalibrierMittelwert(void) |
358 | //############################################################################ |
361 | //############################################################################ |
359 | { |
362 | { |
Line 366... | Line 369... | ||
366 | Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick; |
369 | Mittelwert_AccNick = ACC_AMPLIFY * (long) AdWertAccNick; |
367 | Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll; |
370 | Mittelwert_AccRoll = ACC_AMPLIFY * (long) AdWertAccRoll; |
368 | Mittelwert_AccHoch = (long)AdWertAccHoch; |
371 | Mittelwert_AccHoch = (long) AdWertAccHoch; |
369 | // ADC einschalten |
372 | // ADC einschalten |
370 | ANALOG_ON; |
373 | ANALOG_ON; |
371 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
- | |
372 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
- | |
373 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
- | |
374 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
- | |
375 | if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255; |
- | |
376 | if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255; |
- | |
377 | if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255; |
- | |
- | 374 | ||
378 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
375 | LesePotis(); |
Line 379... | Line 376... | ||
379 | 376 | ||
380 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
377 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
381 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
378 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
Line 382... | Line 379... | ||
382 | } |
379 | } |
383 | 380 | ||
- | 381 | //############################################################################ |
|
384 | //############################################################################ |
382 | // Senden der Motorwerte per I2C-Bus |
385 | // Senden der Motorwerte per I2C-Bus |
383 | |
386 | void SendMotorData(void) |
384 | void SendMotorData(void) |
387 | //############################################################################ |
385 | //############################################################################ |
388 | { |
386 | { |
389 | DebugOut.Analog[12] = Motor_Vorne; |
387 | DebugOut.Analog[12] = Motor_Vorne; |
390 | DebugOut.Analog[13] = Motor_Hinten; |
388 | DebugOut.Analog[13] = Motor_Hinten; |
Line 391... | Line 389... | ||
391 | DebugOut.Analog[14] = Motor_Links; |
389 | DebugOut.Analog[14] = Motor_Links; |
392 | DebugOut.Analog[15] = Motor_Rechts; |
- | |
393 | 390 | DebugOut.Analog[15] = Motor_Rechts; |
|
394 | if(!( MotorenEin && PARAM_ENGINE_ENABLED ) ) |
391 | |
395 | { |
392 | if (!(MotorenEin && PARAM_ENGINE_ENABLED)) { |
396 | Motor_Hinten = 0; |
393 | Motor_Hinten = 0; |
397 | Motor_Vorne = 0; |
394 | Motor_Vorne = 0; |
Line 412... | Line 409... | ||
412 | 409 | ||
413 | 410 | ||
- | 411 | ||
414 | 412 | //############################################################################ |
|
415 | //############################################################################ |
413 | // Trägt ggf. das Poti als Parameter ein |
416 | // Trägt ggf. das Poti als Parameter ein |
414 | |
417 | void ParameterZuordnung(void) |
415 | void ParameterZuordnung(void) |
418 | //############################################################################ |
416 | //############################################################################ |
Line 465... | Line 463... | ||
465 | 463 | ||
466 | 464 | ||
- | 465 | ||
467 | 466 | //############################################################################ |
|
468 | //############################################################################ |
467 | // |
469 | // |
468 | |
470 | void MotorRegler(void) |
469 | void MotorRegler(void) |
471 | //############################################################################ |
470 | //############################################################################ |
Line 491... | Line 490... | ||
491 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
490 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
492 | GasMischanteil = StickGas; |
491 | GasMischanteil = StickGas; |
493 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
492 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
494 | // Empfang schlecht |
493 | // Empfang schlecht |
495 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
494 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
496 | if(SenderOkay < 100) |
495 | if (SenderOkay < 100) { |
497 | { |
- | |
498 | if(!PcZugriff) |
496 | if (!PcZugriff) { |
499 | { |
- | |
500 | if(BeepMuster == 0xffff) |
497 | if (BeepMuster == 0xffff) { |
501 | { |
- | |
502 | beeptime = 15000; |
498 | beeptime = 15000; |
503 | BeepMuster = 0x0c00; |
499 | BeepMuster = 0x0c00; |
504 | } |
500 | } |
505 | } |
501 | } |
506 | if(RcLostTimer) RcLostTimer--; |
502 | if (RcLostTimer) RcLostTimer--; |
507 | else |
503 | else { |
508 | { |
- | |
509 | MotorenEin = 0; |
504 | MotorenEin = 0; |
510 | Notlandung = 0; |
505 | Notlandung = 0; |
511 | } |
506 | } |
512 | ROT_ON; |
507 | ROT_ON; |
513 | if(modell_fliegt > 1000) // wahrscheinlich in der Luft --> langsam absenken |
508 | if (modell_fliegt > 1000) // wahrscheinlich in der Luft --> langsam absenken |
Line 517... | Line 512... | ||
517 | PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
512 | PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
518 | PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
513 | PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
519 | PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
514 | PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
520 | PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
515 | PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
521 | PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0; |
516 | PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0; |
522 | } |
- | |
523 | else MotorenEin = 0; |
517 | } else MotorenEin = 0; |
524 | } |
- | |
525 | else |
518 | } else |
526 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
519 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
527 | // Emfang gut |
520 | // Emfang gut |
528 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
521 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
529 | if(SenderOkay > 140) |
522 | if (SenderOkay > 140) { |
530 | { |
- | |
531 | Notlandung = 0; |
523 | Notlandung = 0; |
532 | RcLostTimer = EE_Parameter.NotGasZeit * 50; |
524 | RcLostTimer = EE_Parameter.NotGasZeit * 50; |
533 | if(GasMischanteil > 40 && MotorenEin) |
525 | if (GasMischanteil > 40 && MotorenEin) { |
534 | { |
- | |
535 | if(modell_fliegt < 0xffff) modell_fliegt++; |
526 | if (modell_fliegt < 0xffff) modell_fliegt++; |
536 | } |
527 | } |
537 | if((modell_fliegt < 256)) |
528 | if ((modell_fliegt < 256)) { |
538 | { |
- | |
539 | SummeNick = 0; |
529 | SummeNick = 0; |
540 | SummeRoll = 0; |
530 | SummeRoll = 0; |
541 | if(modell_fliegt == 250) |
531 | if (modell_fliegt == 250) { |
542 | { |
- | |
543 | NeueKompassRichtungMerken = 1; |
532 | NeueKompassRichtungMerken = 1; |
544 | sollGier = 0; |
533 | sollGier = 0; |
545 | Mess_Integral_Gier = 0; |
534 | Mess_Integral_Gier = 0; |
546 | // Mess_Integral_Gier2 = 0; |
535 | // Mess_Integral_Gier2 = 0; |
547 | } |
536 | } |
548 | } else MikroKopterFlags |= FLAG_FLY; |
537 | } else MikroKopterFlags |= FLAG_FLY; |
Line 549... | Line 538... | ||
549 | 538 | ||
550 | if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) |
- | |
551 | { |
539 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) { |
552 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
540 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
553 | // auf Nullwerte kalibrieren |
541 | // auf Nullwerte kalibrieren |
554 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
542 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
555 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) // Neutralwerte |
543 | if (PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) // Neutralwerte |
Line 558... | Line 546... | ||
558 | { |
546 | { |
559 | GRN_OFF; |
547 | GRN_OFF; |
560 | MotorenEin = 0; |
548 | MotorenEin = 0; |
561 | delay_neutral = 0; |
549 | delay_neutral = 0; |
562 | modell_fliegt = 0; |
550 | modell_fliegt = 0; |
563 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70) |
551 | if (PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70) { |
564 | { |
- | |
565 | unsigned char setting=1; |
552 | unsigned char setting = 1; |
566 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1; |
553 | if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1; |
567 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2; |
554 | if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2; |
568 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3; |
555 | if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3; |
569 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4; |
556 | if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4; |
570 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5; |
557 | if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5; |
571 | SetActiveParamSetNumber(setting); // aktiven Datensatz merken |
558 | SetActiveParamSetNumber(setting); // aktiven Datensatz merken |
572 | } |
559 | } |
573 | // else |
560 | // else |
574 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 30 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) |
561 | if (abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 30 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) { |
575 | { |
- | |
576 | WinkelOut.CalcState = 1; |
562 | WinkelOut.CalcState = 1; |
577 | beeptime = 1000; |
563 | beeptime = 1000; |
578 | } |
- | |
579 | else |
- | |
580 | { |
564 | } else { |
581 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
565 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) & EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
582 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
566 | if ((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
583 | { |
567 | { |
584 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
568 | if ((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
585 | } |
569 | } |
586 | SetNeutral(); |
570 | SetNeutral(); |
587 | Piep(GetActiveParamSetNumber()); |
571 | Piep(GetActiveParamSetNumber()); |
588 | } |
572 | } |
589 | } |
573 | } |
590 | } |
- | |
591 | else |
574 | } else |
592 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern |
575 | if (PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern |
593 | { |
576 | { |
594 | if(++delay_neutral > 200) // nicht sofort |
577 | if (++delay_neutral > 200) // nicht sofort |
595 | { |
578 | { |
596 | GRN_OFF; |
579 | GRN_OFF; |
Line 605... | Line 588... | ||
605 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256); |
588 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL + 1], NeutralAccY % 256); |
606 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256); |
589 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z], (int) NeutralAccZ / 256); |
607 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256); |
590 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z + 1], (int) NeutralAccZ % 256); |
608 | Piep(GetActiveParamSetNumber()); |
591 | Piep(GetActiveParamSetNumber()); |
609 | } |
592 | } |
610 | } |
- | |
611 | else delay_neutral = 0; |
593 | } else delay_neutral = 0; |
612 | } |
594 | } |
613 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
595 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
614 | // Gas ist unten |
596 | // Gas ist unten |
615 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
597 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
616 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120) |
598 | if (PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35 - 125) { |
617 | { |
- | |
618 | // Starten |
599 | // Starten |
619 | if( !MotorenEin && PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75 ) |
600 | if (!MotorenEin && PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) { |
620 | { |
- | |
621 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
601 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
622 | // Einschalten |
602 | // Einschalten |
623 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
603 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
624 | if(++delay_einschalten > 200) |
604 | if (++delay_einschalten > 200) { |
625 | { |
- | |
626 | delay_einschalten = 200; |
605 | delay_einschalten = 200; |
627 | modell_fliegt = 1; |
606 | modell_fliegt = 1; |
628 | MotorenEin = 1; |
607 | MotorenEin = 1; |
629 | sollGier = 0; |
608 | sollGier = 0; |
630 | Mess_Integral_Gier = 0; |
609 | Mess_Integral_Gier = 0; |
Line 646... | Line 625... | ||
646 | } |
625 | } |
Line 647... | Line 626... | ||
647 | 626 | ||
648 | SetNeutral(); |
627 | SetNeutral(); |
649 | } |
628 | } |
650 | } |
- | |
651 | } |
629 | } |
652 | else delay_einschalten = 0; |
630 | } else delay_einschalten = 0; |
653 | //Auf Neutralwerte setzen |
631 | //Auf Neutralwerte setzen |
654 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
632 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
655 | // Auschalten |
633 | // Auschalten |
656 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
634 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
657 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) |
- | |
658 | { |
635 | if (PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) { |
659 | if(++delay_ausschalten > 200) // nicht sofort |
636 | if (++delay_ausschalten > 200) // nicht sofort |
660 | { |
637 | { |
661 | MotorenEin = 0; |
638 | MotorenEin = 0; |
662 | delay_ausschalten = 200; |
639 | delay_ausschalten = 200; |
663 | modell_fliegt = 0; |
640 | modell_fliegt = 0; |
664 | } |
- | |
665 | } |
641 | } |
666 | else delay_ausschalten = 0; |
642 | } else delay_ausschalten = 0; |
667 | } |
643 | } |
Line 668... | Line 644... | ||
668 | } |
644 | } |
669 | 645 | ||
Line 729... | Line 705... | ||
729 | StickRoll = stick_roll - GPS_Roll; |
705 | StickRoll = stick_roll - GPS_Roll; |
Line 730... | Line 706... | ||
730 | 706 | ||
Line 731... | Line 707... | ||
731 | StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; |
707 | StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; |
- | 708 | ||
732 | 709 | // Gaswert übernehmen |
|
- | 710 | if (pitchNeutral()) { |
|
- | 711 | StickGas = pitch(); |
|
- | 712 | } else { |
|
- | 713 | // Warum 120? Gas= 0 ist -125 |
|
- | 714 | // StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120; |
|
Line 733... | Line 715... | ||
733 | // Gaswert übernehmen |
715 | StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 125; |
734 | StickGas = pitch_value(); |
716 | } |
Line 735... | Line 717... | ||
735 | 717 | ||
736 | GyroFaktor = ((float)Parameter_Gyro_P + 10.0) / (256 / STICK_GAIN ); |
718 | GyroFaktor = ((float) Parameter_Gyro_P + 10.0) / (256 / STICK_GAIN); |
737 | IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN ); |
719 | IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN); |
738 | 720 | ||
739 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
740 | //+ Analoge Steuerung per Seriell |
721 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
741 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
722 | //+ Analoge Steuerung per Seriell |
742 | if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128) |
723 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
743 | { |
724 | if (ExternControl.Config & 0x01 && Parameter_ExternalControl > 128) { |
744 | StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P; |
725 | StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P; |
Line 751... | Line 732... | ||
751 | 732 | ||
752 | if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0; |
733 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0; |
753 | if(GyroFaktor < 0) GyroFaktor = 0; |
734 | if (GyroFaktor < 0) GyroFaktor = 0; |
Line 754... | Line 735... | ||
754 | if(IntegralFaktor < 0) IntegralFaktor = 0; |
735 | if (IntegralFaktor < 0) IntegralFaktor = 0; |
755 | - | ||
756 | if(abs(StickNick/STICK_GAIN) > MaxStickNick) |
736 | |
757 | { |
737 | if (abs(StickNick / STICK_GAIN) > MaxStickNick) { |
758 | MaxStickNick = abs(StickNick)/STICK_GAIN; |
- | |
759 | if(MaxStickNick > 100) MaxStickNick = 100; |
738 | MaxStickNick = abs(StickNick) / STICK_GAIN; |
760 | } |
739 | if (MaxStickNick > 100) MaxStickNick = 100; |
761 | else MaxStickNick--; |
- | |
762 | if(abs(StickRoll/STICK_GAIN) > MaxStickRoll) |
740 | } else MaxStickNick--; |
763 | { |
741 | if (abs(StickRoll / STICK_GAIN) > MaxStickRoll) { |
- | 742 | MaxStickRoll = abs(StickRoll) / STICK_GAIN; |
|
- | 743 | if (MaxStickRoll > 100) MaxStickRoll = 100; |
|
- | 744 | } else MaxStickRoll--; |
|
- | 745 | if (Notlandung) { |
|
764 | MaxStickRoll = abs(StickRoll)/STICK_GAIN; |
746 | MaxStickNick = 0; |
765 | if(MaxStickRoll > 100) MaxStickRoll = 100; |
- | |
766 | } |
- | |
Line 767... | Line 747... | ||
767 | else MaxStickRoll--; |
747 | MaxStickRoll = 0; |
768 | if(Notlandung) {MaxStickNick = 0; MaxStickRoll = 0;} |
748 | } |
769 | 749 | ||
770 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
750 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
771 | // Looping? |
751 | // Looping? |
772 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
773 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS) Looping_Links = 1; |
752 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
774 | else |
753 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS) Looping_Links = 1; |
775 | { |
754 | else { |
776 | { |
755 | { |
777 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0; |
756 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0; |
778 | } |
757 | } |
779 | } |
- | |
780 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1; |
758 | } |
781 | else |
759 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1; |
782 | { |
760 | else { |
783 | if(Looping_Rechts) // Hysterese |
761 | if (Looping_Rechts) // Hysterese |
784 | { |
762 | { |
Line 785... | Line 763... | ||
785 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0; |
763 | if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0; |
786 | } |
764 | } |
787 | } |
- | |
788 | 765 | } |
|
789 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_OBEN) Looping_Oben = 1; |
766 | |
790 | else |
767 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_OBEN) Looping_Oben = 1; |
791 | { |
768 | else { |
792 | if(Looping_Oben) // Hysterese |
769 | if (Looping_Oben) // Hysterese |
793 | { |
770 | { |
794 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0; |
771 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0; |
795 | } |
- | |
796 | } |
772 | } |
797 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_UNTEN) Looping_Unten = 1; |
773 | } |
798 | else |
774 | if ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_UNTEN) Looping_Unten = 1; |
799 | { |
775 | else { |
800 | if(Looping_Unten) // Hysterese |
776 | if (Looping_Unten) // Hysterese |
Line 801... | Line 777... | ||
801 | { |
777 | { |
- | 778 | if (PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0; |
|
802 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0; |
779 | } |
- | 780 | } |
|
- | 781 | ||
- | 782 | if (Looping_Links || Looping_Rechts) Looping_Roll = 1; |
|
- | 783 | else Looping_Roll = 0; |
|
- | 784 | if (Looping_Oben || Looping_Unten) { |
|
803 | } |
785 | Looping_Nick = 1; |
Line 804... | Line 786... | ||
804 | } |
786 | Looping_Roll = 0; |
805 | - | ||
806 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
787 | Looping_Links = 0; |
807 | if(Looping_Oben || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
788 | Looping_Rechts = 0; |
Line 808... | Line 789... | ||
808 | } // Ende neue Funken-Werte |
789 | } else Looping_Nick = 0; |
809 | 790 | } // Ende neue Funken-Werte |
|
810 | if(Looping_Roll || Looping_Nick) |
791 | |
811 | { |
792 | if (Looping_Roll || Looping_Nick) { |
812 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
- | |
813 | } |
793 | if (GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
814 | 794 | } |
|
815 | 795 | ||
816 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
796 | |
817 | // Bei Empfangsausfall im Flug |
797 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 836... | Line 816... | ||
836 | MittelIntegralNick += IntegralNick; // Für die Mittelwertbildung aufsummieren |
816 | MittelIntegralNick += IntegralNick; // Für die Mittelwertbildung aufsummieren |
837 | MittelIntegralRoll += IntegralRoll; |
817 | MittelIntegralRoll += IntegralRoll; |
838 | MittelIntegralNick2 += IntegralNick2; |
818 | MittelIntegralNick2 += IntegralNick2; |
839 | MittelIntegralRoll2 += IntegralRoll2; |
819 | MittelIntegralRoll2 += IntegralRoll2; |
Line 840... | Line 820... | ||
840 | 820 | ||
841 | if(Looping_Nick || Looping_Roll) |
- | |
842 | { |
821 | if (Looping_Nick || Looping_Roll) { |
843 | IntegralAccNick = 0; |
822 | IntegralAccNick = 0; |
844 | IntegralAccRoll = 0; |
823 | IntegralAccRoll = 0; |
845 | MittelIntegralNick = 0; |
824 | MittelIntegralNick = 0; |
846 | MittelIntegralRoll = 0; |
825 | MittelIntegralRoll = 0; |
Line 852... | Line 831... | ||
852 | LageKorrekturNick = 0; |
831 | LageKorrekturNick = 0; |
853 | LageKorrekturRoll = 0; |
832 | LageKorrekturRoll = 0; |
854 | } |
833 | } |
Line 855... | Line 834... | ||
855 | 834 | ||
856 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
835 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
857 | if(!Looping_Nick && !Looping_Roll) |
- | |
858 | { |
836 | if (!Looping_Nick && !Looping_Roll) { |
859 | long tmp_long, tmp_long2; |
837 | long tmp_long, tmp_long2; |
860 | if(FromNaviCtrl_Value.Kalman_K != -1) |
- | |
861 | { |
838 | if (FromNaviCtrl_Value.Kalman_K != -1) { |
862 | tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick); |
839 | tmp_long = (long) (IntegralNick / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccNick); |
863 | tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll); |
840 | tmp_long2 = (long) (IntegralRoll / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccRoll); |
864 | tmp_long = (tmp_long * FromNaviCtrl_Value.Kalman_K) / (32 * 16); |
841 | tmp_long = (tmp_long * FromNaviCtrl_Value.Kalman_K) / (32 * 16); |
865 | tmp_long2 = (tmp_long2 * FromNaviCtrl_Value.Kalman_K) / (32 * 16); |
842 | tmp_long2 = (tmp_long2 * FromNaviCtrl_Value.Kalman_K) / (32 * 16); |
866 | if((MaxStickNick > 64) || (MaxStickRoll > 64)) |
- | |
867 | { |
843 | if ((MaxStickNick > 64) || (MaxStickRoll > 64)) { |
868 | tmp_long /= 2; |
844 | tmp_long /= 2; |
869 | tmp_long2 /= 2; |
845 | tmp_long2 /= 2; |
870 | } |
846 | } |
871 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25) |
- | |
872 | { |
847 | if (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25) { |
873 | tmp_long /= 3; |
848 | tmp_long /= 3; |
874 | tmp_long2 /= 3; |
849 | tmp_long2 /= 3; |
875 | } |
850 | } |
876 | if(tmp_long > (long) FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long = (long) FromNaviCtrl_Value.Kalman_MaxFusion; |
851 | if (tmp_long > (long) FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long = (long) FromNaviCtrl_Value.Kalman_MaxFusion; |
877 | if(tmp_long < (long)-FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long = (long)-FromNaviCtrl_Value.Kalman_MaxFusion; |
852 | if (tmp_long < (long) - FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long = (long) - FromNaviCtrl_Value.Kalman_MaxFusion; |
878 | if(tmp_long2 > (long) FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long2 = (long) FromNaviCtrl_Value.Kalman_MaxFusion; |
853 | if (tmp_long2 > (long) FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long2 = (long) FromNaviCtrl_Value.Kalman_MaxFusion; |
879 | if(tmp_long2 < (long)-FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long2 = (long)-FromNaviCtrl_Value.Kalman_MaxFusion; |
- | |
880 | } |
854 | if (tmp_long2 < (long) - FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long2 = (long) - FromNaviCtrl_Value.Kalman_MaxFusion; |
881 | else |
- | |
882 | { |
855 | } else { |
883 | tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick); |
856 | tmp_long = (long) (IntegralNick / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccNick); |
884 | tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll); |
857 | tmp_long2 = (long) (IntegralRoll / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccRoll); |
885 | tmp_long /= 16; |
858 | tmp_long /= 16; |
886 | tmp_long2 /= 16; |
859 | tmp_long2 /= 16; |
887 | if((MaxStickNick > 64) || (MaxStickRoll > 64)) |
- | |
888 | { |
860 | if ((MaxStickNick > 64) || (MaxStickRoll > 64)) { |
889 | tmp_long /= 3; |
861 | tmp_long /= 3; |
890 | tmp_long2 /= 3; |
862 | tmp_long2 /= 3; |
891 | } |
863 | } |
892 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25) |
- | |
893 | { |
864 | if (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25) { |
894 | tmp_long /= 3; |
865 | tmp_long /= 3; |
895 | tmp_long2 /= 3; |
866 | tmp_long2 /= 3; |
896 | } |
867 | } |
897 | #define AUSGLEICH 32 |
868 | #define AUSGLEICH 32 |
Line 903... | Line 874... | ||
903 | 874 | ||
904 | Mess_IntegralNick -= tmp_long; |
875 | Mess_IntegralNick -= tmp_long; |
905 | Mess_IntegralRoll -= tmp_long2; |
876 | Mess_IntegralRoll -= tmp_long2; |
906 | } |
877 | } |
907 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
878 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
908 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
- | |
909 | { |
879 | if (ZaehlMessungen >= ABGLEICH_ANZAHL) { |
910 | static int cnt = 0; |
880 | static int cnt = 0; |
911 | static char last_n_p,last_n_n,last_r_p,last_r_n; |
881 | static char last_n_p, last_n_n, last_r_p, last_r_n; |
912 | static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt; |
882 | static long MittelIntegralNick_Alt, MittelIntegralRoll_Alt; |
913 | if(!Looping_Nick && !Looping_Roll && !TrichterFlug) |
- | |
914 | { |
883 | if (!Looping_Nick && !Looping_Roll && !TrichterFlug) { |
915 | MittelIntegralNick /= ABGLEICH_ANZAHL; |
884 | MittelIntegralNick /= ABGLEICH_ANZAHL; |
916 | MittelIntegralRoll /= ABGLEICH_ANZAHL; |
885 | MittelIntegralRoll /= ABGLEICH_ANZAHL; |
917 | IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL; |
886 | IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL; |
918 | IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL; |
887 | IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL; |
Line 926... | Line 895... | ||
926 | ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich; |
895 | ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich; |
Line 927... | Line 896... | ||
927 | 896 | ||
928 | LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL; |
897 | LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL; |
Line 929... | Line 898... | ||
929 | LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL; |
898 | LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL; |
930 | - | ||
931 | if(((MaxStickNick > 64) || (MaxStickRoll > 64) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)) && (FromNaviCtrl_Value.Kalman_K == -1)) |
899 | |
932 | { |
900 | if (((MaxStickNick > 64) || (MaxStickRoll > 64) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)) && (FromNaviCtrl_Value.Kalman_K == -1)) { |
933 | LageKorrekturNick /= 2; |
901 | LageKorrekturNick /= 2; |
Line 934... | Line 902... | ||
934 | LageKorrekturRoll /= 2; |
902 | LageKorrekturRoll /= 2; |
Line 948... | Line 916... | ||
948 | Mess_IntegralNick2 -= IntegralFehlerNick; |
916 | Mess_IntegralNick2 -= IntegralFehlerNick; |
949 | Mess_IntegralRoll2 -= IntegralFehlerRoll; |
917 | Mess_IntegralRoll2 -= IntegralFehlerRoll; |
Line 950... | Line 918... | ||
950 | 918 | ||
951 | // IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2; |
919 | // IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2; |
952 | // IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2; |
920 | // IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2; |
- | 921 | if (GierGyroFehler > ABGLEICH_ANZAHL / 2) { |
|
- | 922 | AdNeutralGier++; |
|
- | 923 | AdNeutralGierBias++; |
|
953 | if(GierGyroFehler > ABGLEICH_ANZAHL/2) { AdNeutralGier++; AdNeutralGierBias++; } |
924 | } |
- | 925 | if (GierGyroFehler <-ABGLEICH_ANZAHL / 2) { |
|
- | 926 | AdNeutralGier--; |
|
- | 927 | AdNeutralGierBias--; |
|
Line 954... | Line 928... | ||
954 | if(GierGyroFehler <-ABGLEICH_ANZAHL/2) { AdNeutralGier--; AdNeutralGierBias--; } |
928 | } |
955 | 929 | ||
956 | DebugOut.Analog[22] = MittelIntegralRoll / 26; |
930 | DebugOut.Analog[22] = MittelIntegralRoll / 26; |
Line 974... | Line 948... | ||
974 | #define FEHLER_LIMIT (ABGLEICH_ANZAHL * 4) |
948 | #define FEHLER_LIMIT (ABGLEICH_ANZAHL * 4) |
975 | #define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16) |
949 | #define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16) |
976 | #define BEWEGUNGS_LIMIT 20000 |
950 | #define BEWEGUNGS_LIMIT 20000 |
977 | // Nick +++++++++++++++++++++++++++++++++++++++++++++++++ |
951 | // Nick +++++++++++++++++++++++++++++++++++++++++++++++++ |
978 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
952 | cnt = 1; // + labs(IntegralFehlerNick) / 4096; |
979 | if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16)) |
953 | if (labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3 * 16)) { |
980 | { |
- | |
981 | if(IntegralFehlerNick > FEHLER_LIMIT2) |
954 | if (IntegralFehlerNick > FEHLER_LIMIT2) { |
982 | { |
- | |
983 | if(last_n_p) |
955 | if (last_n_p) { |
984 | { |
- | |
985 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
956 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
986 | ausgleichNick = IntegralFehlerNick / 8; |
957 | ausgleichNick = IntegralFehlerNick / 8; |
987 | if(ausgleichNick > 5000) ausgleichNick = 5000; |
958 | if (ausgleichNick > 5000) ausgleichNick = 5000; |
988 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
959 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
989 | } |
- | |
990 | else last_n_p = 1; |
960 | } else last_n_p = 1; |
991 | } else last_n_p = 0; |
961 | } else last_n_p = 0; |
992 | if(IntegralFehlerNick < -FEHLER_LIMIT2) |
962 | if (IntegralFehlerNick < -FEHLER_LIMIT2) { |
993 | { |
- | |
994 | if(last_n_n) |
963 | if (last_n_n) { |
995 | { |
- | |
996 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
964 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
997 | ausgleichNick = IntegralFehlerNick / 8; |
965 | ausgleichNick = IntegralFehlerNick / 8; |
998 | if(ausgleichNick < -5000) ausgleichNick = -5000; |
966 | if (ausgleichNick < -5000) ausgleichNick = -5000; |
999 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
967 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
1000 | } |
- | |
1001 | else last_n_n = 1; |
968 | } else last_n_n = 1; |
1002 | } else last_n_n = 0; |
969 | } else last_n_n = 0; |
1003 | } |
- | |
1004 | else |
970 | } else { |
1005 | { |
- | |
1006 | cnt = 0; |
971 | cnt = 0; |
1007 | KompassSignalSchlecht = 1000; |
972 | KompassSignalSchlecht = 1000; |
1008 | } |
973 | } |
1009 | if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
974 | if (cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
1010 | if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16; |
975 | if (cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift / 16; |
Line 1013... | Line 978... | ||
1013 | 978 | ||
1014 | // Roll +++++++++++++++++++++++++++++++++++++++++++++++++ |
979 | // Roll +++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 1015... | Line 980... | ||
1015 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
980 | cnt = 1; // + labs(IntegralFehlerNick) / 4096; |
1016 | 981 | ||
1017 | ausgleichRoll = 0; |
- | |
1018 | if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16)) |
982 | ausgleichRoll = 0; |
1019 | { |
- | |
1020 | if(IntegralFehlerRoll > FEHLER_LIMIT2) |
983 | if (labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3 * 16)) { |
1021 | { |
- | |
1022 | if(last_r_p) |
984 | if (IntegralFehlerRoll > FEHLER_LIMIT2) { |
1023 | { |
985 | if (last_r_p) { |
1024 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
986 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
1025 | ausgleichRoll = IntegralFehlerRoll / 8; |
987 | ausgleichRoll = IntegralFehlerRoll / 8; |
1026 | if(ausgleichRoll > 5000) ausgleichRoll = 5000; |
- | |
1027 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
988 | if (ausgleichRoll > 5000) ausgleichRoll = 5000; |
1028 | } |
989 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
1029 | else last_r_p = 1; |
990 | } else last_r_p = 1; |
1030 | } else last_r_p = 0; |
- | |
1031 | if(IntegralFehlerRoll < -FEHLER_LIMIT2) |
991 | } else last_r_p = 0; |
1032 | { |
- | |
1033 | if(last_r_n) |
992 | if (IntegralFehlerRoll < -FEHLER_LIMIT2) { |
1034 | { |
993 | if (last_r_n) { |
1035 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
994 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
1036 | ausgleichRoll = IntegralFehlerRoll / 8; |
995 | ausgleichRoll = IntegralFehlerRoll / 8; |
1037 | if(ausgleichRoll < -5000) ausgleichRoll = -5000; |
- | |
1038 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
996 | if (ausgleichRoll < -5000) ausgleichRoll = -5000; |
1039 | } |
997 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
1040 | else last_r_n = 1; |
998 | } else last_r_n = 1; |
1041 | } else last_r_n = 0; |
- | |
1042 | } else |
999 | } else last_r_n = 0; |
1043 | { |
1000 | } else { |
1044 | cnt = 0; |
1001 | cnt = 0; |
1045 | KompassSignalSchlecht = 1000; |
1002 | KompassSignalSchlecht = 1000; |
1046 | } |
1003 | } |
1047 | if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
1004 | if (cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
1048 | if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16; |
1005 | if (cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift / 16; |
1049 | if(IntegralFehlerRoll > FEHLER_LIMIT) AdNeutralRoll += cnt; |
- | |
1050 | if(IntegralFehlerRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt; |
1006 | if (IntegralFehlerRoll > FEHLER_LIMIT) AdNeutralRoll += cnt; |
1051 | } |
- | |
1052 | else |
1007 | if (IntegralFehlerRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt; |
1053 | { |
1008 | } else { |
1054 | LageKorrekturRoll = 0; |
1009 | LageKorrekturRoll = 0; |
1055 | LageKorrekturNick = 0; |
1010 | LageKorrekturNick = 0; |
Line -... | Line 1011... | ||
- | 1011 | TrichterFlug = 0; |
|
- | 1012 | } |
|
1056 | TrichterFlug = 0; |
1013 | |
- | 1014 | if (!IntegralFaktor) { |
|
1057 | } |
1015 | LageKorrekturRoll = 0; |
1058 | 1016 | LageKorrekturNick = 0; |
|
1059 | if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH |
1017 | } // z.B. bei HH |
1060 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1018 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1061 | MittelIntegralNick_Alt = MittelIntegralNick; |
1019 | MittelIntegralNick_Alt = MittelIntegralNick; |
Line 1077... | Line 1035... | ||
1077 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1035 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1078 | // if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;}; |
1036 | // if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;}; |
1079 | if(abs(StickGier) > 15) // war 35 |
1037 | if (abs(StickGier) > 15) // war 35 |
1080 | { |
1038 | { |
1081 | KompassSignalSchlecht = 1000; |
1039 | KompassSignalSchlecht = 1000; |
1082 | if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) |
1040 | if (!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) { |
1083 | { |
- | |
1084 | NeueKompassRichtungMerken = 1; |
1041 | NeueKompassRichtungMerken = 1; |
1085 | }; |
1042 | }; |
1086 | } |
1043 | } |
1087 | tmp_int = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
1044 | tmp_int = (long) EE_Parameter.Gier_P * ((long) StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
1088 | tmp_int += (EE_Parameter.Gier_P * StickGier) / 4; |
1045 | tmp_int += (EE_Parameter.Gier_P * StickGier) / 4; |
Line 1094... | Line 1051... | ||
1094 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1051 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1095 | // Kompass |
1052 | // Kompass |
1096 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1053 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1097 | //DebugOut.Analog[29] = (MaxStickNick + MaxStickRoll); |
1054 | //DebugOut.Analog[29] = (MaxStickNick + MaxStickRoll); |
Line 1098... | Line 1055... | ||
1098 | 1055 | ||
1099 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
- | |
1100 | { |
1056 | if (KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) { |
1101 | int w,v,r,fehler,korrektur; |
1057 | int w, v, r, fehler, korrektur; |
1102 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
1058 | w = abs(IntegralNick / 512); // mit zunehmender Neigung den Einfluss drosseln |
1103 | v = abs(IntegralRoll /512); |
1059 | v = abs(IntegralRoll / 512); |
1104 | if(v > w) w = v; // grösste Neigung ermitteln |
1060 | if (v > w) w = v; // grösste Neigung ermitteln |
1105 | korrektur = w / 8 + 1; |
1061 | korrektur = w / 8 + 1; |
1106 | fehler = ((540 + KompassValue - (ErsatzKompass/GIER_GRAD_FAKTOR)) % 360) - 180; |
1062 | fehler = ((540 + KompassValue - (ErsatzKompass / GIER_GRAD_FAKTOR)) % 360) - 180; |
1107 | if(NeueKompassRichtungMerken) |
- | |
1108 | { |
1063 | if (NeueKompassRichtungMerken) { |
1109 | fehler = 0; |
1064 | fehler = 0; |
1110 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; |
1065 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; |
1111 | } |
1066 | } |
1112 | if(!KompassSignalSchlecht && w < 25) |
- | |
1113 | { |
1067 | if (!KompassSignalSchlecht && w < 25) { |
1114 | GierGyroFehler += fehler; |
1068 | GierGyroFehler += fehler; |
1115 | if(NeueKompassRichtungMerken) |
- | |
1116 | { |
1069 | if (NeueKompassRichtungMerken) { |
1117 | beeptime = 200; |
1070 | beeptime = 200; |
1118 | // KompassStartwert = KompassValue; |
1071 | // KompassStartwert = KompassValue; |
1119 | KompassStartwert = (ErsatzKompass/GIER_GRAD_FAKTOR); |
1072 | KompassStartwert = (ErsatzKompass / GIER_GRAD_FAKTOR); |
1120 | NeueKompassRichtungMerken = 0; |
1073 | NeueKompassRichtungMerken = 0; |
1121 | } |
1074 | } |
1122 | } |
1075 | } |
1123 | ErsatzKompass += (fehler * 8) / korrektur; |
1076 | ErsatzKompass += (fehler * 8) / korrektur; |
1124 | w = (w * Parameter_KompassWirkung) / 32; // auf die Wirkung normieren |
1077 | w = (w * Parameter_KompassWirkung) / 32; // auf die Wirkung normieren |
1125 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
1078 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
1126 | if(w >= 0) |
- | |
1127 | { |
1079 | if (w >= 0) { |
1128 | if(!KompassSignalSchlecht) |
- | |
1129 | { |
1080 | if (!KompassSignalSchlecht) { |
1130 | v = 64 + ((MaxStickNick + MaxStickRoll)) / 8; |
1081 | v = 64 + ((MaxStickNick + MaxStickRoll)) / 8; |
1131 | r = ((540 + (ErsatzKompass/GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180; |
1082 | r = ((540 + (ErsatzKompass / GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180; |
1132 | // r = KompassRichtung; |
1083 | // r = KompassRichtung; |
1133 | v = (r * w) / v; // nach Kompass ausrichten |
1084 | v = (r * w) / v; // nach Kompass ausrichten |
Line 1136... | Line 1087... | ||
1136 | else |
1087 | else |
1137 | if(v < -w) v = -w; |
1088 | if (v < -w) v = -w; |
1138 | Mess_Integral_Gier += v; |
1089 | Mess_Integral_Gier += v; |
1139 | } |
1090 | } |
1140 | if(KompassSignalSchlecht) KompassSignalSchlecht--; |
1091 | if (KompassSignalSchlecht) KompassSignalSchlecht--; |
1141 | } |
- | |
1142 | else KompassSignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek |
1092 | } else KompassSignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek |
1143 | } |
1093 | } |
1144 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1094 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 1145... | Line 1095... | ||
1145 | 1095 | ||
1146 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1096 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1147 | // Debugwerte zuordnen |
1097 | // Debugwerte zuordnen |
1148 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1098 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1149 | if(!TimerWerteausgabe--) |
- | |
1150 | { |
1099 | if (!TimerWerteausgabe--) { |
Line 1151... | Line 1100... | ||
1151 | TimerWerteausgabe = 24; |
1100 | TimerWerteausgabe = 24; |
1152 | 1101 | ||
1153 | DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor; |
1102 | DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor; |
Line 1237... | Line 1186... | ||
1237 | 1186 | ||
1238 | // Begrenzung des Gasmischanteils auf MAX_GAS - 20 (Reserve für Motoren) |
1187 | // Begrenzung des Gasmischanteils auf MAX_GAS - 20 (Reserve für Motoren) |
1239 | if( GasMischanteil > ( MAX_GAS - 20 ) * STICK_GAIN ) |
1188 | if( GasMischanteil > ( MAX_GAS - 20 ) * STICK_GAIN ) |
Line -... | Line 1189... | ||
- | 1189 | GasMischanteil = ( MAX_GAS - 20 ) * STICK_GAIN; |
|
- | 1190 | ||
- | 1191 | // Mindestens auf Minimalgas stellen |
|
- | 1192 | if (GasMischanteil < MIN_GAS) |
|
- | 1193 | GasMischanteil = MIN_GAS; |
|
- | 1194 | ||
- | 1195 | // Begrenzung des Gasmischanteils auf MAX_GAS - 20 (Reserve für Motoren) |
|
- | 1196 | if (GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) |
|
1240 | GasMischanteil = ( MAX_GAS - 20 ) * STICK_GAIN; |
1197 | GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
Line 1241... | Line 1198... | ||
1241 | 1198 | ||
1242 | DebugOut.Analog[7] = GasMischanteil; |
1199 | DebugOut.Analog[7] = GasMischanteil; |
1243 | 1200 |