Subversion Repositories FlightCtrl

Rev

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

Rev 1232 Rev 1247
Line 61... Line 61...
61
int TrimNick, TrimRoll;
61
int TrimNick, TrimRoll;
62
int AdNeutralGierBias;
62
int AdNeutralGierBias;
63
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
63
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
64
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
64
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
65
int NaviAccNick, NaviAccRoll,NaviCntAcc = 0;
65
int NaviAccNick, NaviAccRoll,NaviCntAcc = 0;
66
volatile float NeutralAccZ = 0;
66
//volatile float NeutralAccZ = 0; // MartinR  : so war es
-
 
67
volatile int NeutralAccZ = 0; // MartinR geändert
-
 
68
 
-
 
69
volatile int NeutralAccZ2 = 0; // MartinR: für HP-Filter 
-
 
70
signed int h_p,h_d,h_delta,Ziel_d;  // MartinR: P,D Anteil beim eigenen Höhenregler
-
 
71
signed int SchwebeGas; // MartinR: für neuen Höhenregler
-
 
72
 
67
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
73
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
68
long IntegralNick = 0,IntegralNick2 = 0;
74
long IntegralNick = 0,IntegralNick2 = 0;
69
long IntegralRoll = 0,IntegralRoll2 = 0;
75
long IntegralRoll = 0,IntegralRoll2 = 0;
70
long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
76
long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
71
long Integral_Gier = 0;
77
long Integral_Gier = 0;
Line 80... Line 86...
80
unsigned int  KompassSignalSchlecht = 500;
86
unsigned int  KompassSignalSchlecht = 500;
81
unsigned char  MAX_GAS,MIN_GAS;
87
unsigned char  MAX_GAS,MIN_GAS;
82
unsigned char Notlandung = 0;
88
unsigned char Notlandung = 0;
83
unsigned char HoehenReglerAktiv = 0;
89
unsigned char HoehenReglerAktiv = 0;
84
unsigned char TrichterFlug = 0;
90
unsigned char TrichterFlug = 0;
-
 
91
 
-
 
92
unsigned char delay_Hoehenregler = 0; // MartinR: zur Begrenzung der Sinkgeschwindigkeit
-
 
93
signed int delay_SchwebeGas = 0; // MartinR: zur Begrenzung der Sinkgeschwindigkeit
-
 
94
 
85
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
95
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
86
long  ErsatzKompass;
96
long  ErsatzKompass;
87
int   ErsatzKompassInGrad; // Kompasswert in Grad
97
int   ErsatzKompassInGrad; // Kompasswert in Grad
88
int   GierGyroFehler = 0;
98
int   GierGyroFehler = 0;
89
char GyroFaktor,GyroFaktorGier;
99
char GyroFaktor,GyroFaktorGier;
Line 92... Line 102...
92
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
102
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
93
volatile unsigned char SenderOkay = 0;
103
volatile unsigned char SenderOkay = 0;
94
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
104
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
95
char MotorenEin = 0;
105
char MotorenEin = 0;
96
int HoehenWert = 0;
106
int HoehenWert = 0;
-
 
107
 
-
 
108
int HoehenWertalt = 0; //MartinR: Test
-
 
109
unsigned char iHoehe; // MartinR: Zähler für HoeheD
-
 
110
signed long HoehenWertSumme = 0; // MartinR: für neuen Höhenregler D-Anteil
-
 
111
 
97
int SollHoehe = 0;
112
int SollHoehe = 0;
98
int LageKorrekturRoll = 0,LageKorrekturNick = 0;
113
int LageKorrekturRoll = 0,LageKorrekturNick = 0;
99
//float Ki =  FAKTOR_I;
114
//float Ki =  FAKTOR_I;
100
int Ki = 10300 / 33;
115
int Ki = 10300 / 33;
-
 
116
 
-
 
117
int KiHH = 10300 / 33; // MartinR : für Ki bei HH über Schalter
-
 
118
 
101
unsigned char Looping_Nick = 0,Looping_Roll = 0;
119
unsigned char Looping_Nick = 0,Looping_Roll = 0;
102
unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0;
120
unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0;
Line 103... Line 121...
103
 
121
 
104
unsigned char Parameter_Luftdruck_D  = 48;      // Wert : 0-250
122
unsigned char Parameter_Luftdruck_D  = 48;      // Wert : 0-250
Line 141... Line 159...
141
unsigned char Parameter_NaviWindCorrection;
159
unsigned char Parameter_NaviWindCorrection;
142
unsigned char Parameter_NaviSpeedCompensation;
160
unsigned char Parameter_NaviSpeedCompensation;
143
unsigned char Parameter_ExternalControl;
161
unsigned char Parameter_ExternalControl;
144
struct mk_param_struct EE_Parameter;
162
struct mk_param_struct EE_Parameter;
145
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
163
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
146
int MaxStickNick = 0,MaxStickRoll = 0;
164
//int MaxStickNick = 0,MaxStickRoll = 0;MartinR: so war es
-
 
165
 
-
 
166
int MaxStickNick = 0,MaxStickRoll = 0,stick_nick_neutral = 0,stick_roll_neutral = 0;  // MartinR: stick_.._neutral hinzugefügt
-
 
167
 
147
unsigned int  modell_fliegt = 0;
168
unsigned int  modell_fliegt = 0;
148
volatile unsigned char MikroKopterFlags = 0;
169
volatile unsigned char MikroKopterFlags = 0;
149
long GIER_GRAD_FAKTOR = 1291;
170
long GIER_GRAD_FAKTOR = 1291;
150
signed int KopplungsteilNickRoll,KopplungsteilRollNick;
171
signed int KopplungsteilNickRoll,KopplungsteilRollNick;
151
unsigned char RequiredMotors = 4;
172
unsigned char RequiredMotors = 4;
Line 154... Line 175...
154
 
175
 
155
int MotorSmoothing(int neu, int alt)
176
int MotorSmoothing(int neu, int alt)
156
{
177
{
157
 int motor;
178
 int motor;
158
 if(neu > alt) motor = (1*(int)alt + neu) / 2;
179
 if(neu > alt) motor = (1*(int)alt + neu) / 2;
-
 
180
 //else   motor = neu - (alt - neu)*1; // MartinR: so war es
159
 else   motor = neu - (alt - neu)*1;
181
 else   motor = neu; // MartinR: Entsprechen Vorschlag von MartinW geändert
160
//if(Poti2 < 20)  return(neu);
182
//if(Poti2 < 20)  return(neu);
161
 return(motor);
183
 return(motor);
Line 162... Line 184...
162
}
184
}
Line 181... Line 203...
181
 unsigned int gier_neutral=0, nick_neutral=0, roll_neutral=0;
203
 unsigned int gier_neutral=0, nick_neutral=0, roll_neutral=0;
182
    ServoActive = 0; HEF4017R_ON;
204
    ServoActive = 0; HEF4017R_ON;
183
        NeutralAccX = 0;
205
        NeutralAccX = 0;
184
        NeutralAccY = 0;
206
        NeutralAccY = 0;
185
        NeutralAccZ = 0;
207
        NeutralAccZ = 0;
-
 
208
        NeutralAccZ2 = 0; // MartinR
-
 
209
       
186
    AdNeutralNick = 0;
210
    AdNeutralNick = 0;
187
        AdNeutralRoll = 0;
211
        AdNeutralRoll = 0;
188
        AdNeutralGier = 0;
212
        AdNeutralGier = 0;
189
    AdNeutralGierBias = 0;
213
    AdNeutralGierBias = 0;
190
    Parameter_AchsKopplung1 = 0;
214
    Parameter_AchsKopplung1 = 0;
Line 214... Line 238...
214
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
238
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
215
    {
239
    {
216
      NeutralAccY = abs(Mittelwert_AccRoll) / (2*ACC_AMPLIFY);
240
      NeutralAccY = abs(Mittelwert_AccRoll) / (2*ACC_AMPLIFY);
217
          NeutralAccX = abs(Mittelwert_AccNick) / (2*ACC_AMPLIFY);
241
          NeutralAccX = abs(Mittelwert_AccNick) / (2*ACC_AMPLIFY);
218
          NeutralAccZ = Aktuell_az;
242
          NeutralAccZ = Aktuell_az;
-
 
243
          NeutralAccZ2 = NeutralAccZ; // MartinR
219
    }
244
    }
220
    else
245
    else
221
    {
246
    {
222
      NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]);
247
      NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]);
223
          NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]);
248
          NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]);
Line 265... Line 290...
265
void Mittelwert(void)
290
void Mittelwert(void)
266
//############################################################################
291
//############################################################################
267
{
292
{
268
    static signed long tmpl,tmpl2,tmpl3,tmpl4;
293
    static signed long tmpl,tmpl2,tmpl3,tmpl4;
269
        static signed int oldNick, oldRoll, d2Roll, d2Nick;
294
        static signed int oldNick, oldRoll, d2Roll, d2Nick;
-
 
295
        static signed int oldNick2, oldRoll2 ; //MartinR : für geänderte d2* Ermittlung
270
        signed long winkel_nick, winkel_roll;
296
        signed long winkel_nick, winkel_roll;
Line 271... Line 297...
271
 
297
 
272
        MesswertGier = (signed int) AdNeutralGier - AdWertGier;
298
        MesswertGier = (signed int) AdNeutralGier - AdWertGier;
273
//    MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier;
299
//    MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier;
Line 292... Line 318...
292
    NaviCntAcc++;
318
    NaviCntAcc++;
293
    IntegralAccZ  += Aktuell_az - NeutralAccZ;
319
    IntegralAccZ  += Aktuell_az - NeutralAccZ;
Line 294... Line 320...
294
 
320
 
295
//++++++++++++++++++++++++++++++++++++++++++++++++
321
//++++++++++++++++++++++++++++++++++++++++++++++++
296
// ADC einschalten
322
// ADC einschalten
-
 
323
        //ANALOG_ON; // MartinR : so war es
297
    ANALOG_ON;
324
        // ANALOG_START; // MartinR verschoben zu timer0
298
        AdReady = 0;
325
        AdReady = 0;
Line 299... Line 326...
299
//++++++++++++++++++++++++++++++++++++++++++++++++
326
//++++++++++++++++++++++++++++++++++++++++++++++++
300
 
327
 
Line 308... Line 335...
308
 
335
 
309
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
336
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
310
   Mess_Integral_Gier += MesswertGier;
337
   Mess_Integral_Gier += MesswertGier;
311
   ErsatzKompass += MesswertGier;
338
   ErsatzKompass += MesswertGier;
-
 
339
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
-
 
340
 
-
 
341
if((EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) || (Parameter_UserParam1 > 140)) IntegralFaktor = 0;  // MartinR: zusätzlich
312
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
342
         
-
 
343
      //if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))  // MartinR : so war es
313
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
344
          if(!Looping_Nick && !Looping_Roll && IntegralFaktor && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) // MartinR: zusätzlich "&& IntegralFaktor"
314
         {
345
         {
315
            tmpl3 = (MesswertRoll * winkel_nick) / 2048L;
346
            tmpl3 = (MesswertRoll * winkel_nick) / 2048L;
316
            tmpl3 *= Parameter_AchsKopplung2; //65
347
            tmpl3 *= Parameter_AchsKopplung2; //65
317
            tmpl3 /= 4096L;
348
            tmpl3 /= 4096L;
Line 374... Line 405...
374
    IntegralNick2 = Mess_IntegralNick2;
405
    IntegralNick2 = Mess_IntegralNick2;
375
    IntegralRoll2 = Mess_IntegralRoll2;
406
    IntegralRoll2 = Mess_IntegralRoll2;
Line 376... Line 407...
376
 
407
 
Line 377... Line 408...
377
#define D_LIMIT 128
408
#define D_LIMIT 128
378
 
409
 
-
 
410
   //MesswertNick = HiResNick / 8;// MartinR : so war es
-
 
411
   //MesswertRoll = HiResRoll / 8;// MartinR : so war es
-
 
412
   MesswertNick = AdWertNickFilter / 8;// MartinR : anstelle HiResNick : AdWertNickFilter
Line -... Line 413...
-
 
413
   MesswertRoll = AdWertRollFilter / 8;// MartinR : ist im vergleich zu HiRes.. eimal mehr gemittelt
-
 
414
 
379
   MesswertNick = HiResNick / 8;
415
 
380
   MesswertRoll = HiResRoll / 8;
416
 // MartinR : so war es Anfang  
381
 
417
        /*
382
   if(AdWertNick < 15)   MesswertNick = -1000;  if(AdWertNick <  7)   MesswertNick = -2000;
418
   if(AdWertNick < 15)   MesswertNick = -1000;  if(AdWertNick <  7)   MesswertNick = -2000;
383
   if(PlatinenVersion == 10)  { if(AdWertNick > 1010) MesswertNick = +1000;  if(AdWertNick > 1017) MesswertNick = +2000; }
419
   if(PlatinenVersion == 10)  { if(AdWertNick > 1010) MesswertNick = +1000;  if(AdWertNick > 1017) MesswertNick = +2000; }
384
   else  {  if(AdWertNick > 2000) MesswertNick = +1000;  if(AdWertNick > 2015) MesswertNick = +2000; }
420
   else  {  if(AdWertNick > 2000) MesswertNick = +1000;  if(AdWertNick > 2015) MesswertNick = +2000; }
Line -... Line 421...
-
 
421
   if(AdWertRoll < 15)   MesswertRoll = -1000;  if(AdWertRoll <  7)   MesswertRoll = -2000;
-
 
422
   if(PlatinenVersion == 10) { if(AdWertRoll > 1010) MesswertRoll = +1000;  if(AdWertRoll > 1017) MesswertRoll = +2000; }
-
 
423
   else { if(AdWertRoll > 2000) MesswertRoll = +1000;  if(AdWertRoll > 2015) MesswertRoll = +2000;  }
-
 
424
 
-
 
425
        // MartinR : FC 1.0: Sprung von 500 auf 2000 !! FC-ME: Sprung von 1000 auf 2000
-
 
426
        */
-
 
427
        // MartinR : so war es Ende
-
 
428
       
-
 
429
         // MartinR : Neu Anfang
-
 
430
        if(PlatinenVersion == 10)  
-
 
431
        {
-
 
432
        if(AdWertNick > 1010) MesswertNick = +600;  
-
 
433
        if(AdWertNick > 1017) MesswertNick = +800;
-
 
434
        if(AdWertNick < 15)   MesswertNick = -600;  
-
 
435
        if(AdWertNick <  7)   MesswertNick = -800;
-
 
436
        if(AdWertRoll > 1010) MesswertRoll = +600;  
-
 
437
        if(AdWertRoll > 1017) MesswertRoll = +800;
-
 
438
        if(AdWertRoll < 15)   MesswertRoll = -600;  
-
 
439
        if(AdWertRoll <  7)   MesswertRoll = -800;
-
 
440
        }
-
 
441
        else  
-
 
442
        {  
-
 
443
        if(AdWertNick > 2000) MesswertNick = +1200;  
-
 
444
        if(AdWertNick > 2015) MesswertNick = +1600;
-
 
445
        if(AdWertNick < 15)   MesswertNick = -1200;  
-
 
446
        if(AdWertNick <  7)   MesswertNick = -1600;
-
 
447
        if(AdWertRoll > 2000) MesswertRoll = +1200;  
-
 
448
        if(AdWertRoll > 2015) MesswertRoll = +1600;
-
 
449
        if(AdWertRoll < 15)   MesswertRoll = -1200;  
385
   if(AdWertRoll < 15)   MesswertRoll = -1000;  if(AdWertRoll <  7)   MesswertRoll = -2000;
450
        if(AdWertRoll <  7)   MesswertRoll = -1600;
386
   if(PlatinenVersion == 10) { if(AdWertRoll > 1010) MesswertRoll = +1000;  if(AdWertRoll > 1017) MesswertRoll = +2000; }
451
        }
-
 
452
 // MartinR : Neu Ende
-
 
453
 
387
   else { if(AdWertRoll > 2000) MesswertRoll = +1000;  if(AdWertRoll > 2015) MesswertRoll = +2000;  }
454
  if(Parameter_Gyro_D)
388
 
455
  {
389
  if(Parameter_Gyro_D)
456
  /* MartinR: so war es Anfang
390
  {
457
 
391
   d2Nick = HiResNick - oldNick;
458
   d2Nick = HiResNick - oldNick;
Line 398... Line 465...
398
   if(d2Roll > D_LIMIT) d2Roll = D_LIMIT;
465
   if(d2Roll > D_LIMIT) d2Roll = D_LIMIT;
399
   else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT;
466
   else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT;
400
   MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16;
467
   MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16;
401
   HiResNick += (d2Nick * (signed int) Parameter_Gyro_D);
468
   HiResNick += (d2Nick * (signed int) Parameter_Gyro_D);
402
   HiResRoll += (d2Roll * (signed int) Parameter_Gyro_D);
469
   HiResRoll += (d2Roll * (signed int) Parameter_Gyro_D);
-
 
470
   
-
 
471
   */ //MartinR: so war es Ende
-
 
472
   
-
 
473
   // MartinR :neu Anfang
-
 
474
   d2Nick = MesswertNick - oldNick2;
-
 
475
   oldNick2 = oldNick;
-
 
476
   oldNick = MesswertNick;
-
 
477
   if(d2Nick > D_LIMIT) d2Nick = D_LIMIT;
-
 
478
   else if(d2Nick < -D_LIMIT) d2Nick = -D_LIMIT;
-
 
479
   if(d2Nick > 0) d2Nick --;
-
 
480
   if(d2Nick < 0) d2Nick ++;
-
 
481
   
-
 
482
   MesswertNick += (d2Nick * (signed int) Parameter_Gyro_D) / 16;
-
 
483
   
-
 
484
   d2Roll = MesswertRoll - oldRoll2;
-
 
485
   oldRoll2 = oldRoll;
-
 
486
   oldRoll = MesswertRoll;
-
 
487
   if(d2Roll > D_LIMIT) d2Roll = D_LIMIT;
-
 
488
   else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT;  
-
 
489
   if(d2Roll > 0) d2Roll --;
-
 
490
   if(d2Roll < 0) d2Roll ++;
-
 
491
   
-
 
492
   MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16;
-
 
493
   // MartinR :neu Ende
-
 
494
   
-
 
495
   
403
  }
496
  }
Line 404... Line 497...
404
 
497
 
405
 if(RohMesswertRoll > 0) TrimRoll  += ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
498
 if(RohMesswertRoll > 0) TrimRoll  += ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
406
 else                    TrimRoll -= ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
499
 else                    TrimRoll -= ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
Line 519... Line 612...
519
 CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255);
612
 CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255);
520
 CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255);
613
 CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255);
521
 CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255);
614
 CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255);
522
 CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255);
615
 CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255);
523
 Ki = 10300 / (Parameter_I_Faktor + 1);
616
 Ki = 10300 / (Parameter_I_Faktor + 1);
-
 
617
 
-
 
618
 if(Parameter_UserParam1 > 140) KiHH = 10300 / (Parameter_UserParam2 + 1); else  KiHH = Ki; // MartinR : für HH über Schalter
-
 
619
 Parameter_NaviGpsModeControl = EE_Parameter.NaviGpsModeControl; //MartinR: Standard: EE_Parameter.NaviGpsModeControl wird übertragen
-
 
620
 if(!IntegralFaktor) Parameter_NaviGpsModeControl= 0; // MartinR: wenn HH dann GPS auf free- Mode 
-
 
621
  // 0 = AID; 100 = free; 200 = coming home //so war es 
-
 
622
  // 0 = free; 100 = AID; 200 = coming home //neu 
-
 
623
 
524
 MAX_GAS = EE_Parameter.Gas_Max;
624
 MAX_GAS = EE_Parameter.Gas_Max;
525
 MIN_GAS = EE_Parameter.Gas_Min;
625
 MIN_GAS = EE_Parameter.Gas_Min;
526
}
626
}
Line 533... Line 633...
533
//############################################################################
633
//############################################################################
534
{
634
{
535
         int pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int;
635
         int pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int;
536
         int GierMischanteil,GasMischanteil;
636
         int GierMischanteil,GasMischanteil;
537
     static long SummeNick=0,SummeRoll=0;
637
     static long SummeNick=0,SummeRoll=0;
-
 
638
         
-
 
639
         static long SummeNickHH=0,SummeRollHH=0; // MartinR: Für ACC-HH Umschaltung
-
 
640
         
538
     static long sollGier = 0,tmp_long,tmp_long2;
641
     static long sollGier = 0,tmp_long,tmp_long2;
539
     static long IntegralFehlerNick = 0;
642
     static long IntegralFehlerNick = 0;
540
     static long IntegralFehlerRoll = 0;
643
     static long IntegralFehlerRoll = 0;
541
         static unsigned int RcLostTimer;
644
         static unsigned int RcLostTimer;
542
         static unsigned char delay_neutral = 0;
645
         static unsigned char delay_neutral = 0;
Line 700... Line 803...
700
                        Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll;
803
                        Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll;
701
                        Mess_IntegralNick2 = IntegralNick;
804
                        Mess_IntegralNick2 = IntegralNick;
702
                        Mess_IntegralRoll2 = IntegralRoll;
805
                        Mess_IntegralRoll2 = IntegralRoll;
703
                        SummeNick = 0;
806
                        SummeNick = 0;
704
                        SummeRoll = 0;
807
                        SummeRoll = 0;
-
 
808
                                                SchwebeGas = 0; // MartinR: für neuen Höhenregler
705
                        MikroKopterFlags |= FLAG_START;
809
                        MikroKopterFlags |= FLAG_START;
706
                        }
810
                        }
707
                    }
811
                    }
708
                    else delay_einschalten = 0;
812
                    else delay_einschalten = 0;
709
                //Auf Neutralwerte setzen
813
                //Auf Neutralwerte setzen
Line 729... Line 833...
729
 
833
 
730
 if(!NewPpmData-- || Notlandung)
834
 if(!NewPpmData-- || Notlandung)
731
  {
835
  {
732
        static int stick_nick,stick_roll;
836
        static int stick_nick,stick_roll;
-
 
837
    ParameterZuordnung();
-
 
838
       
-
 
839
        // MartinR: original:   
733
    ParameterZuordnung();
840
        /*
734
    stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4;
841
    stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4;
735
    stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D;
842
    stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D;
Line 736... Line 843...
736
    StickNick = stick_nick - (GPS_Nick + GPS_Nick2);
843
    StickNick = stick_nick - (GPS_Nick + GPS_Nick2);
737
 
844
 
738
    stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4;
845
    stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4;
-
 
846
    stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D;
-
 
847
    StickRoll = stick_roll - (GPS_Roll + GPS_Roll2);
-
 
848
       
-
 
849
        */
-
 
850
 
-
 
851
// MartinR: geändert Anfang
-
 
852
        if(Parameter_UserParam1 > 140)  // MartinR: zweiter Stick_P Wert nur, wenn HH über Schalter aktiv ist
-
 
853
                {
-
 
854
                stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * Parameter_UserParam3 - stick_nick_neutral) / 4;
-
 
855
                stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * Parameter_UserParam3 - stick_roll_neutral) / 4 ;
-
 
856
                }
-
 
857
               
-
 
858
         else
-
 
859
               
-
 
860
                stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4;
-
 
861
                stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4;
-
 
862
               
-
 
863
       
-
 
864
         if(IntegralFaktor)  
-
 
865
                {
-
 
866
                stick_nick_neutral = stick_nick; //  beim Umschalten auf HH wird derletzte Stickwert als Neutralposition verwendet, MartinR
-
 
867
                stick_roll_neutral = stick_roll; //  beim Umschalten auf HH wird derletzte Stickwert als Neutralposition verwendet, MartinR
-
 
868
                stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D;
-
 
869
                stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D;
-
 
870
               
-
 
871
                StickNick = stick_nick - (GPS_Nick + GPS_Nick2); // MartinR: GPS nur im ACC-Mode wirksam
-
 
872
                StickRoll = stick_roll - (GPS_Roll + GPS_Roll2); // MartinR: GPS nur im ACC-Mode wirksam
-
 
873
                }
-
 
874
        else            // wenn HH , MartinR
-
 
875
                {
-
 
876
                stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D; // MartinR: eventuell vor if verschieben
-
 
877
                stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; // MartinR: eventuell vor if verschieben
-
 
878
                StickNick = stick_nick; // MartinR: GPS nur im ACC-Mode wirksam
-
 
879
                StickRoll = stick_roll; // MartinR: GPS nur im ACC-Mode wirksam
-
 
880
                }
-
 
881
               
Line 739... Line 882...
739
    stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D;
882
// MartinR: geändert Ende
740
    StickRoll = stick_roll - (GPS_Roll + GPS_Roll2);
883
 
741
 
884
 
Line 750... Line 893...
750
    IntegralFaktorGier = Parameter_Gyro_I;
893
    IntegralFaktorGier = Parameter_Gyro_I;
Line 751... Line 894...
751
 
894
 
752
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
895
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
753
//+ Analoge Steuerung per Seriell
896
//+ Analoge Steuerung per Seriell
-
 
897
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
898
// MartinR: ToDo: eventuell die Kombination HH und Steuerung per Seriell nicht zulassen??
754
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
899
 
755
   if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128)
900
   if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128)
756
    {
901
    {
757
         StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
902
         StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
758
         StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
903
         StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
759
         StickGier += ExternControl.Gier;
904
         StickGier += ExternControl.Gier;
760
     ExternHoehenValue =  (int) ExternControl.Hight * (int)EE_Parameter.Hoehe_Verstaerkung;
905
     ExternHoehenValue =  (int) ExternControl.Hight * (int)EE_Parameter.Hoehe_Verstaerkung;
761
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
906
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
762
    }
907
    }
-
 
908
    if(StickGas < 0) StickGas = 0;
-
 
909
       
-
 
910
        //if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0; // MartinR: Original
Line 763... Line -...
763
    if(StickGas < 0) StickGas = 0;
-
 
764
 
911
        if((EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) || (Parameter_UserParam1 > 140)) IntegralFaktor = 0;  // MartinR
765
    if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0;
912
 
Line 766... Line 913...
766
    if(GyroFaktor < 0) GyroFaktor = 0;
913
    if(GyroFaktor < 0) GyroFaktor = 0;
767
    if(IntegralFaktor < 0) IntegralFaktor = 0;
914
    if(IntegralFaktor < 0) IntegralFaktor = 0;
Line 852... Line 999...
852
 MittelIntegralNick  += IntegralNick;    // Für die Mittelwertbildung aufsummieren
999
 MittelIntegralNick  += IntegralNick;    // Für die Mittelwertbildung aufsummieren
853
 MittelIntegralRoll  += IntegralRoll;
1000
 MittelIntegralRoll  += IntegralRoll;
854
 MittelIntegralNick2 += IntegralNick2;
1001
 MittelIntegralNick2 += IntegralNick2;
855
 MittelIntegralRoll2 += IntegralRoll2;
1002
 MittelIntegralRoll2 += IntegralRoll2;
Line 856... Line 1003...
856
 
1003
 
-
 
1004
 //if(Looping_Nick || Looping_Roll) // MartinR: so war es
857
 if(Looping_Nick || Looping_Roll)
1005
 if(Looping_Nick || Looping_Roll || !IntegralFaktor)  // MartinR: "|| !IntegralFaktor" hinzugefügt
858
  {
1006
  {
859
    IntegralAccNick = 0;
1007
    IntegralAccNick = 0;
860
    IntegralAccRoll = 0;
1008
    IntegralAccRoll = 0;
861
    MittelIntegralNick = 0;
1009
    MittelIntegralNick = 0;
862
    MittelIntegralRoll = 0;
1010
    MittelIntegralRoll = 0;
863
    MittelIntegralNick2 = 0;
1011
    MittelIntegralNick2 = 0;
-
 
1012
    MittelIntegralRoll2 = 0;
-
 
1013
       
-
 
1014
        IntegralNick = 0; // MartinR: im HH-Modus alle unbenutzten Integratoren = 0
-
 
1015
    IntegralRoll = 0; // MartinR: im HH-Modus alle unbenutzten Integratoren = 0 
-
 
1016
    Mess_IntegralNick = 0; // MartinR: im HH-Modus alle unbenutzten Integratoren = 0    
-
 
1017
    Mess_IntegralRoll = 0; // MartinR: im HH-Modus alle unbenutzten Integratoren = 0    
-
 
1018
    Mess_Integral_Gier = 0;     // MartinR: im HH-Modus alle unbenutzten Integratoren = 0       
-
 
1019
    Mess_Integral_Gier2 = 0; // MartinR: im HH-Modus alle unbenutzten Integratoren = 0
864
    MittelIntegralRoll2 = 0;
1020
       
865
    Mess_IntegralNick2 = Mess_IntegralNick;
1021
    Mess_IntegralNick2 = Mess_IntegralNick;
866
    Mess_IntegralRoll2 = Mess_IntegralRoll;
1022
    Mess_IntegralRoll2 = Mess_IntegralRoll;
867
    ZaehlMessungen = 0;
1023
    ZaehlMessungen = 0;
868
    LageKorrekturNick = 0;
1024
    LageKorrekturNick = 0;
869
    LageKorrekturRoll = 0;
1025
    LageKorrekturRoll = 0;
Line 870... Line 1026...
870
  }
1026
  }
871
 
1027
 
872
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1028
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
873
  if(!Looping_Nick && !Looping_Roll && (Aktuell_az > 512 || MotorenEin))
1029
  if(!Looping_Nick && !Looping_Roll && (Aktuell_az > 512 || MotorenEin) && IntegralFaktor) // MartinR: "&& IntegralFaktor" hinzugefügt 
874
  {
1030
  {
875
   long tmp_long, tmp_long2;
1031
   long tmp_long, tmp_long2;
876
   if(FromNaviCtrl_Value.Kalman_K != -1 /*&& !TrichterFlug*/)
1032
   if(FromNaviCtrl_Value.Kalman_K != -1 /*&& !TrichterFlug*/)
Line 926... Line 1082...
926
 if(ZaehlMessungen >= ABGLEICH_ANZAHL)
1082
 if(ZaehlMessungen >= ABGLEICH_ANZAHL)
927
 {
1083
 {
928
  static int cnt = 0;
1084
  static int cnt = 0;
929
  static char last_n_p,last_n_n,last_r_p,last_r_n;
1085
  static char last_n_p,last_n_n,last_r_p,last_r_n;
930
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
1086
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
-
 
1087
 
931
  if(!Looping_Nick && !Looping_Roll && !TrichterFlug && EE_Parameter.Driftkomp)
1088
  if(!Looping_Nick && !Looping_Roll && !TrichterFlug && EE_Parameter.Driftkomp && IntegralFaktor) // MartinR: "&& IntegralFaktor" hinzugefügt
-
 
1089
 
932
  {
1090
  {
933
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
1091
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
934
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
1092
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
935
        IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
1093
        IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
936
        IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
1094
        IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
Line 1185... Line 1343...
1185
    DebugOut.Analog[10] = SenderOkay;
1343
    DebugOut.Analog[10] = SenderOkay;
1186
    //DebugOut.Analog[16] = Mittelwert_AccHoch;
1344
    //DebugOut.Analog[16] = Mittelwert_AccHoch;
1187
    //DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
1345
    //DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
1188
    //DebugOut.Analog[18] = (int)FromNaviCtrl_Value.OsdBar;
1346
    //DebugOut.Analog[18] = (int)FromNaviCtrl_Value.OsdBar;
1189
    DebugOut.Analog[19] = WinkelOut.CalcState;
1347
    DebugOut.Analog[19] = WinkelOut.CalcState;
1190
    DebugOut.Analog[20] = ServoValue;
1348
//    DebugOut.Analog[20] = ServoValue; // MartinR: DebugOut.Analog[20] wird in timer0.c ausgegeben!!
1191
//    DebugOut.Analog[24] = MesswertNick/2;
1349
//    DebugOut.Analog[24] = MesswertNick/2;
1192
//    DebugOut.Analog[25] = MesswertRoll/2;
1350
//    DebugOut.Analog[25] = MesswertRoll/2;
1193
    DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift;
1351
    DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift;
1194
//    DebugOut.Analog[28] = (int)FromNaviCtrl_Value.Kalman_MaxFusion;
1352
//    DebugOut.Analog[28] = (int)FromNaviCtrl_Value.Kalman_MaxFusion;
1195
//    DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K;
1353
//    DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K;
Line 1235... Line 1393...
1235
 
1393
 
1236
#define TRIM_MAX 200
1394
#define TRIM_MAX 200
1237
 if(TrimNick > TRIM_MAX) TrimNick = TRIM_MAX; else  if(TrimNick <-TRIM_MAX) TrimNick =-TRIM_MAX;
1395
 if(TrimNick > TRIM_MAX) TrimNick = TRIM_MAX; else  if(TrimNick <-TRIM_MAX) TrimNick =-TRIM_MAX;
Line -... Line 1396...
-
 
1396
 if(TrimRoll > TRIM_MAX) TrimRoll = TRIM_MAX; else  if(TrimRoll <-TRIM_MAX) TrimRoll =-TRIM_MAX;
-
 
1397
 
-
 
1398
 if(!IntegralFaktor) // MartinR : hinzugefügt
-
 
1399
        {
-
 
1400
        MesswertNick = (long) ((long)MesswertNick * GyroFaktor) / (256L / STICK_GAIN)  ; // MartinR : hinzugefügt
-
 
1401
        MesswertRoll = (long) ((long)MesswertRoll * GyroFaktor) / (256L / STICK_GAIN) ;  // MartinR : hinzugefügt
-
 
1402
        }
1238
 if(TrimRoll > TRIM_MAX) TrimRoll = TRIM_MAX; else  if(TrimRoll <-TRIM_MAX) TrimRoll =-TRIM_MAX;
1403
        else // MartinR so war es
1239
 
1404
        {
-
 
1405
    MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN);
-
 
1406
    MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN);
1240
    MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN);
1407
        }
Line 1241... Line 1408...
1241
    MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN);
1408
 
-
 
1409
    MesswertGier = (long)(MesswertGier * 2 * (long)GyroFaktorGier) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktorGier) / (2 * (44000 / STICK_GAIN));
-
 
1410
 
1242
    MesswertGier = (long)(MesswertGier * 2 * (long)GyroFaktorGier) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktorGier) / (2 * (44000 / STICK_GAIN));
1411
    // Maximalwerte abfangen
1243
 
1412
        // MartinR : Prüfen ob Unterscheidung nach Platinenversion erforderlich?
1244
    // Maximalwerte abfangen
1413
       
1245
//    #define MAX_SENSOR  (4096*STICK_GAIN)
1414
//    #define MAX_SENSOR  (4096*STICK_GAIN)
1246
    #define MAX_SENSOR  (4096*4)
1415
    #define MAX_SENSOR  (4096*4)
Line 1263... Line 1432...
1263
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1432
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1264
// Höhenregelung
1433
// Höhenregelung
1265
// Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht
1434
// Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht
1266
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1435
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1267
  GasMischanteil *= STICK_GAIN;
1436
  GasMischanteil *= STICK_GAIN;
-
 
1437
 
-
 
1438
        Mess_Integral_Hoch += AdWertAccHoch;      // Integrieren // MartinR: zu Höhenregler in fc.c verschoben
-
 
1439
    Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen // MartinR: zu Höhenregler in fc.c verschoben
-
 
1440
 
-
 
1441
        // MartinR: Änderungen HoheD Anfang :
-
 
1442
                HoehenWert = 255 * ExpandBaro + StartLuftdruck - Luftdruck;
-
 
1443
                HoehenWertSumme += HoehenWert ;
-
 
1444
                if (++ iHoehe >= 40) // MartinR: Wartezeit um auch kleine Änderungsgeschwindigkeiten erkennen zu können
-
 
1445
                {
-
 
1446
                 HoehenWertSumme = HoehenWertSumme / iHoehe ; // MartinR: Mittelwert während der Wartezeit
-
 
1447
                 HoeheD = (int) Parameter_Luftdruck_D * (HoehenWert - HoehenWertalt) ;
-
 
1448
                 if (HoeheD < 0) HoeheD += Parameter_Luftdruck_D ; // MartinR: Digitalisierungsrauschen abmindern
-
 
1449
                 if (HoeheD > 0) HoeheD -= Parameter_Luftdruck_D ; // MartinR: entspricht - 1 Bit vom Höhenwert
-
 
1450
                 
-
 
1451
                 iHoehe = 0 ;
-
 
1452
                 HoehenWertalt = HoehenWertSumme ;
-
 
1453
                 HoehenWertSumme = 0 ;
-
 
1454
                }      
-
 
1455
        // MartinR: Änderungen HoheD Ende
-
 
1456
 
-
 
1457
 
-
 
1458
  // MartinR: bisheriger Höhenregler
-
 
1459
 
-
 
1460
  /*
1268
 if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
1461
 if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
1269
  {
1462
  {
1270
    int tmp_int;
1463
    int tmp_int;
1271
        static char delay = 100;
1464
        static char delay = 100;
1272
    if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
1465
    if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
Line 1338... Line 1531...
1338
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
1531
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
1339
      GasMischanteil = hoehenregler;
1532
      GasMischanteil = hoehenregler;
1340
     }
1533
     }
1341
  }
1534
  }
1342
  if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN;
1535
  if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN;
-
 
1536
 
-
 
1537
  */
-
 
1538
// MartinR: Ende bisheriger Höhenregler
-
 
1539
 
-
 
1540
// MartinR: Neuer Höhenregler von MartinR: Anfang
-
 
1541
 
-
 
1542
   if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
-
 
1543
  {
-
 
1544
    int tmp_int;
-
 
1545
        static char delay = 100;
-
 
1546
    if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
-
 
1547
    {
-
 
1548
      //if(Parameter_MaxHoehe < 50)  // MartinR :so war es
-
 
1549
          if(Parameter_MaxHoehe < 50  || (Parameter_UserParam1 > 140) )   // MartinR: Schalter aus oder HH über UsererParam1 an
-
 
1550
      {
-
 
1551
       if(!delay--)
-
 
1552
            {
-
 
1553
         if((MessLuftdruck > 1000) && OCR0A < 254)
-
 
1554
                  {
-
 
1555
                    if(OCR0A < 244)
-
 
1556
                     {
-
 
1557
                      ExpandBaro -= 10;
-
 
1558
                      OCR0A = DruckOffsetSetting - ExpandBaro;
-
 
1559
                         }
-
 
1560
                         else OCR0A = 254;
-
 
1561
                beeptime = 300;
-
 
1562
            delay = 250;
-
 
1563
                  }
-
 
1564
                  else      
-
 
1565
         if((MessLuftdruck < 100) && OCR0A > 1)
-
 
1566
                  {
-
 
1567
                   if(OCR0A > 10)
-
 
1568
                    {
-
 
1569
                     ExpandBaro += 10;
-
 
1570
                     OCR0A = DruckOffsetSetting - ExpandBaro;
-
 
1571
                        }
-
 
1572
                         else OCR0A = 1;
-
 
1573
                   beeptime = 300;
-
 
1574
           delay = 250;
-
 
1575
                  }
-
 
1576
          else
-
 
1577
          {
-
 
1578
               //SollHoehe = HoehenWert - 20;  // Parameter_MaxHoehe ist der PPM-Wert des Schalters // MartinR : so war es
-
 
1579
                   SollHoehe = HoehenWert; // MartinR : geändert
-
 
1580
           HoehenReglerAktiv = 0;
-
 
1581
                   delay = 1;
-
 
1582
                  }
-
 
1583
                }
-
 
1584
                SollHoehe = HoehenWert;  // MartinR: SollHoehe wird nachgeführt bis HoehenreglerAktiv = 1
-
 
1585
                SchwebeGas = GasMischanteil;  // MartinR: SchwebeGas wird nachgeführt bis HoehenreglerAktiv = 1
-
 
1586
                HoehenReglerAktiv = 0; // MartinR: zur Sicherheit
-
 
1587
      }
-
 
1588
      else // Schalter an und kein HH über Schalter
-
 
1589
        {
-
 
1590
         HoehenReglerAktiv = 1;
-
 
1591
                 // Schwebegas ist der letzte GasMischanteil vor dem Aktivieren der Höhenregelung
-
 
1592
                 delay = 200;
-
 
1593
                }
-
 
1594
    }
-
 
1595
    else // Sollhöhe über Poti
-
 
1596
    {
-
 
1597
     //SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20; // MartinR : so war es
-
 
1598
         //HoehenReglerAktiv = 1; // MartinR : so war es
-
 
1599
         if(Parameter_UserParam1 > 140) // HH über Schalter: Höhenregler abgeschaltet, Nachführen von Parametern 
-
 
1600
         {
-
 
1601
           SollHoehe = HoehenWert;  // SollHoehe wird nachgeführt bis HoehenreglerAktiv = 1
-
 
1602
       HoehenReglerAktiv = 0;
-
 
1603
         }
-
 
1604
         else  // Höhenregler mit Sollhöhe über Poti aktiv
-
 
1605
         {
-
 
1606
          SchwebeGas = GasMischanteil;  // SchwebeGas zunächst = Gasmischanteil bis bessere Lösung
-
 
1607
      HoehenReglerAktiv = 1;
-
 
1608
          // MartinR: Versuch Höhenregler zu verlangsamen.  Steig- / Sinkrate im MK-Tool über UserParam4 einstellbar
-
 
1609
                if (((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20 > SollHoehe)
-
 
1610
                {
-
 
1611
                        if(++delay_Hoehenregler > (Parameter_UserParam4 / 4))
-
 
1612
                        {
-
 
1613
                        delay_Hoehenregler = 0;
-
 
1614
                        SollHoehe ++ ; //MartinR: Höhenänderung begrenzen.
-
 
1615
                        }
-
 
1616
                }
-
 
1617
                else
-
 
1618
                {
-
 
1619
                        if (((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20 < SollHoehe)
-
 
1620
                        {
-
 
1621
                                if(++delay_Hoehenregler > (Parameter_UserParam4 / 4))
-
 
1622
                                {
-
 
1623
                                delay_Hoehenregler = 0;
-
 
1624
                                SollHoehe -- ; //MartinR: Höhenänderung begrenzen.
-
 
1625
                                }
-
 
1626
                        }
-
 
1627
                }
-
 
1628
         }
-
 
1629
         
-
 
1630
         
-
 
1631
    }
-
 
1632
 
-
 
1633
    if(Notlandung) SollHoehe = 0;
-
 
1634
        // MartinR: so war es Anfang
-
 
1635
        /*
-
 
1636
    h = HoehenWert;
-
 
1637
    if((h > SollHoehe) && HoehenReglerAktiv)      // zu hoch --> drosseln
-
 
1638
     {
-
 
1639
      h = ((h - SollHoehe) * (int) Parameter_Hoehe_P) / (16 / STICK_GAIN); // Differenz bestimmen --> P-Anteil
-
 
1640
      h = GasMischanteil - h;         // vom Gas abziehen
-
 
1641
      h -= (HoeheD)/(8/STICK_GAIN);    // D-Anteil
-
 
1642
      tmp_int = ((Mess_Integral_Hoch / 128) * (signed long) Parameter_Hoehe_ACC_Wirkung) / (128 / STICK_GAIN);
-
 
1643
      if(tmp_int > 70*STICK_GAIN) tmp_int = 70*STICK_GAIN;
-
 
1644
      else if(tmp_int < -(70*STICK_GAIN)) tmp_int = -(70*STICK_GAIN);
-
 
1645
      h -= tmp_int;
-
 
1646
      hoehenregler = (hoehenregler*15 + h) / 16;
-
 
1647
      if(hoehenregler < EE_Parameter.Hoehe_MinGas * STICK_GAIN) // nicht unter MIN
-
 
1648
       {
-
 
1649
         if(GasMischanteil >= EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = EE_Parameter.Hoehe_MinGas * STICK_GAIN;
-
 
1650
         if(GasMischanteil < EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = GasMischanteil;
-
 
1651
       }
-
 
1652
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
-
 
1653
      GasMischanteil = hoehenregler;
-
 
1654
     }
-
 
1655
  }
-
 
1656
  */  // MartinR: so war es Ende
-
 
1657
       
-
 
1658
        // MartinR: neuer Höhenregler Anfang
-
 
1659
       
-
 
1660
         if(HoehenReglerAktiv && !(Parameter_UserParam1 > 140))      // kein HH
-
 
1661
        {
-
 
1662
          h_delta = (int) SollHoehe - (int) HoehenWert; // positiver Wert: MK ist unterhalb der Sollhöhe
-
 
1663
         
-
 
1664
         
-
 
1665
          h_p = (h_delta * (int) Parameter_Hoehe_P) / (16 / STICK_GAIN); // Differenz bestimmen --> P-Anteil
-
 
1666
         
-
 
1667
      h_d = (int) (HoeheD)/(64/STICK_GAIN);    // D-Anteil (8*8=64)
-
 
1668
          // ACC-D-Anteil
-
 
1669
      tmp_int = ((Mess_Integral_Hoch / 128) * (signed long) Parameter_Hoehe_ACC_Wirkung) / (128 / STICK_GAIN);
-
 
1670
      if(tmp_int > 50*STICK_GAIN) tmp_int = 50*STICK_GAIN;
-
 
1671
      else if(tmp_int < -(50*STICK_GAIN)) tmp_int = -(50*STICK_GAIN);
-
 
1672
      h_d += tmp_int; // positiver D-Anteil bedeutet Steigen
-
 
1673
         
-
 
1674
          h = SchwebeGas + h_p - h_d ;
-
 
1675
         
-
 
1676
          hoehenregler = (hoehenregler*7 + h) / 8;
-
 
1677
         
-
 
1678
          if(hoehenregler < EE_Parameter.Hoehe_MinGas * STICK_GAIN) // nicht unter MIN
-
 
1679
      {
-
 
1680
        if(GasMischanteil >= EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = EE_Parameter.Hoehe_MinGas * STICK_GAIN;
-
 
1681
        if(GasMischanteil < EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = GasMischanteil;
-
 
1682
      }  
-
 
1683
          if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
-
 
1684
          //else hoehenregler += (GasMischanteil-hoehenregler)/16  ; // um die Höhe noch leicht mit Gas korrigieren zu können
-
 
1685
          //if(SchwebeGas < 20)  SchwebeGas = 20; // nicht unter 20
-
 
1686
         
-
 
1687
          GasMischanteil = hoehenregler;
-
 
1688
        }
-
 
1689
        else  // Integratoren auf Null halten
-
 
1690
        {
-
 
1691
        Mess_Integral_Hoch = 0;
-
 
1692
        hoehenregler = GasMischanteil;
-
 
1693
        h_p = 0 ;
-
 
1694
        h_d = 0 ;
-
 
1695
        }
-
 
1696
  }
-
 
1697
         // MartinR: neuer Höhenregler Ende
-
 
1698
 
-
 
1699
  if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN;
-
 
1700
 
-
 
1701
 // MartinR: Ende neuer Höhenregler 
Line 1343... Line 1702...
1343
 
1702
 
1344
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1703
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1345
// + Mischer und PI-Regler
1704
// + Mischer und PI-Regler
1346
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1705
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 1368... Line 1727...
1368
 
1727
 
1369
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1728
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1370
// Nick-Achse
1729
// Nick-Achse
1371
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1730
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
1731
    DiffNick = MesswertNick - StickNick;        // Differenz bestimmen
-
 
1732
       
-
 
1733
        // MartinR : so war es Anfang
1372
    DiffNick = MesswertNick - StickNick;        // Differenz bestimmen
1734
        /*
1373
    if(IntegralFaktor) SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung
1735
    if(IntegralFaktor) SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung
1374
    else  SummeNick += DiffNick; // I-Anteil bei HH
1736
    else  SummeNick += DiffNick; // I-Anteil bei HH
1375
    if(SummeNick >  (STICK_GAIN * 16000L)) SummeNick =  (STICK_GAIN * 16000L);
1737
    if(SummeNick >  (STICK_GAIN * 16000L)) SummeNick =  (STICK_GAIN * 16000L);
1376
    if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
1738
    if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
1377
    pd_ergebnis_nick = DiffNick + SummeNick / Ki; // PI-Regler für Nick
1739
    pd_ergebnis_nick = DiffNick + SummeNick / Ki; // PI-Regler für Nick
-
 
1740
    // Motor Vorn
-
 
1741
        */
-
 
1742
        // MartinR : so war es Ende
-
 
1743
       
-
 
1744
        // MartinR : geändert Anfang
-
 
1745
       
-
 
1746
        if(IntegralFaktor) // MartinR : ACC-Mode
-
 
1747
         {
-
 
1748
          SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung
-
 
1749
          if(SummeNick >  (STICK_GAIN * 8000L)) SummeNick =  (STICK_GAIN * 8000L); // MartinR : von 16000 auf 8000, da überlauf
-
 
1750
      if(SummeNick < -(8000L * STICK_GAIN)) SummeNick = -(8000L * STICK_GAIN); // MartinR : von 16000 auf 8000, da überlauf
-
 
1751
          pd_ergebnis_nick = DiffNick + (SummeNick / Ki);
-
 
1752
          SummeNickHH = 0 ;
-
 
1753
         }
-
 
1754
    else // MartinR : HH-Mode
-
 
1755
         {
-
 
1756
          SummeNickHH += DiffNick; // I-Anteil bei HH
-
 
1757
      if(SummeNickHH >  (STICK_GAIN * 8000L)) SummeNickHH =  (STICK_GAIN * 8000L); // MartinR : von 16000 auf 8000, da überlauf
-
 
1758
      if(SummeNickHH < -(8000L * STICK_GAIN)) SummeNickHH = -(8000L * STICK_GAIN); // MartinR : von 16000 auf 8000, da überlauf
-
 
1759
          pd_ergebnis_nick = DiffNick + SummeNickHH / KiHH; // MartinR: PI-Regler für Nick bei HH
-
 
1760
          SummeNick = 0;
-
 
1761
     } 
-
 
1762
       
-
 
1763
        // MartinR : geändert Ende
1378
    // Motor Vorn
1764
       
1379
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1765
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1380
    if(pd_ergebnis_nick >  tmp_int) pd_ergebnis_nick =  tmp_int;
1766
    if(pd_ergebnis_nick >  tmp_int) pd_ergebnis_nick =  tmp_int;
Line -... Line 1767...
-
 
1767
    if(pd_ergebnis_nick < -tmp_int) pd_ergebnis_nick = -tmp_int;
-
 
1768
 
1381
    if(pd_ergebnis_nick < -tmp_int) pd_ergebnis_nick = -tmp_int;
1769
       
1382
 
1770
 
1383
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1771
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1384
// Roll-Achse
1772
// Roll-Achse
-
 
1773
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
1774
        DiffRoll = MesswertRoll - StickRoll;    // Differenz bestimmen
-
 
1775
       
1385
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1776
        // MartinR : so war es Anfang
1386
        DiffRoll = MesswertRoll - StickRoll;    // Differenz bestimmen
1777
        /*
1387
    if(IntegralFaktor) SummeRoll += IntegralRollMalFaktor - StickRoll;// I-Anteil bei Winkelregelung
1778
    if(IntegralFaktor) SummeRoll += IntegralRollMalFaktor - StickRoll;// I-Anteil bei Winkelregelung
1388
    else                 SummeRoll += DiffRoll;  // I-Anteil bei HH
1779
    else                 SummeRoll += DiffRoll;  // I-Anteil bei HH
1389
    if(SummeRoll >  (STICK_GAIN * 16000L)) SummeRoll =  (STICK_GAIN * 16000L);
1780
    if(SummeRoll >  (STICK_GAIN * 16000L)) SummeRoll =  (STICK_GAIN * 16000L);
-
 
1781
    if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN);
-
 
1782
    pd_ergebnis_roll = DiffRoll + SummeRoll / Ki;       // PI-Regler für Roll
-
 
1783
        */
-
 
1784
        // MartinR : so war es Ende
-
 
1785
       
-
 
1786
        // MartinR : geändert Anfang
-
 
1787
       
-
 
1788
        if(IntegralFaktor) // MartinR : ACC-Mode
-
 
1789
         {
-
 
1790
         SummeRoll += IntegralRollMalFaktor - StickRoll;
-
 
1791
         if(SummeRoll >  (STICK_GAIN * 8000L)) SummeRoll =  (STICK_GAIN * 8000L);// MartinR : von 16000 auf 8000, da überlauf
-
 
1792
     if(SummeRoll < -(8000L * STICK_GAIN)) SummeRoll = -(8000L * STICK_GAIN);// MartinR : von 16000 auf 8000, da überlauf
-
 
1793
         tmp_int = SummeRoll / Ki;
-
 
1794
         pd_ergebnis_roll = DiffRoll + tmp_int;         // MartinR: PI-Regler im ACC-Mode
-
 
1795
         //SummeRollHH = (IntegralRollMalFaktor + tmp_int - stick_roll_neutral + (TrimRoll * STICK_GAIN / 2)) * KiHH;// MartinR: Startwert von SummeRollHH bei Umschaltung auf HH
-
 
1796
         // MartinR: Hintergrund: pd_ergebnis_xx soll sich beim Umschalten nicht ändern!
-
 
1797
         SummeRollHH = 0;
-
 
1798
         }
-
 
1799
    else // MartinR : HH-Mode
-
 
1800
         {               
-
 
1801
          SummeRollHH += DiffRoll;  // I-Anteil bei HH
-
 
1802
      if(SummeRollHH >  (STICK_GAIN * 8000L)) SummeRollHH =  (STICK_GAIN * 8000L);// MartinR : von 16000 auf 8000, da überlauf
-
 
1803
      if(SummeRollHH < -(8000L * STICK_GAIN)) SummeRollHH = -(8000L * STICK_GAIN);// MartinR : von 16000 auf 8000, da überlauf
-
 
1804
          pd_ergebnis_roll = DiffRoll + SummeRollHH / KiHH;     // MartinR: PI-Regler für Roll bei HH
-
 
1805
          SummeRoll = 0;
-
 
1806
         }
-
 
1807
       
-
 
1808
        // MartinR : geändert Ende
1390
    if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN);
1809
       
1391
    pd_ergebnis_roll = DiffRoll + SummeRoll / Ki;       // PI-Regler für Roll
1810
       
1392
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1811
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
Line 1393... Line 1812...
1393
    if(pd_ergebnis_roll >  tmp_int) pd_ergebnis_roll =  tmp_int;
1812
    if(pd_ergebnis_roll >  tmp_int) pd_ergebnis_roll =  tmp_int;