Rev 1121 | Rev 1155 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1121 | Rev 1153 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | #include "main.h" |
55 | #include "main.h" |
56 | #include "eeprom.c" |
56 | #include "eeprom.c" |
Line 57... | Line 57... | ||
57 | 57 | ||
58 | unsigned char h,m,s; |
58 | unsigned char h,m,s; |
59 | volatile unsigned int I2CTimeout = 100; |
59 | volatile unsigned int I2CTimeout = 100; |
60 | volatile int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias; |
60 | int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias, RohMesswertNick,RohMesswertRoll; |
61 | int AdNeutralGierBias; |
61 | int AdNeutralGierBias; |
62 | int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0; |
62 | int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0; |
63 | int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0; |
63 | int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0; |
64 | int NaviAccNick, NaviAccRoll,NaviCntAcc = 0; |
64 | int NaviAccNick, NaviAccRoll,NaviCntAcc = 0; |
Line 71... | Line 71... | ||
71 | long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0; |
71 | long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0; |
72 | long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0; |
72 | long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0; |
73 | long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0; |
73 | long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0; |
74 | long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2; |
74 | long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2; |
75 | volatile long Mess_Integral_Hoch = 0; |
75 | volatile long Mess_Integral_Hoch = 0; |
76 | volatile int KompassValue = 0; |
76 | int KompassValue = 0; |
77 | volatile int KompassStartwert = 0; |
77 | int KompassStartwert = 0; |
78 | volatile int KompassRichtung = 0; |
78 | int KompassRichtung = 0; |
79 | unsigned int KompassSignalSchlecht = 500; |
79 | unsigned int KompassSignalSchlecht = 500; |
80 | unsigned char MAX_GAS,MIN_GAS; |
80 | unsigned char MAX_GAS,MIN_GAS; |
81 | unsigned char Notlandung = 0; |
81 | unsigned char Notlandung = 0; |
82 | unsigned char HoehenReglerAktiv = 0; |
82 | unsigned char HoehenReglerAktiv = 0; |
83 | unsigned char TrichterFlug = 0; |
83 | unsigned char TrichterFlug = 0; |
84 | long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L; |
84 | long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L; |
85 | long ErsatzKompass; |
85 | long ErsatzKompass; |
86 | int ErsatzKompassInGrad; // Kompasswert in Grad |
86 | int ErsatzKompassInGrad; // Kompasswert in Grad |
87 | int GierGyroFehler = 0; |
87 | int GierGyroFehler = 0; |
88 | float GyroFaktor; |
88 | char GyroFaktor; |
89 | float IntegralFaktor; |
89 | char IntegralFaktor; |
90 | volatile int DiffNick,DiffRoll; |
90 | int DiffNick,DiffRoll; |
91 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
91 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
92 | volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count; |
92 | volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count; |
93 | volatile unsigned char Motor1, Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8; |
93 | volatile unsigned char Motor1, Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8; |
94 | volatile unsigned char SenderOkay = 0; |
94 | volatile unsigned char SenderOkay = 0; |
95 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
95 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
96 | char MotorenEin = 0; |
96 | char MotorenEin = 0; |
97 | int HoehenWert = 0; |
97 | int HoehenWert = 0; |
98 | int SollHoehe = 0; |
98 | int SollHoehe = 0; |
99 | int LageKorrekturRoll = 0,LageKorrekturNick = 0; |
99 | int LageKorrekturRoll = 0,LageKorrekturNick = 0; |
100 | float Ki = FAKTOR_I; |
100 | //float Ki = FAKTOR_I; |
- | 101 | int Ki = 10300 / 33; |
|
101 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
102 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
102 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
103 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
Line 103... | Line 104... | ||
103 | 104 | ||
104 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
105 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
Line 144... | Line 145... | ||
144 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
145 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
145 | int MaxStickNick = 0,MaxStickRoll = 0; |
146 | int MaxStickNick = 0,MaxStickRoll = 0; |
146 | unsigned int modell_fliegt = 0; |
147 | unsigned int modell_fliegt = 0; |
147 | unsigned char MikroKopterFlags = 0; |
148 | unsigned char MikroKopterFlags = 0; |
148 | long GIER_GRAD_FAKTOR = 1291; |
149 | long GIER_GRAD_FAKTOR = 1291; |
- | 150 | signed int KopplungsteilNickRoll,KopplungsteilRollNick; |
|
Line 149... | Line 151... | ||
149 | 151 | ||
150 | void Piep(unsigned char Anzahl) |
152 | void Piep(unsigned char Anzahl) |
151 | { |
153 | { |
152 | while(Anzahl--) |
154 | while(Anzahl--) |
Line 240... | Line 242... | ||
240 | void Mittelwert(void) |
242 | void Mittelwert(void) |
241 | //############################################################################ |
243 | //############################################################################ |
242 | { |
244 | { |
243 | static signed long tmpl,tmpl2,tmpl3,tmpl4; |
245 | static signed long tmpl,tmpl2,tmpl3,tmpl4; |
244 | static signed int oldNick, oldRoll, d2Roll, d2Nick; |
246 | static signed int oldNick, oldRoll, d2Roll, d2Nick; |
245 | signed int tmp_int; |
247 | signed int tmp_int; |
- | 248 | signed long winkel_nick, winkel_roll; |
|
246 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
249 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
247 | ErsatzKompass += MesswertGier; |
- | |
248 | // MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier; |
250 | // MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier; |
249 | MesswertRoll = (signed int) AdWertRoll - AdNeutralRoll; |
251 | MesswertRoll = (signed int) AdWertRoll - AdNeutralRoll; |
250 | MesswertNick = (signed int) AdWertNick - AdNeutralNick; |
252 | MesswertNick = (signed int) AdWertNick - AdNeutralNick; |
- | 253 | RohMesswertNick = MesswertNick; |
|
- | 254 | RohMesswertRoll = MesswertRoll; |
|
251 | //DebugOut.Analog[21] = MesswertNick; |
255 | //DebugOut.Analog[21] = MesswertNick; |
252 | //DebugOut.Analog[22] = MesswertRoll; |
256 | //DebugOut.Analog[22] = MesswertRoll; |
253 | //DebugOut.Analog[22] = Mess_Integral_Gier; |
257 | //DebugOut.Analog[22] = Mess_Integral_Gier; |
Line 254... | Line 258... | ||
254 | 258 | ||
Line 259... | Line 263... | ||
259 | IntegralAccNick += ACC_AMPLIFY * AdWertAccNick; |
263 | IntegralAccNick += ACC_AMPLIFY * AdWertAccNick; |
260 | IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll; |
264 | IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll; |
261 | NaviAccNick += AdWertAccNick; |
265 | NaviAccNick += AdWertAccNick; |
262 | NaviAccRoll += AdWertAccRoll; |
266 | NaviAccRoll += AdWertAccRoll; |
263 | NaviCntAcc++; |
267 | NaviCntAcc++; |
264 | IntegralAccZ += Aktuell_az - NeutralAccZ; |
268 | IntegralAccZ += Aktuell_az - NeutralAccZ; |
- | 269 | ||
- | 270 | if(Mess_IntegralRoll > 93000L) winkel_roll = 93000L; |
|
- | 271 | else if(Mess_IntegralRoll <-93000L) winkel_roll = -93000L; |
|
- | 272 | else winkel_roll = Mess_IntegralRoll; |
|
- | 273 | ||
- | 274 | if(Mess_IntegralNick > 93000L) winkel_nick = 93000L; |
|
- | 275 | else if(Mess_IntegralNick <-93000L) winkel_nick = -93000L; |
|
- | 276 | else winkel_nick = Mess_IntegralNick; |
|
- | 277 | ||
265 | // Gier ++++++++++++++++++++++++++++++++++++++++++++++++ |
278 | // Gier ++++++++++++++++++++++++++++++++++++++++++++++++ |
266 | Mess_Integral_Gier += MesswertGier; |
279 | Mess_Integral_Gier += MesswertGier; |
- | 280 | ErsatzKompass += MesswertGier; |
|
Line 267... | Line 281... | ||
267 | 281 | ||
268 | // Kopplungsanteil +++++++++++++++++++++++++++++++++++++ |
282 | // Kopplungsanteil +++++++++++++++++++++++++++++++++++++ |
269 | if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) |
283 | if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) |
270 | { |
284 | { |
271 | tmpl3 = (MesswertRoll * Mess_IntegralNick) / 2048L; |
285 | tmpl3 = (MesswertRoll * winkel_nick) / 2048L; |
272 | tmpl3 *= Parameter_AchsKopplung2; //65 |
286 | tmpl3 *= Parameter_AchsKopplung2; //65 |
273 | tmpl3 /= 4096L; |
287 | tmpl3 /= 4096L; |
274 | tmpl4 = (MesswertNick * Mess_IntegralRoll) / 2048L; |
288 | tmpl4 = (MesswertNick * winkel_roll) / 2048L; |
275 | tmpl4 *= Parameter_AchsKopplung2; //65 |
289 | tmpl4 *= Parameter_AchsKopplung2; //65 |
- | 290 | tmpl4 /= 4096L; |
|
- | 291 | KopplungsteilNickRoll = tmpl3; |
|
276 | tmpl4 /= 4096L; |
292 | KopplungsteilRollNick = tmpl4; |
277 | tmpl4 -= tmpl3; |
293 | tmpl4 -= tmpl3; |
Line 278... | Line 294... | ||
278 | ErsatzKompass += tmpl4; |
294 | ErsatzKompass += tmpl4; |
279 | 295 | ||
280 | tmpl = ((MesswertGier + tmpl4) * Mess_IntegralNick) / 2048L; |
296 | tmpl = ((MesswertGier + tmpl4) * winkel_nick) / 2048L; |
281 | tmpl *= Parameter_AchsKopplung1; // 90 |
297 | tmpl *= Parameter_AchsKopplung1; // 90 |
282 | tmpl /= 4096L; |
298 | tmpl /= 4096L; |
283 | tmpl2 = ((MesswertGier + tmpl4) * Mess_IntegralRoll) / 2048L; |
299 | tmpl2 = ((MesswertGier + tmpl4) * winkel_roll) / 2048L; |
284 | tmpl2 *= Parameter_AchsKopplung1; |
300 | tmpl2 *= Parameter_AchsKopplung1; |
285 | tmpl2 /= 4096L; |
- | |
286 | if(labs(tmpl) > 128 || labs(tmpl2) > 128) TrichterFlug = 1; |
301 | tmpl2 /= 4096L; |
- | 302 | if(labs(tmpl) > 128 || labs(tmpl2) > 128 /* || abs(KopplungsteilNickRoll) > 128 || abs(KopplungsteilRollNick) > 128)*/) TrichterFlug = 1; |
|
- | 303 | //MesswertGier += (Parameter_CouplingYawCorrection * tmpl4) / 256; |
|
287 | 304 | DebugOut.Analog[21] = KopplungsteilNickRoll; |
|
288 | MesswertGier += (Parameter_CouplingYawCorrection * tmpl4) / 128; |
305 | DebugOut.Analog[22] = KopplungsteilRollNick; |
Line 289... | Line -... | ||
289 | } |
- | |
290 | else tmpl = tmpl2 = 0; |
306 | } |
291 | 307 | else tmpl = tmpl2 = 0; |
|
292 | DebugOut.Analog[22] = tmpl; |
308 | |
293 | // Kompasswert begrenzen ++++++++++++++++++++++++++++++++++++++++++++++++ |
309 | // Kompasswert begrenzen ++++++++++++++++++++++++++++++++++++++++++++++++ |
294 | if(ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR; // 360° Umschlag |
310 | if(ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR; // 360° Umschlag |
Line 360... | Line 376... | ||
360 | Integral_Gier = Mess_Integral_Gier; |
376 | Integral_Gier = Mess_Integral_Gier; |
361 | IntegralNick = Mess_IntegralNick; |
377 | IntegralNick = Mess_IntegralNick; |
362 | IntegralRoll = Mess_IntegralRoll; |
378 | IntegralRoll = Mess_IntegralRoll; |
363 | IntegralNick2 = Mess_IntegralNick2; |
379 | IntegralNick2 = Mess_IntegralNick2; |
364 | IntegralRoll2 = Mess_IntegralRoll2; |
380 | IntegralRoll2 = Mess_IntegralRoll2; |
365 | - | ||
366 | if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) |
- | |
367 | { |
- | |
368 | if(MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200); |
- | |
369 | else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200); |
381 | MesswertNick = (RohMesswertNick + 2 * MesswertNick) / 3; |
370 | if(MesswertRoll > 200) MesswertRoll += 4 * (MesswertRoll - 200); |
- | |
371 | else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200); |
382 | MesswertRoll = (RohMesswertRoll + 2 * MesswertRoll) / 3; |
372 | } |
- | |
Line 373... | Line 383... | ||
373 | 383 | ||
374 | #define D_LIMIT 8 |
384 | #define D_LIMIT 8 |
375 | if(Parameter_Gyro_D) |
385 | if(Parameter_Gyro_D) |
376 | { |
386 | { |
Line 385... | Line 395... | ||
385 | if(d2Roll > D_LIMIT) d2Roll = D_LIMIT; |
395 | if(d2Roll > D_LIMIT) d2Roll = D_LIMIT; |
386 | else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT; |
396 | else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT; |
387 | MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D); |
397 | MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D); |
388 | } |
398 | } |
Line -... | Line 399... | ||
- | 399 | ||
- | 400 | if(RohMesswertRoll > 0) MesswertRoll += ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L; |
|
- | 401 | else MesswertRoll -= ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L; |
|
- | 402 | if(RohMesswertNick > 0) MesswertNick += ((long) abs(KopplungsteilRollNick) * Parameter_CouplingYawCorrection) / 64L; |
|
- | 403 | else MesswertNick -= ((long) abs(KopplungsteilRollNick) * Parameter_CouplingYawCorrection) / 64L; |
|
- | 404 | ||
- | 405 | if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) |
|
- | 406 | { |
|
- | 407 | if(RohMesswertNick > 256) MesswertNick += 1 * (RohMesswertNick - 256); |
|
- | 408 | else if(RohMesswertNick < -256) MesswertNick += 1 * (RohMesswertNick + 256); |
|
- | 409 | if(RohMesswertRoll > 256) MesswertRoll += 1 * (RohMesswertRoll - 256); |
|
- | 410 | else if(RohMesswertRoll < -256) MesswertRoll += 1 * (RohMesswertRoll + 256); |
|
- | 411 | } |
|
389 | 412 | ||
390 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
413 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
391 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
414 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
392 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
415 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
393 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
416 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
Line 508... | Line 531... | ||
508 | // CHK_POTI(Parameter_NaviWindCorrection,EE_Parameter.NaviWindCorrection,0,255); |
531 | // CHK_POTI(Parameter_NaviWindCorrection,EE_Parameter.NaviWindCorrection,0,255); |
509 | // CHK_POTI(Parameter_NaviSpeedCompensation,EE_Parameter.NaviSpeedCompensation,0,255); |
532 | // CHK_POTI(Parameter_NaviSpeedCompensation,EE_Parameter.NaviSpeedCompensation,0,255); |
Line 510... | Line 533... | ||
510 | 533 | ||
Line 511... | Line 534... | ||
511 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255); |
534 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255); |
- | 535 | ||
512 | 536 | //Ki = (float) Parameter_I_Faktor * 0.0001; |
|
513 | Ki = (float) Parameter_I_Faktor * 0.0001; |
537 | Ki = 10300 / (Parameter_I_Faktor + 1); |
514 | MAX_GAS = EE_Parameter.Gas_Max; |
538 | MAX_GAS = EE_Parameter.Gas_Max; |
Line 520... | Line 544... | ||
520 | //############################################################################ |
544 | //############################################################################ |
521 | // |
545 | // |
522 | void MotorRegler(void) |
546 | void MotorRegler(void) |
523 | //############################################################################ |
547 | //############################################################################ |
524 | { |
548 | { |
525 | int motorwert,pd_ergebnis,h,tmp_int; |
549 | int motorwert,pd_ergebnis, pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int; |
526 | int GierMischanteil,GasMischanteil; |
550 | int GierMischanteil,GasMischanteil; |
527 | static long SummeNick=0,SummeRoll=0; |
551 | static long SummeNick=0,SummeRoll=0; |
528 | static long sollGier = 0,tmp_long,tmp_long2; |
552 | static long sollGier = 0,tmp_long,tmp_long2; |
529 | static long IntegralFehlerNick = 0; |
553 | static long IntegralFehlerNick = 0; |
530 | static long IntegralFehlerRoll = 0; |
554 | static long IntegralFehlerRoll = 0; |
Line 533... | Line 557... | ||
533 | static unsigned char delay_einschalten = 0,delay_ausschalten = 0; |
557 | static unsigned char delay_einschalten = 0,delay_ausschalten = 0; |
534 | static int hoehenregler = 0; |
558 | static int hoehenregler = 0; |
535 | static char TimerWerteausgabe = 0; |
559 | static char TimerWerteausgabe = 0; |
536 | static char NeueKompassRichtungMerken = 0; |
560 | static char NeueKompassRichtungMerken = 0; |
537 | static long ausgleichNick, ausgleichRoll; |
561 | static long ausgleichNick, ausgleichRoll; |
538 | - | ||
- | 562 | int IntegralNickMalFaktor,IntegralRollMalFaktor; |
|
539 | Mittelwert(); |
563 | Mittelwert(); |
Line 540... | Line 564... | ||
540 | 564 | ||
541 | GRN_ON; |
565 | GRN_ON; |
542 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
566 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 711... | Line 735... | ||
711 | } |
735 | } |
Line 712... | Line 736... | ||
712 | 736 | ||
713 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
737 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
714 | // neue Werte von der Funke |
738 | // neue Werte von der Funke |
- | 739 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
715 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
740 | |
716 | if(!NewPpmData-- || Notlandung) |
741 | if(!NewPpmData-- || Notlandung) |
717 | { |
742 | { |
718 | int tmp_int; |
743 | int tmp_int; |
719 | static int stick_nick,stick_roll; |
744 | static int stick_nick,stick_roll; |
Line 724... | Line 749... | ||
724 | 749 | ||
725 | stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4; |
750 | stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4; |
726 | stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
751 | stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
Line 727... | Line -... | ||
727 | StickRoll = stick_roll - (GPS_Roll + GPS_Roll2); |
- | |
728 | 752 | StickRoll = stick_roll - (GPS_Roll + GPS_Roll2); |
|
729 | 753 | ||
730 | StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; |
754 | StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; |
Line 731... | Line 755... | ||
731 | if(StickGier > 2) StickGier -= 2; else |
755 | if(StickGier > 2) StickGier -= 2; else |
Line 736... | Line 760... | ||
736 | /* if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick) |
760 | /* if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick) |
737 | MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--; |
761 | MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--; |
738 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll) |
762 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll) |
739 | MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--; |
763 | MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--; |
740 | */ |
764 | */ |
741 | GyroFaktor = ((float)Parameter_Gyro_P + 10.0) / (256.0/STICK_GAIN); |
765 | // GyroFaktor = ((float)Parameter_Gyro_P + 10.0) / (256.0/STICK_GAIN); |
- | 766 | GyroFaktor = (Parameter_Gyro_P + 10.0); |
|
742 | IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN); |
767 | // IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN); |
- | 768 | IntegralFaktor = Parameter_Gyro_I; |
|
Line 743... | Line 769... | ||
743 | 769 | ||
744 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
770 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
745 | //+ Analoge Steuerung per Seriell |
771 | //+ Analoge Steuerung per Seriell |
746 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
772 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 807... | Line 833... | ||
807 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0; |
833 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0; |
808 | } |
834 | } |
809 | } |
835 | } |
Line 810... | Line 836... | ||
810 | 836 | ||
811 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
837 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
812 | if(Looping_Oben || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
838 | if(Looping_Oben || Looping_Unten) { Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
Line 813... | Line 839... | ||
813 | } // Ende neue Funken-Werte |
839 | } // Ende neue Funken-Werte |
814 | 840 | ||
815 | if(Looping_Roll || Looping_Nick) |
841 | if(Looping_Roll || Looping_Nick) |
- | 842 | { |
|
816 | { |
843 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
Line 817... | Line 844... | ||
817 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
844 | TrichterFlug = 1; |
818 | } |
845 | } |
Line 824... | Line 851... | ||
824 | if(Notlandung) |
851 | if(Notlandung) |
825 | { |
852 | { |
826 | StickGier = 0; |
853 | StickGier = 0; |
827 | StickNick = 0; |
854 | StickNick = 0; |
828 | StickRoll = 0; |
855 | StickRoll = 0; |
829 | GyroFaktor = (float) 100 / (256.0 / STICK_GAIN); |
856 | GyroFaktor = 90;//(float) 100 / (256.0 / STICK_GAIN); |
830 | IntegralFaktor = (float) 120 / (44000 / STICK_GAIN); |
857 | IntegralFaktor = 120;//(float) 120 / (44000 / STICK_GAIN); |
831 | Looping_Roll = 0; |
858 | Looping_Roll = 0; |
832 | Looping_Nick = 0; |
859 | Looping_Nick = 0; |
833 | } |
860 | } |
Line 957... | Line 984... | ||
957 | if(EE_Parameter.Driftkomp) |
984 | if(EE_Parameter.Driftkomp) |
958 | { |
985 | { |
959 | if(GierGyroFehler > ABGLEICH_ANZAHL/2) { AdNeutralGier++; AdNeutralGierBias++; } |
986 | if(GierGyroFehler > ABGLEICH_ANZAHL/2) { AdNeutralGier++; AdNeutralGierBias++; } |
960 | if(GierGyroFehler <-ABGLEICH_ANZAHL/2) { AdNeutralGier--; AdNeutralGierBias--; } |
987 | if(GierGyroFehler <-ABGLEICH_ANZAHL/2) { AdNeutralGier--; AdNeutralGierBias--; } |
961 | } |
988 | } |
962 | DebugOut.Analog[22] = MittelIntegralRoll / 26; |
989 | //DebugOut.Analog[22] = MittelIntegralRoll / 26; |
963 | //DebugOut.Analog[24] = GierGyroFehler; |
990 | //DebugOut.Analog[24] = GierGyroFehler; |
964 | GierGyroFehler = 0; |
991 | GierGyroFehler = 0; |
Line 965... | Line 992... | ||
965 | 992 | ||
Line 1091... | Line 1118... | ||
1091 | }; |
1118 | }; |
1092 | } |
1119 | } |
1093 | tmp_int = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
1120 | tmp_int = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
1094 | tmp_int += (EE_Parameter.Gier_P * StickGier) / 4; |
1121 | tmp_int += (EE_Parameter.Gier_P * StickGier) / 4; |
1095 | sollGier = tmp_int; |
1122 | sollGier = tmp_int; |
1096 | DebugOut.Analog[21] = tmp_int; |
- | |
1097 | Mess_Integral_Gier -= tmp_int; |
1123 | Mess_Integral_Gier -= tmp_int; |
1098 | if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen |
1124 | if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen |
1099 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
1125 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
Line 1100... | Line 1126... | ||
1100 | 1126 | ||
Line 1209... | Line 1235... | ||
1209 | } |
1235 | } |
Line 1210... | Line 1236... | ||
1210 | 1236 | ||
1211 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1237 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1212 | // Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen |
1238 | // Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen |
- | 1239 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1240 | if(TrichterFlug) { SummeRoll = 0; SummeNick = 0;}; |
|
- | 1241 | ||
- | 1242 | if(!Looping_Nick) IntegralNickMalFaktor = (IntegralNick * IntegralFaktor) / (44000 / STICK_GAIN); else IntegralNickMalFaktor = 0; |
|
- | 1243 | if(!Looping_Roll) IntegralRollMalFaktor = (IntegralRoll * IntegralFaktor) / (44000 / STICK_GAIN); else IntegralRollMalFaktor = 0; |
|
- | 1244 | ||
- | 1245 | MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor) / (256L / STICK_GAIN); |
|
Line 1213... | Line -... | ||
1213 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1214 | - | ||
1215 | if(Looping_Nick) MesswertNick = MesswertNick * GyroFaktor; |
- | |
1216 | else MesswertNick = IntegralNick * IntegralFaktor + MesswertNick * GyroFaktor; |
- | |
1217 | if(Looping_Roll) MesswertRoll = MesswertRoll * GyroFaktor; |
1246 | MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor) / (256L / STICK_GAIN); |
1218 | else MesswertRoll = IntegralRoll * IntegralFaktor + MesswertRoll * GyroFaktor; |
1247 | |
1219 | #ifdef OCTO |
1248 | #ifdef OCTO |
1220 | MesswertGier = MesswertGier * (2 * GyroFaktor) + Integral_Gier * IntegralFaktor / 2; |
1249 | MesswertGier = (long)(MesswertGier * 4 * (long)GyroFaktor) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktor) / (4 * (44000 / STICK_GAIN)); |
1221 | #else |
1250 | #else |
Line 1222... | Line 1251... | ||
1222 | MesswertGier = MesswertGier * (4 * GyroFaktor) + Integral_Gier * IntegralFaktor / 4; |
1251 | MesswertGier = (long)(MesswertGier * 2 * (long)GyroFaktor) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktor) / (2 * (44000 / STICK_GAIN)); |
1223 | #endif |
1252 | #endif |
- | 1253 | ||
1224 | 1254 | // Maximalwerte abfangen |
|
1225 | // Maximalwerte abfangen |
1255 | // #define MAX_SENSOR (4096*STICK_GAIN) |
1226 | #define MAX_SENSOR (4096*STICK_GAIN) |
1256 | #define MAX_SENSOR (4096*4) |
1227 | if(MesswertNick > MAX_SENSOR) MesswertNick = MAX_SENSOR; |
1257 | if(MesswertNick > MAX_SENSOR) MesswertNick = MAX_SENSOR; |
1228 | if(MesswertNick < -MAX_SENSOR) MesswertNick = -MAX_SENSOR; |
1258 | if(MesswertNick < -MAX_SENSOR) MesswertNick = -MAX_SENSOR; |
1229 | if(MesswertRoll > MAX_SENSOR) MesswertRoll = MAX_SENSOR; |
1259 | if(MesswertRoll > MAX_SENSOR) MesswertRoll = MAX_SENSOR; |
Line 1305... | Line 1335... | ||
1305 | GasMischanteil = hoehenregler; |
1335 | GasMischanteil = hoehenregler; |
1306 | } |
1336 | } |
1307 | } |
1337 | } |
1308 | if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
1338 | if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
Line -... | Line 1339... | ||
- | 1339 | ||
1309 | 1340 | ||
1310 | #ifdef OCTO |
1341 | #ifdef OCTO |
1311 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1342 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1312 | // + Mischer und PI-Regler |
1343 | // + Mischer und PI-Regler |
1313 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1344 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 1335... | Line 1366... | ||
1335 | 1366 | ||
1336 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1367 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1337 | // Nick-Achse |
1368 | // Nick-Achse |
1338 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1369 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1339 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
1370 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
1340 | if(IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - StickNick; // I-Anteil bei Winkelregelung |
1371 | if(IntegralFaktor) SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung |
1341 | else SummeNick += DiffNick; // I-Anteil bei HH |
1372 | else SummeNick += DiffNick; // I-Anteil bei HH |
1342 | if(SummeNick > (STICK_GAIN * 16000L)) SummeNick = (STICK_GAIN * 16000L); |
1373 | if(SummeNick > (STICK_GAIN * 16000L)) SummeNick = (STICK_GAIN * 16000L); |
1343 | if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN); |
1374 | if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN); |
1344 | pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick |
1375 | pd_ergebnis_nick = DiffNick + SummeNick / Ki; // PI-Regler für Nick |
1345 | // Motor Vorn |
1376 | // Motor Vorn |
1346 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1377 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1347 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1378 | if(pd_ergebnis_nick > tmp_int) pd_ergebnis_nick = tmp_int; |
Line -... | Line 1379... | ||
- | 1379 | if(pd_ergebnis_nick < -tmp_int) pd_ergebnis_nick = -tmp_int; |
|
- | 1380 | ||
- | 1381 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1382 | // Roll-Achse |
|
- | 1383 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1384 | DiffRoll = MesswertRoll - StickRoll; // Differenz bestimmen |
|
- | 1385 | if(IntegralFaktor) SummeRoll += IntegralRollMalFaktor - StickRoll;// I-Anteil bei Winkelregelung |
|
- | 1386 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
|
- | 1387 | if(SummeRoll > (STICK_GAIN * 16000L)) SummeRoll = (STICK_GAIN * 16000L); |
|
- | 1388 | if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN); |
|
- | 1389 | pd_ergebnis_roll = DiffRoll + SummeRoll / Ki; // PI-Regler für Roll |
|
- | 1390 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
|
- | 1391 | if(pd_ergebnis_roll > tmp_int) pd_ergebnis_roll = tmp_int; |
|
- | 1392 | if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int; |
|
- | 1393 | ||
- | 1394 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
1348 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1395 | // Octo-Mischer |
1349 | 1396 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
1350 | motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; // Mischer |
1397 | motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil; |
1351 | motorwert /= STICK_GAIN; |
1398 | motorwert /= STICK_GAIN; |
1352 | if ((motorwert < 0)) motorwert = 0; |
1399 | if ((motorwert < 0)) motorwert = 0; |
1353 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1400 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
Line 1354... | Line 1401... | ||
1354 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1401 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1355 | Motor1 = motorwert; |
1402 | Motor1 = motorwert; |
1356 | 1403 | ||
1357 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; // Mischer |
1404 | motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil; |
1358 | motorwert /= STICK_GAIN; |
1405 | motorwert /= STICK_GAIN; |
1359 | if ((motorwert < 0)) motorwert = 0; |
1406 | if ((motorwert < 0)) motorwert = 0; |
Line 1360... | Line -... | ||
1360 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
- | |
1361 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1407 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1362 | Motor2 = motorwert; |
1408 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1363 | 1409 | Motor2 = motorwert; |
|
1364 | // Motor Heck |
1410 | |
1365 | motorwert = GasMischanteil - pd_ergebnis + GierMischanteil; |
1411 | motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil; |
1366 | motorwert /= STICK_GAIN; |
1412 | motorwert /= STICK_GAIN; |
Line 1367... | Line -... | ||
1367 | if ((motorwert < 0)) motorwert = 0; |
- | |
1368 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1413 | if ((motorwert < 0)) motorwert = 0; |
1369 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1414 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1370 | Motor5 = motorwert; |
1415 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1371 | 1416 | Motor3 = motorwert; |
|
1372 | // Motor Heck |
1417 | |
1373 | motorwert = GasMischanteil - pd_ergebnis - GierMischanteil; |
1418 | motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil; |
1374 | motorwert /= STICK_GAIN; |
- | |
1375 | if ((motorwert < 0)) motorwert = 0; |
- | |
1376 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
- | |
1377 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
- | |
1378 | Motor6 = motorwert; |
- | |
1379 | - | ||
1380 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1381 | // Roll-Achse |
- | |
1382 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1383 | DiffRoll = MesswertRoll - StickRoll; // Differenz bestimmen |
- | |
1384 | if(IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - StickRoll;// I-Anteil bei Winkelregelung |
- | |
1385 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
- | |
1386 | if(SummeRoll > (STICK_GAIN * 16000L)) SummeRoll = (STICK_GAIN * 16000L); |
- | |
Line 1387... | Line -... | ||
1387 | if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN); |
- | |
1388 | pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll |
1419 | motorwert /= STICK_GAIN; |
1389 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1420 | if ((motorwert < 0)) motorwert = 0; |
1390 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1421 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1391 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1422 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1392 | 1423 | Motor4 = motorwert; |
|
1393 | // Motor Links |
1424 | |
Line 1394... | Line -... | ||
1394 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; |
- | |
1395 | motorwert /= STICK_GAIN; |
1425 | motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil; |
1396 | if ((motorwert < 0)) motorwert = 0; |
1426 | motorwert /= STICK_GAIN; |
1397 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1427 | if ((motorwert < 0)) motorwert = 0; |
1398 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1428 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1399 | Motor8 = motorwert; |
1429 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1400 | 1430 | Motor5 = motorwert; |
|
Line 1401... | Line -... | ||
1401 | // Motor Links |
- | |
1402 | motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; |
1431 | |
1403 | motorwert /= STICK_GAIN; |
1432 | motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil; |
1404 | if ((motorwert < 0)) motorwert = 0; |
1433 | motorwert /= STICK_GAIN; |
1405 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1434 | if ((motorwert < 0)) motorwert = 0; |
1406 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1435 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1407 | Motor7 = motorwert; |
1436 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
Line 1408... | Line -... | ||
1408 | - | ||
1409 | // Motor Rechts |
1437 | Motor6 = motorwert; |
1410 | motorwert = GasMischanteil - pd_ergebnis + GierMischanteil; |
1438 | |
1411 | motorwert /= STICK_GAIN; |
1439 | motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil; |
1412 | if ((motorwert < 0)) motorwert = 0; |
1440 | motorwert /= STICK_GAIN; |
1413 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1441 | if ((motorwert < 0)) motorwert = 0; |
1414 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1442 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1415 | Motor3 = motorwert; |
1443 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
- | 1444 | Motor7 = motorwert; |
|
- | 1445 | ||
- | 1446 | motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil; |
|
- | 1447 | motorwert /= STICK_GAIN; |
|
- | 1448 | if ((motorwert < 0)) motorwert = 0; |
|
- | 1449 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
|
1416 | 1450 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
|
1417 | // Motor Rechts |
1451 | Motor8 = motorwert; |
Line 1418... | Line 1452... | ||
1418 | motorwert = GasMischanteil - pd_ergebnis - GierMischanteil; |
1452 | // +++++++++++++++++++++++++++++++++++++++++++++++ |
1419 | motorwert /= STICK_GAIN; |
1453 | /* |
Line 1452... | Line 1486... | ||
1452 | 1486 | ||
1453 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1487 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1454 | // Nick-Achse |
1488 | // Nick-Achse |
1455 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1489 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1456 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
1490 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
1457 | if(IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - StickNick; // I-Anteil bei Winkelregelung |
1491 | if(IntegralFaktor) SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung |
1458 | else SummeNick += DiffNick; // I-Anteil bei HH |
1492 | else SummeNick += DiffNick; // I-Anteil bei HH |
1459 | if(SummeNick > (STICK_GAIN * 16000L)) SummeNick = (STICK_GAIN * 16000L); |
1493 | if(SummeNick > (STICK_GAIN * 16000L)) SummeNick = (STICK_GAIN * 16000L); |
1460 | if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN); |
1494 | if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN); |
1461 | pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick |
1495 | pd_ergebnis = DiffNick + SummeNick / Ki; // PI-Regler für Nick |
1462 | // Motor Vorn |
1496 | // Motor Vorn |
1463 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1497 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1464 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1498 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
Line 1479... | Line 1513... | ||
1479 | Motor_Hinten = motorwert; |
1513 | Motor_Hinten = motorwert; |
1480 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1514 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1481 | // Roll-Achse |
1515 | // Roll-Achse |
1482 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1516 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1483 | DiffRoll = MesswertRoll - StickRoll; // Differenz bestimmen |
1517 | DiffRoll = MesswertRoll - StickRoll; // Differenz bestimmen |
1484 | if(IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - StickRoll;// I-Anteil bei Winkelregelung |
1518 | if(IntegralFaktor) SummeRoll += IntegralRollMalFaktor - StickRoll;// I-Anteil bei Winkelregelung |
1485 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
1519 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
1486 | if(SummeRoll > (STICK_GAIN * 16000L)) SummeRoll = (STICK_GAIN * 16000L); |
1520 | if(SummeRoll > (STICK_GAIN * 16000L)) SummeRoll = (STICK_GAIN * 16000L); |
1487 | if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN); |
1521 | if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN); |
1488 | pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll |
1522 | pd_ergebnis = DiffRoll + SummeRoll / Ki; // PI-Regler für Roll |
1489 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1523 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1490 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1524 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1491 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1525 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1492 | // Motor Links |
1526 | // Motor Links |
1493 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; |
1527 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; |
Line 1504... | Line 1538... | ||
1504 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1538 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1505 | Motor_Rechts = motorwert; |
1539 | Motor_Rechts = motorwert; |
1506 | // +++++++++++++++++++++++++++++++++++++++++++++++ |
1540 | // +++++++++++++++++++++++++++++++++++++++++++++++ |
1507 | //Motor_Hinten = 0; |
1541 | //Motor_Hinten = 0; |
1508 | //Motor_Vorne = 0; |
1542 | //Motor_Vorne = 0; |
- | 1543 | //Motor_Links = 0; |
|
- | 1544 | //Motor_Rechts = 0; |
|
1509 | } |
1545 | } |
Line 1510... | Line 1546... | ||
1510 | 1546 |