Rev 2176 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2176 | Rev 2177 | ||
---|---|---|---|
Line 56... | Line 56... | ||
56 | 56 | ||
57 | #include "main.h" |
57 | #include "main.h" |
58 | #include "mymath.h" |
58 | #include "mymath.h" |
Line -... | Line 59... | ||
- | 59 | #include "isqrt.h" |
|
- | 60 | ||
- | 61 | ||
- | 62 | //MartinW; added vars |
|
- | 63 | unsigned char loop1, loop2, loop3; |
|
- | 64 | unsigned char settingdest = 5; |
|
- | 65 | char keynumber=-7; |
|
- | 66 | unsigned char jetistepstep[] = {1,5,10,25,50}, jetistep = 0; |
|
- | 67 | ||
- | 68 | ||
- | 69 | unsigned short CurrentOffset = 0;/// |
|
- | 70 | ||
- | 71 | unsigned char Motors[12]; //MartinR: Fehlersuche (war 8) |
|
- | 72 | unsigned char Motorsmax[12]; //MartinR: Fehlersuche (war 8) |
|
- | 73 | unsigned short MotorsTmax; |
|
- | 74 | unsigned char updatemotors=2; |
|
- | 75 | ||
- | 76 | //Panorama Trigger; |
|
- | 77 | int degreeold =0; |
|
- | 78 | int degreedivold =0; |
|
- | 79 | int degreediv =0; |
|
- | 80 | unsigned int panograd=0; |
|
- | 81 | unsigned char panotrigger=0; |
|
- | 82 | unsigned char calibration_done = 0; |
|
- | 83 | ||
- | 84 | unsigned char jetibeepcode[] = {130,'E','I','S','H'}; |
|
- | 85 | ||
- | 86 | ||
- | 87 | ///MartinW; added vars END |
|
- | 88 | ||
59 | #include "isqrt.h" |
89 | |
60 | 90 | ||
61 | unsigned char h,m,s; |
91 | unsigned char h,m,s; |
62 | unsigned int BaroExpandActive = 0; |
92 | unsigned int BaroExpandActive = 0; |
63 | int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias, RohMesswertNick,RohMesswertRoll; |
93 | int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias, RohMesswertNick,RohMesswertRoll; |
Line 72... | Line 102... | ||
72 | long IntegralRoll = 0,IntegralRoll2 = 0; |
102 | long IntegralRoll = 0,IntegralRoll2 = 0; |
73 | long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0; |
103 | long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0; |
74 | long Integral_Gier = 0; |
104 | long Integral_Gier = 0; |
75 | long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0; |
105 | long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0; |
76 | long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0; |
106 | long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0; |
77 | long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0; |
107 | //long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0; ///MartinW so war es |
- | 108 | long Mess_Integral_Gier = 0; ///MartinW: Mess_Integral_Gier2 unbenutzt |
|
- | 109 | ||
78 | long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2; |
110 | long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2; |
79 | long SummeNick=0,SummeRoll=0; |
111 | long SummeNick=0,SummeRoll=0; |
80 | volatile long Mess_Integral_Hoch = 0; |
112 | volatile long Mess_Integral_Hoch = 0; |
81 | int KompassValue = -1; |
113 | int KompassValue = -1; |
82 | int KompassSollWert = 0; |
114 | int KompassSollWert = 0; |
Line 111... | Line 143... | ||
111 | unsigned char CalibrationDone = 0; |
143 | unsigned char CalibrationDone = 0; |
112 | char NeueKompassRichtungMerken = 0; |
144 | char NeueKompassRichtungMerken = 0; |
113 | int LageKorrekturRoll = 0,LageKorrekturNick = 0, HoverGas = 0; |
145 | int LageKorrekturRoll = 0,LageKorrekturNick = 0, HoverGas = 0; |
114 | //float Ki = FAKTOR_I; |
146 | //float Ki = FAKTOR_I; |
115 | int Ki = 10300 / 33; |
147 | int Ki = 10300 / 33; |
- | 148 | int KiHH = 10300 / 33; // MartinR : für Ki bei HH über Schalter |
|
- | 149 | ||
116 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
150 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
117 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
151 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
Line 118... | Line 152... | ||
118 | 152 | ||
119 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
153 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
Line 162... | Line 196... | ||
162 | unsigned char Parameter_GlobalConfig; |
196 | unsigned char Parameter_GlobalConfig; |
163 | unsigned char Parameter_ExtraConfig; |
197 | unsigned char Parameter_ExtraConfig; |
164 | unsigned char Parameter_MaximumAltitude; |
198 | unsigned char Parameter_MaximumAltitude; |
165 | unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5; |
199 | unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5; |
166 | unsigned char CareFree = 0; |
200 | unsigned char CareFree = 0; |
167 | const signed char sintab[31] = { 0, 2, 4, 6, 7, 8, 8, 8, 7, 6, 4, 2, 0, -2, -4, -6, -7, -8, -8, -8, -7, -6, -4, -2, 0, 2, 4, 6, 7, 8, 8}; // 15° steps |
201 | //const signed char sintab[31] = { 0, 2, 4, 6, 7, 8, 8, 8, 7, 6, 4, 2, 0, -2, -4, -6, -7, -8, -8, -8, -7, -6, -4, -2, 0, 2, 4, 6, 7, 8, 8}; // 15° steps // MartinR: so war es |
- | 202 | const signed char sintab[62] = { 0, 2, 4, 6, 8, 10, 12, 13, 14, 15, 16, 16, 16, 16, 16, 15, 14, 13, 12, 10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, -12, -13, -14, -15, -16, -16, -16, -16, -16, -15, -14, -13, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 13, 14, 15, 16, 16, 16}; // 7,5° steps //MartinR |
|
- | 203 | signed char cosinus, sinus; // MartinR : extern für PAN-Funktion |
|
Line 168... | Line 204... | ||
168 | 204 | ||
169 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
205 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
- | 206 | //int MaxStickNick = 0,MaxStickRoll = 0; MartinR: so war es |
|
- | 207 | int MaxStickNick = 0,MaxStickRoll = 0,stick_nick_neutral = 0,stick_roll_neutral = 0; // MartinR: stick_.._neutral hinzugefügt |
|
- | 208 | unsigned char stick_p; // MartinR: Test |
|
170 | int MaxStickNick = 0,MaxStickRoll = 0; |
209 | |
171 | unsigned int modell_fliegt = 0; |
210 | unsigned int modell_fliegt = 0; |
172 | volatile unsigned char FC_StatusFlags = 0, FC_StatusFlags2 = 0; |
211 | volatile unsigned char FC_StatusFlags = 0, FC_StatusFlags2 = 0; |
173 | long GIER_GRAD_FAKTOR = 1291; |
212 | long GIER_GRAD_FAKTOR = 1291; |
174 | signed int KopplungsteilNickRoll,KopplungsteilRollNick; |
213 | signed int KopplungsteilNickRoll,KopplungsteilRollNick; |
Line 199... | Line 238... | ||
199 | DebugOut.Analog[11] = ErsatzKompassInGrad; |
238 | DebugOut.Analog[11] = ErsatzKompassInGrad; |
200 | DebugOut.Analog[12] = Motor[0].SetPoint; |
239 | DebugOut.Analog[12] = Motor[0].SetPoint; |
201 | DebugOut.Analog[13] = Motor[1].SetPoint; |
240 | DebugOut.Analog[13] = Motor[1].SetPoint; |
202 | DebugOut.Analog[14] = Motor[2].SetPoint; |
241 | DebugOut.Analog[14] = Motor[2].SetPoint; |
203 | DebugOut.Analog[15] = Motor[3].SetPoint; |
242 | DebugOut.Analog[15] = Motor[3].SetPoint; |
- | 243 | ||
- | 244 | DebugOut.Analog[16] = cosinus; // MartinR: zur Einstellung der Pan-Funktion |
|
- | 245 | DebugOut.Analog[17] = sinus; // MartinR: test zur Einstellung der Pan-Funktion |
|
- | 246 | DebugOut.Analog[18] = ServoPanValue; // MartinR: zur Einstellung der Pan-Funktion |
|
- | 247 | DebugOut.Analog[19] = ServoRollValue; // MartinR: Test |
|
- | 248 | ||
204 | DebugOut.Analog[20] = ServoNickValue; |
249 | DebugOut.Analog[20] = ServoNickValue; |
205 | DebugOut.Analog[22] = Capacity.ActualCurrent; |
250 | DebugOut.Analog[22] = Capacity.ActualCurrent; |
- | 251 | #ifdef WITH_REMAINCAPACITY // only include functions if DEBUG is defined in main.h |
|
- | 252 | ||
- | 253 | #warning : "### with REMAIN CAPACITY ###" |
|
- | 254 | DebugOut.Analog[23] = Capacity.RemainCapacity; |
|
- | 255 | #else |
|
206 | DebugOut.Analog[23] = Capacity.UsedCapacity; |
256 | DebugOut.Analog[23] = Capacity.UsedCapacity; |
- | 257 | #endif |
|
- | 258 | ||
207 | DebugOut.Analog[24] = SollHoehe/5; |
259 | DebugOut.Analog[24] = SollHoehe/5; |
208 | // DebugOut.Analog[22] = FromNaviCtrl_Value.GpsZ; |
260 | // DebugOut.Analog[22] = FromNaviCtrl_Value.GpsZ; |
209 | // DebugOut.Analog[29] = FromNaviCtrl_Value.SerialDataOkay; |
261 | // DebugOut.Analog[29] = FromNaviCtrl_Value.SerialDataOkay; |
- | 262 | DebugOut.Analog[25] = FC_StatusFlags;// MartinR: Test |
|
- | 263 | DebugOut.Analog[26] = FC_StatusFlags2;// MartinR: Test |
|
- | 264 | ||
210 | DebugOut.Analog[27] = KompassSollWert; |
265 | DebugOut.Analog[27] = KompassSollWert; |
211 | DebugOut.Analog[29] = Capacity.MinOfMaxPWM; |
266 | DebugOut.Analog[29] = Capacity.MinOfMaxPWM; |
212 | DebugOut.Analog[30] = GPS_Nick; |
267 | DebugOut.Analog[30] = GPS_Nick; |
213 | DebugOut.Analog[31] = GPS_Roll; |
268 | DebugOut.Analog[31] = GPS_Roll; |
214 | if(VersionInfo.HardwareError[0] || VersionInfo.HardwareError[1]) DebugOut.Status[1] |= 1; else DebugOut.Status[1] &= 0xfe; |
269 | if(VersionInfo.HardwareError[0] || VersionInfo.HardwareError[1]) DebugOut.Status[1] |= 1; else DebugOut.Status[1] &= 0xfe; |
Line 372... | Line 427... | ||
372 | if((AdNeutralGier < 150 * 2) || (AdNeutralGier > 850 * 2)) { VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_YAW; }; |
427 | if((AdNeutralGier < 150 * 2) || (AdNeutralGier > 850 * 2)) { VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_YAW; }; |
373 | if((NeutralAccX < 300) || (NeutralAccX > 750)) { VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_NICK; }; |
428 | if((NeutralAccX < 300) || (NeutralAccX > 750)) { VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_NICK; }; |
374 | if((NeutralAccY < 300) || (NeutralAccY > 750)) { VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_ROLL; }; |
429 | if((NeutralAccY < 300) || (NeutralAccY > 750)) { VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_ROLL; }; |
375 | if((NeutralAccZ < 512) || (NeutralAccZ > 850)) { VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_TOP; }; |
430 | if((NeutralAccZ < 512) || (NeutralAccZ > 850)) { VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_TOP; }; |
376 | carefree_old = 70; |
431 | carefree_old = 70; |
377 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
432 | #if ((defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) && defined(WITH_HOTTMENU)) |
- | 433 | #warning : "### with Hottmenu ###" |
|
378 | LIBFC_HoTT_Clear(); |
434 | LIBFC_HoTT_Clear(); |
379 | #endif |
435 | #endif |
380 | } |
436 | } |
Line 387... | Line 443... | ||
387 | { |
443 | { |
388 | static signed long tmpl,tmpl2,tmpl3,tmpl4; |
444 | static signed long tmpl,tmpl2,tmpl3,tmpl4; |
389 | static signed int oldNick, oldRoll, d2Roll, d2Nick; |
445 | static signed int oldNick, oldRoll, d2Roll, d2Nick; |
390 | signed long winkel_nick, winkel_roll; |
446 | signed long winkel_nick, winkel_roll; |
391 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
447 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
392 | MesswertNick = (signed int) AdWertNickFilter / 8; |
448 | //MesswertNick = (signed int) AdWertNickFilter / 8; // MartinR: so war es |
393 | MesswertRoll = (signed int) AdWertRollFilter / 8; |
449 | //MesswertRoll = (signed int) AdWertRollFilter / 8; // MartinR: so war es |
- | 450 | MesswertNick = (signed int) AdWertNickFilter ; // MartinR die Division /8 erfolgt bereits in der analog.c |
|
- | 451 | MesswertRoll = (signed int) AdWertRollFilter ; // MartinR die Division /8 erfolgt bereits in der analog.c |
|
394 | RohMesswertNick = MesswertNick; |
452 | RohMesswertNick = MesswertNick; |
395 | RohMesswertRoll = MesswertRoll; |
453 | RohMesswertRoll = MesswertRoll; |
Line 396... | Line 454... | ||
396 | 454 | ||
397 | // Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++ |
455 | // Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 431... | Line 489... | ||
431 | tmpl4 *= Parameter_AchsKopplung2; //65 |
489 | tmpl4 *= Parameter_AchsKopplung2; //65 |
432 | tmpl4 /= 4096L; |
490 | tmpl4 /= 4096L; |
433 | KopplungsteilNickRoll = tmpl3; |
491 | KopplungsteilNickRoll = tmpl3; |
434 | KopplungsteilRollNick = tmpl4; |
492 | KopplungsteilRollNick = tmpl4; |
435 | tmpl4 -= tmpl3; |
493 | tmpl4 -= tmpl3; |
- | 494 | if(IntegralFaktor) // MartinR: nur im ACC-Mode |
|
- | 495 | { |
|
436 | ErsatzKompass += tmpl4; |
496 | ErsatzKompass += tmpl4; |
437 | if(!Parameter_CouplingYawCorrection) Mess_Integral_Gier -= tmpl4/2; // Gier nachhelfen |
497 | if(!Parameter_CouplingYawCorrection) Mess_Integral_Gier -= tmpl4/2; // Gier nachhelfen |
438 | 498 | } |
|
439 | tmpl = ((MesswertGier + tmpl4) * winkel_nick) / 2048L; |
499 | tmpl = ((MesswertGier + tmpl4) * winkel_nick) / 2048L; |
440 | tmpl *= Parameter_AchsKopplung1; // 90 |
500 | tmpl *= Parameter_AchsKopplung1; // 90 |
441 | tmpl /= 4096L; |
501 | tmpl /= 4096L; |
442 | tmpl2 = ((MesswertGier + tmpl4) * winkel_roll) / 2048L; |
502 | tmpl2 = ((MesswertGier + tmpl4) * winkel_roll) / 2048L; |
443 | tmpl2 *= Parameter_AchsKopplung1; |
503 | tmpl2 *= Parameter_AchsKopplung1; |
Line 482... | Line 542... | ||
482 | IntegralNick = Mess_IntegralNick; |
542 | IntegralNick = Mess_IntegralNick; |
483 | IntegralRoll = Mess_IntegralRoll; |
543 | IntegralRoll = Mess_IntegralRoll; |
484 | IntegralNick2 = Mess_IntegralNick2; |
544 | IntegralNick2 = Mess_IntegralNick2; |
485 | IntegralRoll2 = Mess_IntegralRoll2; |
545 | IntegralRoll2 = Mess_IntegralRoll2; |
Line -... | Line 546... | ||
- | 546 | ||
486 | 547 | //#define D_LIMIT 128 // MartinR: so war es |
|
- | 548 | #define D_LIMIT 16 |
|
487 | #define D_LIMIT 128 |
549 | // MartinR: Änderung war notwendig, da die Division /8 bereits in der analog.c erfolgt |
488 | 550 | ||
489 | MesswertNick = HiResNick / 8; |
551 | //MesswertNick = HiResNick / 8; // MartinR : so war es |
- | 552 | // MesswertRoll = HiResRoll / 8; // MartinR : so war es |
|
- | 553 | MesswertNick = HiResNick ; // MartinR die Division /8 erfolgt bereits in der analog.c |
|
Line -... | Line 554... | ||
- | 554 | MesswertRoll = HiResRoll ; // MartinR die Division /8 erfolgt bereits in der analog.c |
|
- | 555 | ||
- | 556 | // MartinR : so war es Anfang |
|
490 | MesswertRoll = HiResRoll / 8; |
557 | /* |
491 | 558 | |
|
492 | if(AdWertNick < 15) MesswertNick = -1000; if(AdWertNick < 7) MesswertNick = -2000; |
559 | if(AdWertNick < 15) MesswertNick = -1000; if(AdWertNick < 7) MesswertNick = -2000; |
493 | if(PlatinenVersion == 10) { if(AdWertNick > 1010) MesswertNick = +1000; if(AdWertNick > 1017) MesswertNick = +2000; } |
560 | if(PlatinenVersion == 10) { if(AdWertNick > 1010) MesswertNick = +1000; if(AdWertNick > 1017) MesswertNick = +2000; } |
494 | else { if(AdWertNick > 2000) MesswertNick = +1000; if(AdWertNick > 2015) MesswertNick = +2000; } |
561 | else { if(AdWertNick > 2000) MesswertNick = +1000; if(AdWertNick > 2015) MesswertNick = +2000; } |
495 | if(AdWertRoll < 15) MesswertRoll = -1000; if(AdWertRoll < 7) MesswertRoll = -2000; |
562 | if(AdWertRoll < 15) MesswertRoll = -1000; if(AdWertRoll < 7) MesswertRoll = -2000; |
- | 563 | if(PlatinenVersion == 10) { if(AdWertRoll > 1010) MesswertRoll = +1000; if(AdWertRoll > 1017) MesswertRoll = +2000; } |
|
- | 564 | else { if(AdWertRoll > 2000) MesswertRoll = +1000; if(AdWertRoll > 2015) MesswertRoll = +2000; } |
|
- | 565 | |
|
- | 566 | // MartinR : FC 1.0: Sprung von 500 auf 2000 !! FC-ME: Sprung von 1000 auf 2000 |
|
- | 567 | */ |
|
- | 568 | // MartinR : so war es Ende |
|
- | 569 | ||
- | 570 | // MartinR : Neu Anfang |
|
- | 571 | if(PlatinenVersion == 10) |
|
- | 572 | { |
|
- | 573 | if(AdWertNick > 1010) MesswertNick = +600; |
|
- | 574 | if(AdWertNick > 1017) MesswertNick = +800; |
|
- | 575 | if(AdWertNick < 15) MesswertNick = -600; |
|
- | 576 | if(AdWertNick < 7) MesswertNick = -800; |
|
- | 577 | if(AdWertRoll > 1010) MesswertRoll = +600; |
|
- | 578 | if(AdWertRoll > 1017) MesswertRoll = +800; |
|
- | 579 | if(AdWertRoll < 15) MesswertRoll = -600; |
|
- | 580 | if(AdWertRoll < 7) MesswertRoll = -800; |
|
- | 581 | } |
|
- | 582 | else |
|
- | 583 | { |
|
- | 584 | if(AdWertNick > 2000) MesswertNick = +1200; |
|
- | 585 | if(AdWertNick > 2015) MesswertNick = +1600; |
|
- | 586 | if(AdWertNick < 15) MesswertNick = -1200; |
|
- | 587 | if(AdWertNick < 7) MesswertNick = -1600; |
|
- | 588 | if(AdWertRoll > 2000) MesswertRoll = +1200; |
|
- | 589 | if(AdWertRoll > 2015) MesswertRoll = +1600; |
|
- | 590 | if(AdWertRoll < 15) MesswertRoll = -1200; |
|
- | 591 | if(AdWertRoll < 7) MesswertRoll = -1600; |
|
Line 496... | Line 592... | ||
496 | if(PlatinenVersion == 10) { if(AdWertRoll > 1010) MesswertRoll = +1000; if(AdWertRoll > 1017) MesswertRoll = +2000; } |
592 | } |
- | 593 | // MartinR : Neu Ende |
|
- | 594 | ||
497 | else { if(AdWertRoll > 2000) MesswertRoll = +1000; if(AdWertRoll > 2015) MesswertRoll = +2000; } |
595 | if(Parameter_Gyro_D) |
498 | 596 | // MartinR: hier sind Änderungen erforderlich, da u.a. MesswertNick = HiResNick / 8 von der fc.c in die analog.c verschoben wurde |
|
499 | if(Parameter_Gyro_D) |
597 | // Hintergrund: Code einsparen |
500 | { |
598 | { |
501 | d2Nick = HiResNick - oldNick; |
599 | d2Nick = HiResNick - oldNick; |
Line 502... | Line 600... | ||
502 | oldNick = (oldNick + HiResNick)/2; |
600 | oldNick = (oldNick + HiResNick)/2; |
503 | if(d2Nick > D_LIMIT) d2Nick = D_LIMIT; |
601 | if(d2Nick > D_LIMIT) d2Nick = D_LIMIT; |
504 | else if(d2Nick < -D_LIMIT) d2Nick = -D_LIMIT; |
602 | else if(d2Nick < -D_LIMIT) d2Nick = -D_LIMIT; |
505 | 603 | ||
506 | d2Roll = HiResRoll - oldRoll; |
604 | d2Roll = HiResRoll - oldRoll; |
507 | oldRoll = (oldRoll + HiResRoll)/2; |
605 | oldRoll = (oldRoll + HiResRoll)/2; |
- | 606 | if(d2Roll > D_LIMIT) d2Roll = D_LIMIT; |
|
508 | if(d2Roll > D_LIMIT) d2Roll = D_LIMIT; |
607 | else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT; |
- | 608 | ||
509 | else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT; |
609 | //MesswertNick += (d2Nick * (signed int) Parameter_Gyro_D) / 16; // MartinR : so war es |
510 | 610 | MesswertNick += (d2Nick * (signed int) Parameter_Gyro_D) / 2; // MartinR : geändert |
|
511 | MesswertNick += (d2Nick * (signed int) Parameter_Gyro_D) / 16; |
611 | //MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16; // MartinR : so war es |
Line 512... | Line 612... | ||
512 | MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16; |
612 | MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 2; // MartinR : geändert |
513 | HiResNick += (d2Nick * (signed int) Parameter_Gyro_D); |
613 | HiResNick += (d2Nick * (signed int) Parameter_Gyro_D * 8); // martinR: *8 hinzugefügt |
514 | HiResRoll += (d2Roll * (signed int) Parameter_Gyro_D); |
614 | HiResRoll += (d2Roll * (signed int) Parameter_Gyro_D * 8); // martinR: *8 hinzugefügt |
Line 630... | Line 730... | ||
630 | Parameter_ExtraConfig = EE_Parameter.ExtraConfig; |
730 | Parameter_ExtraConfig = EE_Parameter.ExtraConfig; |
631 | // CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255); |
731 | // CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255); |
632 | CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability); |
732 | CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability); |
633 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl); |
733 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl); |
634 | Ki = 10300 / (Parameter_I_Faktor + 1); |
734 | Ki = 10300 / (Parameter_I_Faktor + 1); |
- | 735 | //Ki = (10300 / (Parameter_I_Faktor + 4)) + (StickGas /2); // MartinR: Test Gasabhängige Regelung |
|
- | 736 | ||
- | 737 | if(Parameter_UserParam1 > 50) KiHH = 10300 / (Parameter_UserParam2 + 1); else KiHH = Ki; // MartinR : für HH über Schalter |
|
- | 738 | //if(Parameter_UserParam1 > 50) KiHH = (10300 / (Parameter_UserParam2 + 4)) + (StickGas /2); else KiHH = Ki; // MartinR : für HH über Schalter // MartinR: Test Gasabhängige Regelung |
|
- | 739 | Parameter_NaviGpsModeControl = EE_Parameter.NaviGpsModeControl; //MartinR: Standard: EE_Parameter.NaviGpsModeControl wird übertragen |
|
- | 740 | if(!IntegralFaktor) Parameter_NaviGpsModeControl= 0; // MartinR: wenn HH dann GPS auf free- Mode |
|
- | 741 | // 0 = free; 100 = AID; 200 = coming home //neu |
|
- | 742 | ||
- | 743 | ||
635 | MAX_GAS = EE_Parameter.Gas_Max; |
744 | MAX_GAS = EE_Parameter.Gas_Max; |
636 | MIN_GAS = EE_Parameter.Gas_Min; |
745 | MIN_GAS = EE_Parameter.Gas_Min; |
Line 637... | Line 746... | ||
637 | 746 | ||
638 | tmp = EE_Parameter.CareFreeModeControl; |
747 | tmp = EE_Parameter.CareFreeModeControl; |
Line 677... | Line 786... | ||
677 | void MotorRegler(void) |
786 | void MotorRegler(void) |
678 | //############################################################################ |
787 | //############################################################################ |
679 | { |
788 | { |
680 | int pd_ergebnis_nick,pd_ergebnis_roll,tmp_int, tmp_int2; |
789 | int pd_ergebnis_nick,pd_ergebnis_roll,tmp_int, tmp_int2; |
681 | int GierMischanteil,GasMischanteil; |
790 | int GierMischanteil,GasMischanteil; |
- | 791 | ||
- | 792 | static long SummeNickHH=0,SummeRollHH=0; // MartinR: hinzugefügt |
|
- | 793 | ||
682 | static long sollGier = 0,tmp_long,tmp_long2; |
794 | static long sollGier = 0,tmp_long,tmp_long2; |
683 | static long IntegralFehlerNick = 0; |
795 | static long IntegralFehlerNick = 0; |
684 | static long IntegralFehlerRoll = 0; |
796 | static long IntegralFehlerRoll = 0; |
685 | static unsigned int RcLostTimer; |
797 | static unsigned int RcLostTimer; |
686 | static unsigned char delay_neutral = 0; |
798 | static unsigned char delay_neutral = 0; |
Line 795... | Line 907... | ||
795 | SetNeutral(0); |
907 | SetNeutral(0); |
796 | CalibrationDone = 1; |
908 | CalibrationDone = 1; |
797 | ServoActive = 1; |
909 | ServoActive = 1; |
798 | DDRD |=0x80; // enable J7 -> Servo signal |
910 | DDRD |=0x80; // enable J7 -> Servo signal |
799 | Piep(GetActiveParamSet(),120); |
911 | Piep(GetActiveParamSet(),120); |
- | 912 | PPM_in[13] = Parameter_UserParam5 -127 ; // MartinR: Initialisierungswerte für die seriellen Potis für Jeti+ |
|
- | 913 | PPM_in[14] = Parameter_UserParam6 -127 ; // MartinR: Initialisierungswerte für die seriellen Potis für Jeti+ |
|
800 | } |
914 | } |
801 | } |
915 | } |
802 | } |
916 | } |
803 | else |
917 | else |
804 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern |
918 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern |
Line 840... | Line 954... | ||
840 | { |
954 | { |
841 | modell_fliegt = 1; |
955 | modell_fliegt = 1; |
842 | MotorenEin = 1; |
956 | MotorenEin = 1; |
843 | sollGier = 0; |
957 | sollGier = 0; |
844 | Mess_Integral_Gier = 0; |
958 | Mess_Integral_Gier = 0; |
845 | Mess_Integral_Gier2 = 0; |
959 | // Mess_Integral_Gier2 = 0; |
- | 960 | ||
846 | Mess_IntegralNick = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccNick; |
961 | Mess_IntegralNick = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccNick; |
847 | Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll; |
962 | Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll; |
848 | Mess_IntegralNick2 = IntegralNick; |
963 | Mess_IntegralNick2 = IntegralNick; |
849 | Mess_IntegralRoll2 = IntegralRoll; |
964 | Mess_IntegralRoll2 = IntegralRoll; |
850 | SummeNick = 0; |
965 | SummeNick = 0; |
Line 852... | Line 967... | ||
852 | // ControlHeading = (((int) EE_Parameter.OrientationAngle * 15 + KompassValue) % 360) / 2; |
967 | // ControlHeading = (((int) EE_Parameter.OrientationAngle * 15 + KompassValue) % 360) / 2; |
853 | NeueKompassRichtungMerken = 100; // 2 sekunden |
968 | NeueKompassRichtungMerken = 100; // 2 sekunden |
854 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
969 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
855 | SpeakHoTT = SPEAK_STARTING; |
970 | SpeakHoTT = SPEAK_STARTING; |
856 | #endif |
971 | #endif |
- | 972 | // MartinR: hinzugefügt Anfang |
|
- | 973 | stick_nick_neutral = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; // aktueller Stickwert wird als Neutralposition im HH verwendet, MartinR |
|
- | 974 | stick_roll_neutral = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; // aktueller Stickwert wird als Neutralposition im HH verwendet, MartinR |
|
- | 975 | SummeNickHH = 0 ; // Zurücksetzen der Integratoren |
|
- | 976 | SummeRollHH = 0 ; // Zurücksetzen der Integratoren |
|
- | 977 | // MartinR: hinzugefügt Ende |
|
857 | } |
978 | } |
858 | else |
979 | else |
859 | { |
980 | { |
860 | beeptime = 1500; // indicate missing calibration |
981 | beeptime = 1500; // indicate missing calibration |
861 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
982 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
Line 899... | Line 1020... | ||
899 | { |
1020 | { |
900 | static int stick_nick,stick_roll; |
1021 | static int stick_nick,stick_roll; |
901 | unsigned char stick_p; |
1022 | unsigned char stick_p; |
902 | ParameterZuordnung(); |
1023 | ParameterZuordnung(); |
903 | stick_p = EE_Parameter.Stick_P; |
1024 | stick_p = EE_Parameter.Stick_P; |
- | 1025 | // MartinR: original: |
|
- | 1026 | /* |
|
904 | stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * stick_p) / 4; |
1027 | stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * stick_p) / 4; |
905 | stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D; |
1028 | stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D; |
906 | stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * stick_p) / 4; |
1029 | stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * stick_p) / 4; |
907 | stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
1030 | stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
- | 1031 | */ |
|
- | 1032 | // MartinR: geändert Anfang |
|
- | 1033 | ||
- | 1034 | if(IntegralFaktor) // ACC-Mode |
|
- | 1035 | { |
|
- | 1036 | stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * stick_p) / 4; |
|
- | 1037 | stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * stick_p) / 4; |
|
- | 1038 | stick_nick_neutral = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; // beim Umschalten auf HH wird derletzte Stickwert als Neutralposition verwendet, MartinR |
|
- | 1039 | stick_roll_neutral = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; // beim Umschalten auf HH wird derletzte Stickwert als Neutralposition verwendet, MartinR |
|
- | 1040 | stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D; |
|
- | 1041 | stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
|
- | 1042 | ||
- | 1043 | } |
|
- | 1044 | else // HH-Mode |
|
- | 1045 | { |
|
- | 1046 | if(Parameter_UserParam1 > 49) // MartinR: zweiter Stick_P Wert nur, wenn HH über Schalter aktiv ist |
|
- | 1047 | { |
|
- | 1048 | stick_nick = ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] - stick_nick_neutral) * Parameter_UserParam3); |
|
- | 1049 | stick_roll = ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] - stick_roll_neutral) * Parameter_UserParam3); |
|
- | 1050 | } |
|
- | 1051 | ||
- | 1052 | else |
|
- | 1053 | { |
|
- | 1054 | stick_nick = ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] - stick_nick_neutral) * stick_p); |
|
- | 1055 | stick_roll = ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] - stick_roll_neutral) * stick_p); |
|
- | 1056 | } |
|
- | 1057 | } |
|
- | 1058 | // MartinR: geändert Ende |
|
Line 908... | Line 1059... | ||
908 | 1059 | ||
909 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1060 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
910 | // CareFree und freie Wahl der vorderen Richtung |
1061 | // CareFree und freie Wahl der vorderen Richtung |
911 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1062 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 1063 | //if(CareFree) // MartinR: so war es |
|
912 | if(CareFree) |
1064 | if(CareFree && IntegralFaktor) // MartinR: CareFree nur im ACC-Mode |
913 | { |
1065 | { |
914 | signed int nick, roll; |
1066 | signed int nick, roll; |
915 | nick = stick_nick / 4; |
1067 | nick = stick_nick / 4; |
916 | roll = stick_roll / 4; |
1068 | roll = stick_roll / 4; |
917 | StickNick = ((FromNC_Rotate_C * nick) + (FromNC_Rotate_S * roll)) / (32 / 4); |
1069 | StickNick = ((FromNC_Rotate_C * nick) + (FromNC_Rotate_S * roll)) / (32 / 4); |
918 | StickRoll = ((FromNC_Rotate_C * roll) - (FromNC_Rotate_S * nick)) / (32 / 4); |
1070 | StickRoll = ((FromNC_Rotate_C * roll) - (FromNC_Rotate_S * nick)) / (32 / 4); |
919 | } |
1071 | } |
920 | else |
1072 | else |
921 | { |
1073 | { |
- | 1074 | //FromNC_Rotate_C = sintab[EE_Parameter.OrientationAngle + 6]; //MartinR: so war es |
|
922 | FromNC_Rotate_C = sintab[EE_Parameter.OrientationAngle + 6]; |
1075 | FromNC_Rotate_C = (sintab[EE_Parameter.OrientationAngle * 2 + 12]) / 2; //MartinR: feinere Auflösung |
- | 1076 | //FromNC_Rotate_S = sintab[EE_Parameter.OrientationAngle]; //MartinR: so war es |
|
923 | FromNC_Rotate_S = sintab[EE_Parameter.OrientationAngle]; |
1077 | FromNC_Rotate_S = (sintab[EE_Parameter.OrientationAngle * 2]) / 2; //MartinR: feinere Auflösung |
924 | StickNick = ((FromNC_Rotate_C * stick_nick) + (FromNC_Rotate_S * stick_roll)) / 8; |
1078 | StickNick = ((FromNC_Rotate_C * stick_nick) + (FromNC_Rotate_S * stick_roll)) / 8; |
925 | StickRoll = ((FromNC_Rotate_C * stick_roll) - (FromNC_Rotate_S * stick_nick)) / 8; |
1079 | StickRoll = ((FromNC_Rotate_C * stick_roll) - (FromNC_Rotate_S * stick_nick)) / 8; |
Line 926... | Line 1080... | ||
926 | } |
1080 | } |
Line 938... | Line 1092... | ||
938 | StickNick -= GPS_Nick; |
1092 | StickNick -= GPS_Nick; |
939 | StickRoll -= GPS_Roll; |
1093 | StickRoll -= GPS_Roll; |
940 | StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 127; |
1094 | StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 127; |
Line 941... | Line 1095... | ||
941 | 1095 | ||
942 | GyroFaktor = (Parameter_Gyro_P + 10.0); |
1096 | GyroFaktor = (Parameter_Gyro_P + 10.0); |
943 | IntegralFaktor = Parameter_Gyro_I; |
1097 | // IntegralFaktor = Parameter_Gyro_I; // MartinR: war mal hier |
944 | GyroFaktorGier = (Parameter_Gyro_Gier_P + 10.0); |
1098 | GyroFaktorGier = (Parameter_Gyro_Gier_P + 10.0); |
Line 945... | Line 1099... | ||
945 | IntegralFaktorGier = Parameter_Gyro_Gier_I; |
1099 | IntegralFaktorGier = Parameter_Gyro_Gier_I; |
946 | 1100 | ||
947 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1101 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 1102 | //+ Analoge Steuerung per Seriell |
|
- | 1103 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1104 | #ifdef WITH_ExternControl /// MartinW memorysaving |
|
948 | //+ Analoge Steuerung per Seriell |
1105 | #warning : "### with ExternControl ###" |
949 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1106 | |
950 | if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128) |
1107 | if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128) |
951 | { |
1108 | { |
952 | StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P; |
1109 | StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P; |
Line 970... | Line 1127... | ||
970 | MaxStickRoll = abs(StickRoll)/STICK_GAIN; |
1127 | MaxStickRoll = abs(StickRoll)/STICK_GAIN; |
971 | if(MaxStickRoll > 100) MaxStickRoll = 100; |
1128 | if(MaxStickRoll > 100) MaxStickRoll = 100; |
972 | } |
1129 | } |
973 | else MaxStickRoll--; |
1130 | else MaxStickRoll--; |
974 | if(FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING) {MaxStickNick = 0; MaxStickRoll = 0;} |
1131 | if(FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING) {MaxStickNick = 0; MaxStickRoll = 0;} |
- | 1132 | ||
- | 1133 | #else |
|
- | 1134 | #warning : "### without ExternControl ###" |
|
- | 1135 | #endif |
|
Line 975... | Line 1136... | ||
975 | 1136 | ||
976 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1137 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
977 | // Looping? |
1138 | // Looping? |
- | 1139 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1140 | #ifdef WITH_ACC_Loop // MartinR: deaktivieren um Code zu sparen |
|
978 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1141 | |
979 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS) Looping_Links = 1; |
1142 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS) Looping_Links = 1; |
980 | else |
1143 | else |
981 | { |
1144 | { |
982 | { |
1145 | { |
Line 1009... | Line 1172... | ||
1009 | } |
1172 | } |
1010 | } |
1173 | } |
Line 1011... | Line 1174... | ||
1011 | 1174 | ||
1012 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
1175 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
- | 1176 | if(Looping_Oben || Looping_Unten) { Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
|
1013 | if(Looping_Oben || Looping_Unten) { Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
1177 | #endif |
1014 | } // Ende neue Funken-Werte |
- | |
- | 1178 | } // Ende neue Funken-Werte |
|
1015 | 1179 | #ifdef WITH_ACC_Loop // MartinR: deaktiviert um Code zu sparen |
|
1016 | if(Looping_Roll || Looping_Nick) |
1180 | if(Looping_Roll || Looping_Nick) |
1017 | { |
1181 | { |
1018 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
1182 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
1019 | TrichterFlug = 1; |
1183 | TrichterFlug = 1; |
- | 1184 | } |
|
- | 1185 | #else |
|
1020 | } |
1186 | #warning : "### without ACC-Loop ###" |
Line 1021... | Line 1187... | ||
1021 | 1187 | #endif |
|
1022 | 1188 | ||
1023 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1189 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1024 | // Bei Empfangsausfall im Flug |
1190 | // Bei Empfangsausfall im Flug |
Line 1056... | Line 1222... | ||
1056 | MittelIntegralNick += IntegralNick; // Für die Mittelwertbildung aufsummieren |
1222 | MittelIntegralNick += IntegralNick; // Für die Mittelwertbildung aufsummieren |
1057 | MittelIntegralRoll += IntegralRoll; |
1223 | MittelIntegralRoll += IntegralRoll; |
1058 | MittelIntegralNick2 += IntegralNick2; |
1224 | MittelIntegralNick2 += IntegralNick2; |
1059 | MittelIntegralRoll2 += IntegralRoll2; |
1225 | MittelIntegralRoll2 += IntegralRoll2; |
Line -... | Line 1226... | ||
- | 1226 | ||
- | 1227 | if((!IntegralFaktor && (Parameter_UserParam1 < 50) && !(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD))) // MartinR: |
|
- | 1228 | // nur im Moment des Umschaltens von HH auf ACC erfolgt ein Reset der Integrale, nicht aber bei normalem HH |
|
- | 1229 | // um einen im HH-Mode eventuell schwindelig geflogenen ACC_Mode zu resetten! |
|
- | 1230 | // bis zur Umschaltung werden die Integrale für den Kameraausgleich verwendet |
|
- | 1231 | { |
|
- | 1232 | IntegralNick = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1233 | IntegralRoll = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1234 | Mess_IntegralNick = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1235 | Mess_IntegralRoll = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1236 | Mess_Integral_Gier = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1237 | sollGier = 0; |
|
- | 1238 | Integral_Gier = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1239 | //Mess_Integral_Gier2 = 0; // MartinR: Reset der Integratoren beim Zurückschalten vom HH- in den ACC-Mode |
|
- | 1240 | KompassSollWert = KompassValue; // MartinR: aktuelle Ausrichtung beibehalten |
|
- | 1241 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; // MartinR: aktuelle Ausrichtung beibehalten |
|
- | 1242 | NeueKompassRichtungMerken = 1; // MartinR: aktuelle Ausrichtung beibehalten |
|
- | 1243 | } |
|
1060 | 1244 | ||
- | 1245 | // if(Looping_Nick || Looping_Roll) // MartinR: so war es |
|
- | 1246 | if(Looping_Nick || Looping_Roll || (!IntegralFaktor && (Parameter_UserParam1 < 50) && !(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD))) // MartinR: erweitert |
|
1061 | if(Looping_Nick || Looping_Roll) |
1247 | // MartinR: beim ACC-Loop oder beim zurückschalten von HH auf ACC |
1062 | { |
1248 | { |
1063 | IntegralAccNick = 0; |
1249 | IntegralAccNick = 0; |
1064 | IntegralAccRoll = 0; |
1250 | IntegralAccRoll = 0; |
1065 | MittelIntegralNick = 0; |
1251 | MittelIntegralNick = 0; |
Line 1070... | Line 1256... | ||
1070 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
1256 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
1071 | ZaehlMessungen = 0; |
1257 | ZaehlMessungen = 0; |
1072 | LageKorrekturNick = 0; |
1258 | LageKorrekturNick = 0; |
1073 | LageKorrekturRoll = 0; |
1259 | LageKorrekturRoll = 0; |
1074 | } |
1260 | } |
- | 1261 | ||
- | 1262 | if((EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) || (Parameter_UserParam1 > 49)) IntegralFaktor = 0; // MartinR geändert und verschoben |
|
- | 1263 | else IntegralFaktor = Parameter_Gyro_I; // MartinR: geändert |
|
Line 1075... | Line 1264... | ||
1075 | 1264 | ||
1076 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1265 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1077 | if(!Looping_Nick && !Looping_Roll && (Aktuell_az > 512 || MotorenEin)) |
1266 | if(!Looping_Nick && !Looping_Roll && (Aktuell_az > 512 || MotorenEin)) |
1078 | { |
1267 | { |
Line 1129... | Line 1318... | ||
1129 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
1318 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
1130 | { |
1319 | { |
1131 | static int cnt = 0; |
1320 | static int cnt = 0; |
1132 | static char last_n_p,last_n_n,last_r_p,last_r_n; |
1321 | static char last_n_p,last_n_n,last_r_p,last_r_n; |
1133 | static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt; |
1322 | static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt; |
1134 | if(!Looping_Nick && !Looping_Roll && !TrichterFlug && EE_Parameter.Driftkomp) |
1323 | //if(!Looping_Nick && !Looping_Roll && !TrichterFlug && EE_Parameter.Driftkomp) // MartinR: so war es |
- | 1324 | if(!Looping_Nick && !Looping_Roll && !TrichterFlug && EE_Parameter.Driftkomp && IntegralFaktor) // MartinR: "&& IntegralFaktor" hinzugefügt |
|
- | 1325 | ||
1135 | { |
1326 | { |
1136 | MittelIntegralNick /= ABGLEICH_ANZAHL; |
1327 | MittelIntegralNick /= ABGLEICH_ANZAHL; |
1137 | MittelIntegralRoll /= ABGLEICH_ANZAHL; |
1328 | MittelIntegralRoll /= ABGLEICH_ANZAHL; |
1138 | IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL; |
1329 | IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL; |
1139 | IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL; |
1330 | IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL; |
Line 1289... | Line 1480... | ||
1289 | } |
1480 | } |
1290 | tmp_int = (long) EE_Parameter.StickGier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
1481 | tmp_int = (long) EE_Parameter.StickGier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
1291 | tmp_int += (EE_Parameter.StickGier_P * StickGier) / 4; |
1482 | tmp_int += (EE_Parameter.StickGier_P * StickGier) / 4; |
1292 | tmp_int += CompassGierSetpoint; |
1483 | tmp_int += CompassGierSetpoint; |
1293 | sollGier = tmp_int; |
1484 | sollGier = tmp_int; |
1294 | Mess_Integral_Gier -= tmp_int; |
1485 | //Mess_Integral_Gier -= tmp_int; // MartinR: so war es |
- | 1486 | Mess_Integral_Gier -= (tmp_int * 10) / 8; // MartinR: Test um Zurückschwingen bei hohen I-Faktoren zu verringern |
|
1295 | if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen |
1487 | //if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen // MartinR: so war es |
1296 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
1488 | //if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; // MartinR: so war es |
- | 1489 | if(Mess_Integral_Gier > 90000) Mess_Integral_Gier = 90000; // begrenzen // MartinR: Begrenzung verändert |
|
- | 1490 | if(Mess_Integral_Gier <-90000) Mess_Integral_Gier =-90000; // MartinR: Begrenzung verändert |
|
Line 1297... | Line 1491... | ||
1297 | 1491 | ||
1298 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1492 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1299 | // Kompass |
1493 | // Kompass |
1300 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1494 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 1495 | //if(KompassValue >= 0 && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) // MartinR: so war es |
|
1301 | if(KompassValue >= 0 && (Parameter_GlobalConfig & CFG_KOMPASS_AKTIV)) |
1496 | if((KompassValue >= 0 && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) && !(Parameter_UserParam1 > 50)) // MartinR: bei HH über Schalter wird der Kompass abgeschaltet |
1302 | { |
1497 | { |
1303 | if(CalculateCompassTimer-- == 1) |
1498 | if(CalculateCompassTimer-- == 1) |
1304 | { |
1499 | { |
1305 | int w,v,r,fehler,korrektur; // wird von der SPI-Routine auf 1 gesetzt |
1500 | int w,v,r,fehler,korrektur; // wird von der SPI-Routine auf 1 gesetzt |
Line 1353... | Line 1548... | ||
1353 | 1548 | ||
1354 | #define TRIM_MAX 200 |
1549 | #define TRIM_MAX 200 |
1355 | if(TrimNick > TRIM_MAX) TrimNick = TRIM_MAX; else if(TrimNick <-TRIM_MAX) TrimNick =-TRIM_MAX; |
1550 | if(TrimNick > TRIM_MAX) TrimNick = TRIM_MAX; else if(TrimNick <-TRIM_MAX) TrimNick =-TRIM_MAX; |
Line -... | Line 1551... | ||
- | 1551 | if(TrimRoll > TRIM_MAX) TrimRoll = TRIM_MAX; else if(TrimRoll <-TRIM_MAX) TrimRoll =-TRIM_MAX; |
|
- | 1552 | ||
- | 1553 | //MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN);// MartinR so war es |
|
- | 1554 | //MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN);// MartinR so war es |
|
- | 1555 | ||
- | 1556 | if(!IntegralFaktor) // MartinR : HH-Mode hinzugefügt |
|
- | 1557 | { |
|
- | 1558 | MesswertNick = (long) ((long)MesswertNick * GyroFaktor) / (256L / STICK_GAIN) ; // MartinR : hinzugefügt |
|
- | 1559 | MesswertRoll = (long) ((long)MesswertRoll * GyroFaktor) / (256L / STICK_GAIN) ; // MartinR : hinzugefügt |
|
- | 1560 | //MesswertGier = (long)(MesswertGier * 2 * (long)GyroFaktorGier) / (256L / STICK_GAIN); |
|
- | 1561 | //Mess_Integral_Gier = 0; // MartinR: nur Kompass wird bei HH deaktiviert |
|
- | 1562 | //Integral_Gier = 0; // MartinR: nur Kompass wird bei HH deaktiviert |
|
- | 1563 | } |
|
1356 | if(TrimRoll > TRIM_MAX) TrimRoll = TRIM_MAX; else if(TrimRoll <-TRIM_MAX) TrimRoll =-TRIM_MAX; |
1564 | else // MartinR: ACC-Mode so war es |
1357 | 1565 | { |
|
- | 1566 | MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN); |
|
- | 1567 | MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN); |
|
1358 | MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN); |
1568 | } |
Line 1359... | Line 1569... | ||
1359 | MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN); |
1569 | |
1360 | MesswertGier = (long)(MesswertGier * 2 * (long)GyroFaktorGier) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktorGier) / (2 * (44000 / STICK_GAIN)); |
1570 | MesswertGier = (long)(MesswertGier * 2 * (long)GyroFaktorGier) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktorGier) / (2 * (44000 / STICK_GAIN)); |
1361 | 1571 | ||
Line 1444... | Line 1654... | ||
1444 | } |
1654 | } |
Line 1445... | Line 1655... | ||
1445 | 1655 | ||
1446 | // if height control is activated by an rc channel |
1656 | // if height control is activated by an rc channel |
1447 | if(Parameter_GlobalConfig & CFG_HOEHEN_SCHALTER) // Regler wird über Schalter gesteuert |
1657 | if(Parameter_GlobalConfig & CFG_HOEHEN_SCHALTER) // Regler wird über Schalter gesteuert |
1448 | { // check if parameter is less than activation threshold |
1658 | { // check if parameter is less than activation threshold |
- | 1659 | // if(Parameter_HoehenSchalter < 50) // for 3 or 2-state switch height control is disabled in lowest position // MartinR :so war es |
|
1449 | if(Parameter_HoehenSchalter < 50) // for 3 or 2-state switch height control is disabled in lowest position |
1660 | if((Parameter_HoehenSchalter < 50) || (Parameter_UserParam1 > 140) ) // MartinR: Schalter aus oder HH ohne Höhenregler über UsererParam1 an |
1450 | { //height control not active |
1661 | { //height control not active |
1451 | if(!delay--) |
1662 | if(!delay--) |
1452 | { |
1663 | { |
1453 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
1664 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
Line 1469... | Line 1680... | ||
1469 | } |
1680 | } |
1470 | } |
1681 | } |
1471 | else // no switchable height control |
1682 | else // no switchable height control |
1472 | { |
1683 | { |
1473 | SollHoehe = ((int16_t) ExternHoehenValue + (int16_t) Parameter_HoehenSchalter) * (int)EE_Parameter.Hoehe_Verstaerkung; |
1684 | SollHoehe = ((int16_t) ExternHoehenValue + (int16_t) Parameter_HoehenSchalter) * (int)EE_Parameter.Hoehe_Verstaerkung; |
- | 1685 | // HoehenReglerAktiv = 1; // MartinR : so war es |
|
- | 1686 | // MartinR : geändert Anfang |
|
- | 1687 | if(Parameter_UserParam1 > 140) // HH über Schalter: HH an + Höhenregler abgeschaltet, Nachführen von Parametern |
|
- | 1688 | { |
|
- | 1689 | HoehenReglerAktiv = 0; |
|
- | 1690 | } |
|
- | 1691 | else // Höhenregler mit Sollhöhe über Poti aktiv |
|
- | 1692 | { |
|
1474 | HoehenReglerAktiv = 1; |
1693 | HoehenReglerAktiv = 1; |
- | 1694 | } |
|
- | 1695 | // MartinR : geändert Ende |
|
1475 | } |
1696 | } |
Line 1476... | Line 1697... | ||
1476 | 1697 | ||
1477 | // calculate cos of nick and roll angle used for projection of the vertical hoover gas |
1698 | // calculate cos of nick and roll angle used for projection of the vertical hoover gas |
1478 | tmp_int = (int)(IntegralNick/GIER_GRAD_FAKTOR); // nick angle in deg |
1699 | tmp_int = (int)(IntegralNick/GIER_GRAD_FAKTOR); // nick angle in deg |
Line 1503... | Line 1724... | ||
1503 | { |
1724 | { |
1504 | // alternative height control |
1725 | // alternative height control |
1505 | // PD-Control with respect to hoover point |
1726 | // PD-Control with respect to hoover point |
1506 | // the thrust loss out of horizontal attitude is compensated |
1727 | // the thrust loss out of horizontal attitude is compensated |
1507 | // the setpoint will be fine adjusted with the gas stick position |
1728 | // the setpoint will be fine adjusted with the gas stick position |
- | 1729 | HeightDeviation = HoehenWert - SollHoehe; //MartinR: Test |
|
1508 | if(FC_StatusFlags & FC_STATUS_FLY) // trim setpoint only when flying |
1730 | if(FC_StatusFlags & FC_STATUS_FLY) // trim setpoint only when flying |
1509 | { // gas stick is above hoover point |
1731 | { // gas stick is above hoover point |
1510 | if(StickGas > (StickGasHover + HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtUpperLimit) |
1732 | if(StickGas > (StickGasHover + HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtUpperLimit) |
1511 | { |
1733 | { |
1512 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_DOWN) |
1734 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_DOWN) |
1513 | { |
1735 | { |
1514 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_DOWN; |
1736 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_DOWN; |
1515 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1737 | //SollHoehe = HoehenWert; // update setpoint to current heigth // MartinR: so war es |
- | 1738 | SollHoehe = HoehenWert - HeightDeviation / 2; // MartinR: um den Sollwertsprung zu verringern |
|
1516 | } |
1739 | } |
1517 | FC_StatusFlags |= FC_STATUS_VARIO_TRIM_UP; |
1740 | FC_StatusFlags |= FC_STATUS_VARIO_TRIM_UP; |
1518 | // Limit the maximum Altitude |
1741 | // Limit the maximum Altitude |
1519 | if(Parameter_MaximumAltitude && (SollHoehe/100 > Parameter_MaximumAltitude)) AltitudeSetpointTrimming = 0; |
1742 | if(Parameter_MaximumAltitude && (SollHoehe/100 > Parameter_MaximumAltitude)) AltitudeSetpointTrimming = 0; |
1520 | else |
1743 | else |
Line 1529... | Line 1752... | ||
1529 | else if(StickGas < (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtLowerLimit ) |
1752 | else if(StickGas < (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtLowerLimit ) |
1530 | { |
1753 | { |
1531 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_UP) |
1754 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_UP) |
1532 | { |
1755 | { |
1533 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_UP; |
1756 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_UP; |
1534 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1757 | //SollHoehe = HoehenWert; // update setpoint to current heigth // MartinR: so war es |
- | 1758 | SollHoehe = HoehenWert - HeightDeviation / 2; // MartinR: um den Sollwertsprung zu verringern |
|
1535 | } |
1759 | } |
1536 | FC_StatusFlags |= FC_STATUS_VARIO_TRIM_DOWN; |
1760 | FC_StatusFlags |= FC_STATUS_VARIO_TRIM_DOWN; |
1537 | AltitudeSetpointTrimming = -abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
1761 | AltitudeSetpointTrimming = -abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
1538 | // HeightTrimming -= abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
1762 | // HeightTrimming -= abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
1539 | VarioCharacter = '-'; |
1763 | VarioCharacter = '-'; |
Line 1550... | Line 1774... | ||
1550 | WaypointTrimming = 10; |
1774 | WaypointTrimming = 10; |
1551 | VarioCharacter = '^'; |
1775 | VarioCharacter = '^'; |
1552 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_DOWN) // changed from sinking to rising |
1776 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_DOWN) // changed from sinking to rising |
1553 | { |
1777 | { |
1554 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_DOWN; |
1778 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_DOWN; |
1555 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1779 | //SollHoehe = HoehenWert; // update setpoint to current heigth // MartinR: so war es |
- | 1780 | SollHoehe = HoehenWert - HeightDeviation / 2; // MartinR: um den Sollwertsprung zu verringern |
|
1556 | } |
1781 | } |
1557 | } |
1782 | } |
1558 | else |
1783 | else |
1559 | if(FromNC_AltitudeSpeed && FromNC_AltitudeSetpoint < SollHoehe) // von NC gesteuert -> sinken |
1784 | if(FromNC_AltitudeSpeed && FromNC_AltitudeSetpoint < SollHoehe) // von NC gesteuert -> sinken |
1560 | { |
1785 | { |
Line 1564... | Line 1789... | ||
1564 | WaypointTrimming = -10; |
1789 | WaypointTrimming = -10; |
1565 | VarioCharacter = 'v'; |
1790 | VarioCharacter = 'v'; |
1566 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_UP) // changed from rising to sinking |
1791 | if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_UP) // changed from rising to sinking |
1567 | { |
1792 | { |
1568 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_UP; |
1793 | FC_StatusFlags &= ~FC_STATUS_VARIO_TRIM_UP; |
1569 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1794 | //SollHoehe = HoehenWert; // update setpoint to current heigth // MartinR: so war es |
- | 1795 | SollHoehe = HoehenWert - HeightDeviation / 2; // MartinR: um den Sollwertsprung zu verringern |
|
1570 | } |
1796 | } |
1571 | } |
1797 | } |
1572 | else |
1798 | else |
1573 | if(FC_StatusFlags & (FC_STATUS_VARIO_TRIM_UP|FC_STATUS_VARIO_TRIM_DOWN)) |
1799 | if(FC_StatusFlags & (FC_STATUS_VARIO_TRIM_UP|FC_STATUS_VARIO_TRIM_DOWN)) |
1574 | { |
1800 | { |
Line 1633... | Line 1859... | ||
1633 | { |
1859 | { |
1634 | // ------------------------- P-Part ---------------------------- |
1860 | // ------------------------- P-Part ---------------------------- |
1635 | tmp_long = (HoehenWert - SollHoehe); // positive when too high |
1861 | tmp_long = (HoehenWert - SollHoehe); // positive when too high |
1636 | LIMIT_MIN_MAX(tmp_long, -32767L, 32767L); // avoid overflov when casting to int16_t |
1862 | LIMIT_MIN_MAX(tmp_long, -32767L, 32767L); // avoid overflov when casting to int16_t |
1637 | HeightDeviation = (int)(tmp_long); // positive when too high |
1863 | HeightDeviation = (int)(tmp_long); // positive when too high |
- | 1864 | //tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 32L; // p-part // MartinR: so war es |
|
- | 1865 | // MartinR: geändert Anfang |
|
- | 1866 | if ((SollHoehe > (HoehenWert+64)) || (SollHoehe < (HoehenWert-64))) |
|
- | 1867 | { |
|
- | 1868 | //tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 24L; // p-part // MartinR P-Part erhoehen |
|
- | 1869 | tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 70L; // p-part // MartinR Anpassung an Standardwert |
|
- | 1870 | } |
|
- | 1871 | else |
|
- | 1872 | { |
|
1638 | tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 32L; // p-part |
1873 | //tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 32L; // p-part |
- | 1874 | tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 90L; // MartinR Anpassung an Standardwert |
|
- | 1875 | } |
|
- | 1876 | // MartinR: geändert Ende |
|
1639 | LIMIT_MIN_MAX(tmp_long, -127 * STICK_GAIN, 256 * STICK_GAIN); // more than the full range makes no sense |
1877 | //LIMIT_MIN_MAX(tmp_long, -127 * STICK_GAIN, 256 * STICK_GAIN); // more than the full range makes no sense // MartinR: so war es |
- | 1878 | // MartinR: weshalb unsymmetrisch? |
|
- | 1879 | LIMIT_MIN_MAX(tmp_long, -128 * STICK_GAIN, 128 * STICK_GAIN); // more than the full range makes no sense // MartinR: geändert |
|
1640 | GasReduction = tmp_long; |
1880 | GasReduction = tmp_long; |
1641 | // ------------------------- D-Part 1: Vario Meter ---------------------------- |
1881 | // ------------------------- D-Part 1: Vario Meter ---------------------------- |
1642 | tmp_int = VarioMeter / 8; |
1882 | //tmp_int = VarioMeter / 8; // MartinR: so war es |
- | 1883 | // MartinR: geändert Anfang |
|
- | 1884 | tmp_int = VarioMeter / 4; // MartinR: geändert // Variometer: steigen ist positiv |
|
- | 1885 | { |
|
- | 1886 | if ((SollHoehe > (HoehenWert+512)) || (SollHoehe < (HoehenWert-512))) |
|
- | 1887 | //if ((StickGas > (StickGasHover + 3*HEIGHT_CONTROL_STICKTHRESHOLD)) || (StickGas < (StickGasHover - 3*HEIGHT_CONTROL_STICKTHRESHOLD))) |
|
- | 1888 | { |
|
- | 1889 | tmp_int = tmp_int + HeightDeviation / 28; |
|
- | 1890 | //tmp_int = tmp_int + Parameter_Hoehe_ACC_Wirkung* HeightDeviation / 64; // reduce d-part while trimming setpoint // MartinR: geändert |
|
- | 1891 | } |
|
- | 1892 | else |
|
- | 1893 | { |
|
- | 1894 | tmp_int = tmp_int + HeightDeviation / 32; |
|
- | 1895 | //tmp_int = tmp_int + Parameter_Hoehe_ACC_Wirkung* HeightDeviation / 64; |
|
- | 1896 | } |
|
- | 1897 | } |
|
- | 1898 | // MartinR: geändert Ende |
|
- | 1899 | ||
1643 | LIMIT_MIN_MAX(tmp_int, -127, 128); |
1900 | LIMIT_MIN_MAX(tmp_int, -127, 128); |
1644 | tmp_int = (tmp_int * (long)Parameter_Luftdruck_D) / 4L; // scale to d-gain parameter |
1901 | tmp_int = (tmp_int * (long)Parameter_Luftdruck_D) / 4L; // scale to d-gain parameter |
1645 | LIMIT_MIN_MAX(tmp_int,-64 * STICK_GAIN, 64 * STICK_GAIN); |
1902 | LIMIT_MIN_MAX(tmp_int,-64 * STICK_GAIN, 64 * STICK_GAIN); |
- | 1903 | /* // MartinR: so war es Anfang |
|
1646 | if(FC_StatusFlags & (FC_STATUS_VARIO_TRIM_UP|FC_STATUS_VARIO_TRIM_DOWN)) tmp_int /= 4; // reduce d-part while trimming setpoint |
1904 | if(FC_StatusFlags & (FC_STATUS_VARIO_TRIM_UP|FC_STATUS_VARIO_TRIM_DOWN)) tmp_int /= 4; // reduce d-part while trimming setpoint |
1647 | else |
1905 | else |
1648 | if(Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT) tmp_int /= 8; // reduce d-part in "Deckel" mode |
1906 | if(EE_Parameter.ExtraConfig & CFG2_HEIGHT_LIMIT) tmp_int /= 8; // reduce d-part in "Deckel" mode |
- | 1907 | */ // MartinR: so war es Ende |
|
- | 1908 | tmp_int /= 4; // MartinR: geändert: keine veränderung des d-part im "Deckel" mode |
|
- | 1909 | //if(FC_StatusFlags & (FC_STATUS_VARIO_TRIM_UP|FC_STATUS_VARIO_TRIM_DOWN)) tmp_int /= 4; // reduce d-part while trimming setpoint // MartinR: geändert |
|
- | 1910 | ||
1649 | GasReduction += tmp_int; |
1911 | GasReduction += tmp_int; |
1650 | } // EOF no baro range expanding |
1912 | } // EOF no baro range expanding |
1651 | // ------------------------ D-Part 2: ACC-Z Integral ------------------------ |
1913 | // ------------------------ D-Part 2: ACC-Z Integral ------------------------ |
- | 1914 | /* // MartinR: deaktiviert Anfang, da statische Ablage bei Schräglage Probleme macht |
|
1652 | if(Parameter_Hoehe_ACC_Wirkung) |
1915 | if(Parameter_Hoehe_ACC_Wirkung) |
1653 | { |
1916 | { |
1654 | tmp_long = ((Mess_Integral_Hoch / 128L) * (int32_t) Parameter_Hoehe_ACC_Wirkung) / (128L / STICK_GAIN); |
1917 | tmp_long = ((Mess_Integral_Hoch / 128L) * (int32_t) Parameter_Hoehe_ACC_Wirkung) / (128L / STICK_GAIN); |
1655 | LIMIT_MIN_MAX(tmp_long, -32 * STICK_GAIN, 64 * STICK_GAIN); |
1918 | LIMIT_MIN_MAX(tmp_long, -32 * STICK_GAIN, 64 * STICK_GAIN); |
1656 | GasReduction += tmp_long; |
1919 | GasReduction += tmp_long; |
1657 | } |
1920 | } |
- | 1921 | */ // MartinR: deaktiviert Ende |
|
1658 | // ------------------------ D-Part 3: GpsZ ---------------------------------- |
1922 | // ------------------------ D-Part 3: GpsZ ---------------------------------- |
1659 | tmp_int = (Parameter_Hoehe_GPS_Z * (int)FromNaviCtrl_Value.GpsZ)/128L; |
1923 | tmp_int = (Parameter_Hoehe_GPS_Z * (int)FromNaviCtrl_Value.GpsZ)/128L; |
1660 | LIMIT_MIN_MAX(tmp_int, -32 * STICK_GAIN, 64 * STICK_GAIN); |
1924 | //LIMIT_MIN_MAX(tmp_int, -32 * STICK_GAIN, 64 * STICK_GAIN); // MartinR: so war es |
- | 1925 | // MartinR: weshalb unsymmetrisch? |
|
- | 1926 | LIMIT_MIN_MAX(tmp_int, -32 * STICK_GAIN, 32 * STICK_GAIN); // MartinR: geändert |
|
1661 | GasReduction += tmp_int; |
1927 | GasReduction += tmp_int; |
1662 | GasReduction = (long)((long)GasReduction * HoverGas) / 512; // scale to the gas value |
1928 | GasReduction = (long)((long)GasReduction * HoverGas) / 512; // scale to the gas value |
1663 | // ------------------------ ---------------------------------- |
1929 | // ------------------------ ---------------------------------- |
1664 | HCGas -= GasReduction; |
1930 | HCGas -= GasReduction; |
1665 | // limit deviation from hoover point within the target region |
1931 | // limit deviation from hoover point within the target region |
Line 1701... | Line 1967... | ||
1701 | if(Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT) |
1967 | if(Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT) |
1702 | { // old version |
1968 | { // old version |
1703 | LIMIT_MAX(FilterHCGas, GasMischanteil); // nicht mehr als Gas |
1969 | LIMIT_MAX(FilterHCGas, GasMischanteil); // nicht mehr als Gas |
1704 | GasMischanteil = FilterHCGas; |
1970 | GasMischanteil = FilterHCGas; |
1705 | } |
1971 | } |
1706 | else GasMischanteil = FilterHCGas + (GasMischanteil - HoverGas) / 4; // only in Vario-Mode |
1972 | //else GasMischanteil = FilterHCGas + (GasMischanteil - HoverGas) / 4; // only in Vario-Mode // MartinR: so war es |
- | 1973 | else GasMischanteil = FilterHCGas ; // MartinR: geändert, um Überschwinger bei Höhenänderung zu verringern |
|
1707 | } |
1974 | } |
1708 | }// EOF height control active |
1975 | }// EOF height control active |
1709 | else // HC not active |
1976 | else // HC not active |
1710 | { |
1977 | { |
1711 | //update hoover gas stick value when HC is not active |
1978 | //update hoover gas stick value when HC is not active |
Line 1815... | Line 2082... | ||
1815 | if(GierMischanteil < -(MIN_GIERGAS / 2)) GierMischanteil = -(MIN_GIERGAS / 2); |
2082 | if(GierMischanteil < -(MIN_GIERGAS / 2)) GierMischanteil = -(MIN_GIERGAS / 2); |
1816 | } |
2083 | } |
1817 | tmp_int = MAX_GAS*STICK_GAIN; |
2084 | tmp_int = MAX_GAS*STICK_GAIN; |
1818 | if(GierMischanteil > ((tmp_int - GasMischanteil))) GierMischanteil = ((tmp_int - GasMischanteil)); |
2085 | if(GierMischanteil > ((tmp_int - GasMischanteil))) GierMischanteil = ((tmp_int - GasMischanteil)); |
1819 | if(GierMischanteil < -((tmp_int - GasMischanteil))) GierMischanteil = -((tmp_int - GasMischanteil)); |
2086 | if(GierMischanteil < -((tmp_int - GasMischanteil))) GierMischanteil = -((tmp_int - GasMischanteil)); |
- | 2087 | ||
- | 2088 | ||
- | 2089 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 2090 | // Nick / Roll-Achse // MartinR: um Code zu sparen wurde Nick und Roll zusammengefasst |
|
- | 2091 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 2092 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
|
- | 2093 | DiffRoll = MesswertRoll - StickRoll; // Differenz bestimmen |
|
Line -... | Line 2094... | ||
- | 2094 | ||
- | 2095 | // PI-Regler für Nick und Roll |
|
- | 2096 | if(EE_Parameter.Gyro_Stability <= 8) |
|
- | 2097 | { |
|
- | 2098 | pd_ergebnis_nick = (EE_Parameter.Gyro_Stability * DiffNick) / 8 ; // Zwischenergebnis um Code zu sparen |
|
- | 2099 | pd_ergebnis_roll = (EE_Parameter.Gyro_Stability * DiffRoll) / 8; |
|
- | 2100 | } |
|
- | 2101 | else |
|
- | 2102 | { |
|
- | 2103 | pd_ergebnis_nick = ((EE_Parameter.Gyro_Stability / 2) * DiffNick) / 4; // Überlauf verhindern |
|
- | 2104 | pd_ergebnis_roll = ((EE_Parameter.Gyro_Stability / 2) * DiffRoll) / 4; // Überlauf verhindern |
|
- | 2105 | } |
|
- | 2106 | ||
- | 2107 | if(IntegralFaktor) // MartinR : ACC-Mode |
|
- | 2108 | { |
|
- | 2109 | SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung |
|
- | 2110 | if(SummeNick > (STICK_GAIN * 8000L)) SummeNick = (STICK_GAIN * 8000L); // MartinR : von 16000 auf 8000, da überlauf |
|
- | 2111 | if(SummeNick < -(8000L * STICK_GAIN)) SummeNick = -(8000L * STICK_GAIN); // MartinR : von 16000 auf 8000, da überlauf |
|
- | 2112 | pd_ergebnis_nick += (SummeNick / Ki); // PI-Regler für Nick |
|
- | 2113 | SummeNickHH = 0 ; |
|
- | 2114 | ||
- | 2115 | SummeRoll += IntegralRollMalFaktor - StickRoll; |
|
- | 2116 | if(SummeRoll > (STICK_GAIN * 8000L)) SummeRoll = (STICK_GAIN * 8000L);// MartinR : von 16000 auf 8000, da überlauf |
|
- | 2117 | if(SummeRoll < -(8000L * STICK_GAIN)) SummeRoll = -(8000L * STICK_GAIN);// MartinR : von 16000 auf 8000, da überlauf |
|
- | 2118 | pd_ergebnis_roll += (SummeRoll / Ki); // PI-Regler für Roll |
|
- | 2119 | SummeRollHH = 0; |
|
- | 2120 | ||
- | 2121 | } |
|
- | 2122 | else // MartinR : HH-Mode |
|
- | 2123 | { |
|
- | 2124 | SummeNickHH += DiffNick; // I-Anteil bei HH |
|
- | 2125 | if(SummeNickHH > (STICK_GAIN * 8000L)) SummeNickHH = (STICK_GAIN * 8000L); // MartinR : von 16000 auf 8000, da überlauf |
|
- | 2126 | if(SummeNickHH < -(8000L * STICK_GAIN)) SummeNickHH = -(8000L * STICK_GAIN); // MartinR : von 16000 auf 8000, da überlauf |
|
- | 2127 | pd_ergebnis_nick += SummeNickHH / KiHH; // MartinR: PI-Regler für Nick bei HH |
|
- | 2128 | SummeNick = 0; |
|
- | 2129 | ||
- | 2130 | SummeRollHH += DiffRoll; // I-Anteil bei HH |
|
- | 2131 | if(SummeRollHH > (STICK_GAIN * 8000L)) SummeRollHH = (STICK_GAIN * 8000L);// MartinR : von 16000 auf 8000, da überlauf |
|
- | 2132 | if(SummeRollHH < -(8000L * STICK_GAIN)) SummeRollHH = -(8000L * STICK_GAIN);// MartinR : von 16000 auf 8000, da überlauf |
|
- | 2133 | pd_ergebnis_roll += SummeRollHH / KiHH; // MartinR: PI-Regler für Roll bei HH |
|
- | 2134 | SummeRoll = 0; |
|
- | 2135 | } |
|
- | 2136 | // MartinR : geändert Ende |
|
- | 2137 | ||
- | 2138 | ||
- | 2139 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
|
- | 2140 | if(pd_ergebnis_nick > tmp_int) pd_ergebnis_nick = tmp_int; |
|
- | 2141 | if(pd_ergebnis_nick < -tmp_int) pd_ergebnis_nick = -tmp_int; |
|
- | 2142 | ||
- | 2143 | //tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
|
- | 2144 | if(pd_ergebnis_roll > tmp_int) pd_ergebnis_roll = tmp_int; |
|
- | 2145 | if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int; |
|
- | 2146 | ||
- | 2147 | ||
- | 2148 | // MartinR: alt |
|
1820 | 2149 | /* |
|
1821 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2150 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1822 | // Nick-Achse |
2151 | // Nick-Achse |
1823 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2152 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1824 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
2153 | DiffNick = MesswertNick - StickNick; // Differenz bestimmen |
Line 1850... | Line 2179... | ||
1850 | 2179 | |
|
1851 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
2180 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1852 | if(pd_ergebnis_roll > tmp_int) pd_ergebnis_roll = tmp_int; |
2181 | if(pd_ergebnis_roll > tmp_int) pd_ergebnis_roll = tmp_int; |
Line -... | Line 2182... | ||
- | 2182 | if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int; |
|
- | 2183 | ||
- | 2184 | */ |
|
1853 | if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int; |
2185 | // MartinR: alt Ende |
1854 | 2186 | ||
1855 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2187 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1856 | // Universal Mixer |
2188 | // Universal Mixer |
1857 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2189 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 1873... | Line 2205... | ||
1873 | // Gier |
2205 | // Gier |
1874 | if(Mixer.Motor[i][3] == 64) tmp_int += GierMischanteil; |
2206 | if(Mixer.Motor[i][3] == 64) tmp_int += GierMischanteil; |
1875 | else if(Mixer.Motor[i][3] == -64) tmp_int -= GierMischanteil; |
2207 | else if(Mixer.Motor[i][3] == -64) tmp_int -= GierMischanteil; |
1876 | else tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
2208 | else tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
Line 1877... | Line 2209... | ||
1877 | 2209 | ||
- | 2210 | if(tmp_int > tmp_motorwert[i]) tmp_int = (tmp_motorwert[i] + tmp_int) / 2; // MotorSmoothing // MartinR: so war es |
|
1878 | if(tmp_int > tmp_motorwert[i]) tmp_int = (tmp_motorwert[i] + tmp_int) / 2; // MotorSmoothing |
2211 | //if(tmp_int > tmp_motorwert[i]) tmp_int = ((2* tmp_motorwert[i] + tmp_int) / 3) + 1; // MartinR: evtl. stärkere Filterung um Hüpfen bei der Landung zu verringern |
1879 | // else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // original MotorSmoothing |
2212 | // else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // original MotorSmoothing |
1880 | else |
2213 | else |
1881 | { |
2214 | { |
1882 | if(EE_Parameter.MotorSmooth == 0) |
2215 | if(EE_Parameter.MotorSmooth == 0) |
Line 1901... | Line 2234... | ||
1901 | Motor[i].SetPoint = 0; |
2234 | Motor[i].SetPoint = 0; |
1902 | Motor[i].SetPointLowerBits = 0; |
2235 | Motor[i].SetPointLowerBits = 0; |
1903 | } |
2236 | } |
1904 | } |
2237 | } |
1905 | } |
2238 | } |
1906 | //DebugOut.Analog[16] |
- |