Subversion Repositories FlightCtrl

Rev

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

Rev 1122 Rev 1124
Line 56... Line 56...
56
#include "parameter.h"
56
#include "parameter.h"
57
#include "pitch.h"
57
#include "pitch.h"
58
#include "altcon.h"
58
#include "altcon.h"
59
#include "eeprom.c"
59
#include "eeprom.c"
Line 60... Line 60...
60
 
60
 
61
unsigned char h,m,s;
61
unsigned char h, m, s;
62
volatile unsigned int I2CTimeout = 100;
62
volatile unsigned int I2CTimeout = 100;
63
volatile int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias;
63
volatile int MesswertNick, MesswertRoll, MesswertGier, MesswertGierBias;
64
int AdNeutralGierBias;
64
int AdNeutralGierBias;
65
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
65
int AdNeutralNick = 0, AdNeutralRoll = 0, AdNeutralGier = 0, StartNeutralRoll = 0, StartNeutralNick = 0;
66
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
66
int Mittelwert_AccNick, Mittelwert_AccRoll, Mittelwert_AccHoch, NeutralAccX = 0, NeutralAccY = 0;
67
int NaviAccNick, NaviAccRoll,NaviCntAcc = 0;
67
int NaviAccNick, NaviAccRoll, NaviCntAcc = 0;
68
volatile float NeutralAccZ = 0;
68
volatile float NeutralAccZ = 0;
69
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
69
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
70
long IntegralNick = 0,IntegralNick2 = 0;
70
long IntegralNick = 0, IntegralNick2 = 0;
71
long IntegralRoll = 0,IntegralRoll2 = 0;
71
long IntegralRoll = 0, IntegralRoll2 = 0;
72
long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
72
long IntegralAccNick = 0, IntegralAccRoll = 0, IntegralAccZ = 0;
73
long Integral_Gier = 0;
73
long Integral_Gier = 0;
74
long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0;
74
long Mess_IntegralNick = 0, Mess_IntegralNick2 = 0;
75
long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0;
75
long Mess_IntegralRoll = 0, Mess_IntegralRoll2 = 0;
76
long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0;
76
long Mess_Integral_Gier = 0, Mess_Integral_Gier2 = 0;
77
long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2;
77
long MittelIntegralNick, MittelIntegralRoll, MittelIntegralNick2, MittelIntegralRoll2;
78
volatile long Mess_Integral_Hoch = 0;
78
volatile long Mess_Integral_Hoch = 0;
79
volatile int  KompassValue = 0;
79
volatile int KompassValue = 0;
80
volatile int  KompassStartwert = 0;
80
volatile int KompassStartwert = 0;
81
volatile int  KompassRichtung = 0;
81
volatile int KompassRichtung = 0;
82
unsigned int  KompassSignalSchlecht = 500;
82
unsigned int KompassSignalSchlecht = 500;
83
unsigned char  MAX_GAS,MIN_GAS;
83
unsigned char MAX_GAS, MIN_GAS;
84
unsigned char Notlandung = 0;
84
unsigned char Notlandung = 0;
85
unsigned char HoehenReglerAktiv = 0;
85
unsigned char HoehenReglerAktiv = 0;
86
unsigned char TrichterFlug = 0;
86
unsigned char TrichterFlug = 0;
87
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
87
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
88
long  ErsatzKompass;
88
long ErsatzKompass;
89
int   ErsatzKompassInGrad; // Kompasswert in Grad
89
int ErsatzKompassInGrad; // Kompasswert in Grad
90
int   GierGyroFehler = 0;
90
int GierGyroFehler = 0;
91
float GyroFaktor;
91
float GyroFaktor;
92
float IntegralFaktor;
92
float IntegralFaktor;
93
volatile int  DiffNick,DiffRoll;
93
volatile int DiffNick, DiffRoll;
94
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
94
int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
95
volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count;
95
volatile unsigned char Motor_Vorne, Motor_Hinten, Motor_Rechts, Motor_Links, Count;
96
volatile unsigned char SenderOkay = 0;
96
volatile unsigned char SenderOkay = 0;
97
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
97
int StickNick = 0, StickRoll = 0, StickGier = 0, StickGas = 0;
98
char MotorenEin = 0;
98
char MotorenEin = 0;
99
int HoehenWert = 0;
99
int HoehenWert = 0;
100
int SollHoehe = 0;
100
int SollHoehe = 0;
101
int LageKorrekturRoll = 0,LageKorrekturNick = 0;
101
int LageKorrekturRoll = 0, LageKorrekturNick = 0;
102
float Ki =  FAKTOR_I;
102
float Ki = FAKTOR_I;
103
unsigned char Looping_Nick = 0,Looping_Roll = 0;
103
unsigned char Looping_Nick = 0, Looping_Roll = 0;
Line 104... Line 104...
104
unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0;
104
unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0;
105
 
105
 
106
unsigned char Parameter_Luftdruck_D  = 48;      // Wert : 0-250
106
unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250
107
unsigned char Parameter_MaxHoehe     = 251;      // Wert : 0-250
107
unsigned char Parameter_MaxHoehe = 251; // Wert : 0-250
108
unsigned char Parameter_Hoehe_P      = 16;      // Wert : 0-32
108
unsigned char Parameter_Hoehe_P = 16; // Wert : 0-32
109
unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250
109
unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250
110
unsigned char Parameter_KompassWirkung = 64;    // Wert : 0-250
110
unsigned char Parameter_KompassWirkung = 64; // Wert : 0-250
111
unsigned char Parameter_Gyro_P = 150;           // Wert : 10-250
111
unsigned char Parameter_Gyro_P = 150; // Wert : 10-250
112
unsigned char Parameter_Gyro_I = 150;           // Wert : 0-250
112
unsigned char Parameter_Gyro_I = 150; // Wert : 0-250
113
unsigned char Parameter_Gier_P = 2;             // Wert : 1-20
113
unsigned char Parameter_Gier_P = 2; // Wert : 1-20
114
unsigned char Parameter_I_Faktor = 10;          // Wert : 1-20
114
unsigned char Parameter_I_Faktor = 10; // Wert : 1-20
115
unsigned char Parameter_UserParam1 = 0;
115
unsigned char Parameter_UserParam1 = 0;
116
unsigned char Parameter_UserParam2 = 0;
116
unsigned char Parameter_UserParam2 = 0;
117
unsigned char Parameter_UserParam3 = 0;
117
unsigned char Parameter_UserParam3 = 0;
Line 123... Line 123...
123
unsigned char Parameter_ServoNickControl = 100;
123
unsigned char Parameter_ServoNickControl = 100;
124
unsigned char Parameter_LoopGasLimit = 70;
124
unsigned char Parameter_LoopGasLimit = 70;
125
unsigned char Parameter_AchsKopplung1 = 0;
125
unsigned char Parameter_AchsKopplung1 = 0;
126
unsigned char Parameter_AchsGegenKopplung1 = 0;
126
unsigned char Parameter_AchsGegenKopplung1 = 0;
127
unsigned char Parameter_DynamicStability = 100;
127
unsigned char Parameter_DynamicStability = 100;
128
unsigned char Parameter_J16Bitmask;             // for the J16 Output
128
unsigned char Parameter_J16Bitmask; // for the J16 Output
129
unsigned char Parameter_J16Timing;              // for the J16 Output
129
unsigned char Parameter_J16Timing; // for the J16 Output
130
unsigned char Parameter_J16Brightness;          // for the J16 Output
130
unsigned char Parameter_J16Brightness; // for the J16 Output
131
unsigned char Parameter_J17Bitmask;             // for the J17 Output
131
unsigned char Parameter_J17Bitmask; // for the J17 Output
132
unsigned char Parameter_J17Timing;              // for the J17 Output
132
unsigned char Parameter_J17Timing; // for the J17 Output
133
unsigned char Parameter_J17Brightness;          // for the J17 Output
133
unsigned char Parameter_J17Brightness; // for the J17 Output
134
unsigned char Parameter_NaviGpsModeControl;     // Parameters for the Naviboard
134
unsigned char Parameter_NaviGpsModeControl; // Parameters for the Naviboard
135
unsigned char Parameter_NaviGpsGain;
135
unsigned char Parameter_NaviGpsGain;
136
unsigned char Parameter_NaviGpsP;
136
unsigned char Parameter_NaviGpsP;
137
unsigned char Parameter_NaviGpsI;
137
unsigned char Parameter_NaviGpsI;
138
unsigned char Parameter_NaviGpsD;
138
unsigned char Parameter_NaviGpsD;
139
unsigned char Parameter_NaviGpsACC;
139
unsigned char Parameter_NaviGpsACC;
140
unsigned char Parameter_NaviOperatingRadius;
140
unsigned char Parameter_NaviOperatingRadius;
141
unsigned char Parameter_NaviWindCorrection;
141
unsigned char Parameter_NaviWindCorrection;
142
unsigned char Parameter_NaviSpeedCompensation;
142
unsigned char Parameter_NaviSpeedCompensation;
143
unsigned char Parameter_ExternalControl;
143
unsigned char Parameter_ExternalControl;
144
struct mk_param_struct EE_Parameter;
144
struct mk_param_struct EE_Parameter;
145
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
145
signed int ExternStickNick = 0, ExternStickRoll = 0, ExternStickGier = 0, ExternHoehenValue = -20;
146
int MaxStickNick = 0,MaxStickRoll = 0;
146
int MaxStickNick = 0, MaxStickRoll = 0;
147
unsigned int  modell_fliegt = 0;
147
unsigned int modell_fliegt = 0;
148
unsigned char MikroKopterFlags = 0;
148
unsigned char MikroKopterFlags = 0;
Line 149... Line 149...
149
 
149
 
150
void Piep(unsigned char Anzahl)
-
 
151
{
150
void Piep(unsigned char Anzahl) {
152
 while(Anzahl--)
-
 
153
 {
151
    while (Anzahl--) {
154
  if(MotorenEin) return; //auf keinen Fall im Flug!
152
        if (MotorenEin) return; //auf keinen Fall im Flug!
155
  beeptime = 100;
153
        beeptime = 100;
156
  Delay_ms(250);
154
        Delay_ms(250);
157
 }
155
    }
Line 158... Line 156...
158
}
156
}
159
 
157
 
-
 
158
//############################################################################
160
//############################################################################
159
//  Nullwerte ermitteln
161
//  Nullwerte ermitteln
160
 
162
void SetNeutral(void)
161
void SetNeutral(void)
163
//############################################################################
162
//############################################################################
164
{
163
{
165
        NeutralAccX = 0;
164
    NeutralAccX = 0;
166
        NeutralAccY = 0;
165
    NeutralAccY = 0;
167
        NeutralAccZ = 0;
166
    NeutralAccZ = 0;
168
    AdNeutralNick = 0;
167
    AdNeutralNick = 0;
169
        AdNeutralRoll = 0;
168
    AdNeutralRoll = 0;
170
        AdNeutralGier = 0;
169
    AdNeutralGier = 0;
171
    AdNeutralGierBias = 0;
170
    AdNeutralGierBias = 0;
172
    Parameter_AchsKopplung1 = 0;
171
    Parameter_AchsKopplung1 = 0;
173
    Parameter_AchsGegenKopplung1 = 0;
172
    Parameter_AchsGegenKopplung1 = 0;
174
    ExpandBaro = 0;
173
    ExpandBaro = 0;
175
    CalibrierMittelwert();
174
    CalibrierMittelwert();
176
    Delay_ms_Mess(100);
175
    Delay_ms_Mess(100);
177
        CalibrierMittelwert();
-
 
178
    if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
-
 
179
     {
-
 
180
      if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
-
 
181
     }
-
 
182
 
-
 
183
     AdNeutralNick= AdWertNick;
-
 
184
         AdNeutralRoll= AdWertRoll;
-
 
185
         AdNeutralGier= AdWertGier;
-
 
186
     AdNeutralGierBias = AdWertGier;
-
 
187
     StartNeutralRoll = AdNeutralRoll;
-
 
188
     StartNeutralNick = AdNeutralNick;
176
    CalibrierMittelwert();
189
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
177
    if ((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert?
190
    {
-
 
191
      NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY;
-
 
192
          NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY;
178
    {
-
 
179
        if ((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
-
 
180
    }
-
 
181
 
193
          NeutralAccZ = Aktuell_az;
182
    AdNeutralNick = AdWertNick;
-
 
183
    AdNeutralRoll = AdWertRoll;
-
 
184
    AdNeutralGier = AdWertGier;
-
 
185
    AdNeutralGierBias = AdWertGier;
-
 
186
    StartNeutralRoll = AdNeutralRoll;
-
 
187
    StartNeutralNick = AdNeutralNick;
-
 
188
    if (eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) {
-
 
189
        NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY;
194
    }
190
        NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY;
195
    else
191
        NeutralAccZ = Aktuell_az;
196
    {
192
    } else {
197
      NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]);
193
        NeutralAccX = (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK + 1]);
198
          NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]);
194
        NeutralAccY = (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL + 1]);
Line 199... Line 195...
199
          NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]);
195
        NeutralAccZ = (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int) eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z + 1]);
200
    }
196
    }
201
 
197
 
202
        Mess_IntegralNick = 0;
198
    Mess_IntegralNick = 0;
203
    Mess_IntegralNick2 = 0;
199
    Mess_IntegralNick2 = 0;
204
    Mess_IntegralRoll = 0;
200
    Mess_IntegralRoll = 0;
205
    Mess_IntegralRoll2 = 0;
201
    Mess_IntegralRoll2 = 0;
206
    Mess_Integral_Gier = 0;
202
    Mess_Integral_Gier = 0;
207
    MesswertNick = 0;
203
    MesswertNick = 0;
208
    MesswertRoll = 0;
204
    MesswertRoll = 0;
209
    MesswertGier = 0;
205
    MesswertGier = 0;
210
 Delay_ms_Mess(100);
206
    Delay_ms_Mess(100);
211
    StartLuftdruck = Luftdruck;
207
    StartLuftdruck = Luftdruck;
212
    HoeheD = 0;
208
    HoeheD = 0;
213
    Mess_Integral_Hoch = 0;
209
    Mess_Integral_Hoch = 0;
214
    KompassStartwert = KompassValue;
210
    KompassStartwert = KompassValue;
215
    GPS_Neutral();
211
    GPS_Neutral();
216
    beeptime = 50;
212
    beeptime = 50;
217
        Umschlag180Nick = ((long) EE_Parameter.WinkelUmschlagNick * 2500L) + 15000L;
213
    Umschlag180Nick = ((long) EE_Parameter.WinkelUmschlagNick * 2500L) + 15000L;
218
        Umschlag180Roll = ((long) EE_Parameter.WinkelUmschlagRoll * 2500L) + 15000L;
214
    Umschlag180Roll = ((long) EE_Parameter.WinkelUmschlagRoll * 2500L) + 15000L;
219
    ExternHoehenValue = 0;
215
    ExternHoehenValue = 0;
220
    ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
216
    ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
Line 225... Line 221...
225
    FromNaviCtrl_Value.Kalman_K = -1;
221
    FromNaviCtrl_Value.Kalman_K = -1;
226
    FromNaviCtrl_Value.Kalman_MaxDrift = EE_Parameter.Driftkomp * 16;
222
    FromNaviCtrl_Value.Kalman_MaxDrift = EE_Parameter.Driftkomp * 16;
227
    FromNaviCtrl_Value.Kalman_MaxFusion = 32;
223
    FromNaviCtrl_Value.Kalman_MaxFusion = 32;
228
}
224
}
Line -... Line 225...
-
 
225
 
-
 
226
void LesePotis(void) {
-
 
227
    /*  Warum 110? Knüppel geht von -125 bis 125!
-
 
228
        if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
-
 
229
        if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
-
 
230
        if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
-
 
231
        if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
-
 
232
     */
-
 
233
    if (Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 125) Poti1++;
-
 
234
    else if (Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 125 && Poti1) Poti1--;
-
 
235
    if (Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 125) Poti2++;
-
 
236
    else if (Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 125 && Poti2) Poti2--;
-
 
237
    if (Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 125) Poti3++;
-
 
238
    else if (Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 125 && Poti3) Poti3--;
-
 
239
    if (Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 125) Poti4++;
-
 
240
    else if (Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 125 && Poti4) Poti4--;
-
 
241
    if (Poti1 < 0) Poti1 = 0;
-
 
242
    else if (Poti1 > 255) Poti1 = 255;
-
 
243
    if (Poti2 < 0) Poti2 = 0;
-
 
244
    else if (Poti2 > 255) Poti2 = 255;
-
 
245
    if (Poti3 < 0) Poti3 = 0;
-
 
246
    else if (Poti3 > 255) Poti3 = 255;
-
 
247
    if (Poti4 < 0) Poti4 = 0;
-
 
248
    else if (Poti4 > 255) Poti4 = 255;
-
 
249
}
229
 
250
 
230
//############################################################################
251
//############################################################################
-
 
252
// Bearbeitet die Messwerte
231
// Bearbeitet die Messwerte
253
 
232
void Mittelwert(void)
254
void Mittelwert(void)
233
//############################################################################
255
//############################################################################
234
{
256
{
235
    static signed long tmpl,tmpl2;
257
    static signed long tmpl, tmpl2;
236
    MesswertGier = (signed int) AdNeutralGier - AdWertGier;
258
    MesswertGier = (signed int) AdNeutralGier - AdWertGier;
237
    MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier;
259
    MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier;
238
    MesswertRoll = (signed int) AdWertRoll - AdNeutralRoll;
260
    MesswertRoll = (signed int) AdWertRoll - AdNeutralRoll;
Line 239... Line 261...
239
    MesswertNick = (signed int) AdWertNick - AdNeutralNick;
261
    MesswertNick = (signed int) AdWertNick - AdNeutralNick;
240
 
262
 
Line 241... Line 263...
241
//DebugOut.Analog[26] = MesswertNick;
263
    //DebugOut.Analog[26] = MesswertNick;
242
// DebugOut.Analog[28] = MesswertRoll;
264
    // DebugOut.Analog[28] = MesswertRoll;
243
 
265
 
244
// Beschleunigungssensor  ++++++++++++++++++++++++++++++++++++++++++++++++
266
    // Beschleunigungssensor  ++++++++++++++++++++++++++++++++++++++++++++++++
245
        Mittelwert_AccNick = ((long)Mittelwert_AccNick * 1 + ((ACC_AMPLIFY * (long)AdWertAccNick))) / 2L;
267
    Mittelwert_AccNick = ((long) Mittelwert_AccNick * 1 + ((ACC_AMPLIFY * (long) AdWertAccNick))) / 2L;
246
        Mittelwert_AccRoll = ((long)Mittelwert_AccRoll * 1 + ((ACC_AMPLIFY * (long)AdWertAccRoll))) / 2L;
268
    Mittelwert_AccRoll = ((long) Mittelwert_AccRoll * 1 + ((ACC_AMPLIFY * (long) AdWertAccRoll))) / 2L;
247
        Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdWertAccHoch)) / 2L;
269
    Mittelwert_AccHoch = ((long) Mittelwert_AccHoch * 1 + ((long) AdWertAccHoch)) / 2L;
248
    IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
270
    IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
249
    IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
271
    IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
250
    NaviAccNick    += AdWertAccNick;
272
    NaviAccNick += AdWertAccNick;
251
    NaviAccRoll    += AdWertAccRoll;
273
    NaviAccRoll += AdWertAccRoll;
252
    NaviCntAcc++;
274
    NaviCntAcc++;
253
    IntegralAccZ    += Aktuell_az - NeutralAccZ;
275
    IntegralAccZ += Aktuell_az - NeutralAccZ;
254
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
276
    // Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
255
            ErsatzKompass +=  MesswertGier;
277
    ErsatzKompass += MesswertGier;
256
            Mess_Integral_Gier +=  MesswertGier;
278
    Mess_Integral_Gier += MesswertGier;
257
//            Mess_Integral_Gier2 += MesswertGier;
279
    //            Mess_Integral_Gier2 += MesswertGier;
258
                    if(ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR;  // 360° Umschlag
280
    if (ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR; // 360° Umschlag
259
                    if(ErsatzKompass < 0)                          ErsatzKompass += 360L * GIER_GRAD_FAKTOR;
-
 
260
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
281
    if (ErsatzKompass < 0) ErsatzKompass += 360L * GIER_GRAD_FAKTOR;
261
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
282
    // Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
262
         {
283
    if (!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) {
263
            tmpl = (MesswertGierBias * Mess_IntegralNick) / 2048L;
284
        tmpl = (MesswertGierBias * Mess_IntegralNick) / 2048L;
264
            tmpl *= Parameter_AchsKopplung1;  //125
285
        tmpl *= Parameter_AchsKopplung1; //125
265
            tmpl /= 4096L;
286
        tmpl /= 4096L;
266
            tmpl2 = (MesswertGierBias * Mess_IntegralRoll) / 2048L;
287
        tmpl2 = (MesswertGierBias * Mess_IntegralRoll) / 2048L;
267
            tmpl2 *= Parameter_AchsKopplung1;
-
 
268
            tmpl2 /= 4096L;
288
        tmpl2 *= Parameter_AchsKopplung1;
269
            if(labs(tmpl) > 128 || labs(tmpl2) > 128) TrichterFlug = 1;
289
        tmpl2 /= 4096L;
270
         }
290
        if (labs(tmpl) > 128 || labs(tmpl2) > 128) TrichterFlug = 1;
271
      else  tmpl = tmpl2 = 0;
291
    } else tmpl = tmpl2 = 0;
272
// Roll  ++++++++++++++++++++++++++++++++++++++++++++++++
292
    // Roll  ++++++++++++++++++++++++++++++++++++++++++++++++
273
            MesswertRoll += tmpl;
293
    MesswertRoll += tmpl;
274
            MesswertRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109
294
    MesswertRoll += (tmpl2 * Parameter_AchsGegenKopplung1) / 512L; //109
275
            Mess_IntegralRoll2 += MesswertRoll;
-
 
276
            Mess_IntegralRoll +=  MesswertRoll - LageKorrekturRoll;
295
    Mess_IntegralRoll2 += MesswertRoll;
277
            if(Mess_IntegralRoll > Umschlag180Roll)
296
    Mess_IntegralRoll += MesswertRoll - LageKorrekturRoll;
278
            {
297
    if (Mess_IntegralRoll > Umschlag180Roll) {
279
             Mess_IntegralRoll  = -(Umschlag180Roll - 25000L);
298
        Mess_IntegralRoll = -(Umschlag180Roll - 25000L);
280
             Mess_IntegralRoll2 = Mess_IntegralRoll;
-
 
281
            }
299
        Mess_IntegralRoll2 = Mess_IntegralRoll;
282
            if(Mess_IntegralRoll <-Umschlag180Roll)
300
    }
283
            {
301
    if (Mess_IntegralRoll <-Umschlag180Roll) {
284
             Mess_IntegralRoll =  (Umschlag180Roll - 25000L);
302
        Mess_IntegralRoll = (Umschlag180Roll - 25000L);
285
             Mess_IntegralRoll2 = Mess_IntegralRoll;
303
        Mess_IntegralRoll2 = Mess_IntegralRoll;
286
            }
304
    }
287
            if(AdWertRoll < 15)   MesswertRoll = -1000;
-
 
288
            if(AdWertRoll <  7)   MesswertRoll = -2000;
305
    if (AdWertRoll < 15) MesswertRoll = -1000;
289
            if(PlatinenVersion == 10)
306
    if (AdWertRoll < 7) MesswertRoll = -2000;
290
                         {
-
 
291
              if(AdWertRoll > 1010) MesswertRoll = +1000;
307
    if (PlatinenVersion == 10) {
292
              if(AdWertRoll > 1017) MesswertRoll = +2000;
-
 
293
                         }
308
        if (AdWertRoll > 1010) MesswertRoll = +1000;
294
                         else
309
        if (AdWertRoll > 1017) MesswertRoll = +2000;
295
                         {
310
    } else {
296
              if(AdWertRoll > 2020) MesswertRoll = +1000;
311
        if (AdWertRoll > 2020) MesswertRoll = +1000;
297
              if(AdWertRoll > 2034) MesswertRoll = +2000;
312
        if (AdWertRoll > 2034) MesswertRoll = +2000;
298
                         }
313
    }
299
// Nick  ++++++++++++++++++++++++++++++++++++++++++++++++
314
    // Nick  ++++++++++++++++++++++++++++++++++++++++++++++++
300
            MesswertNick -= tmpl2;
315
    MesswertNick -= tmpl2;
301
            MesswertNick -= (tmpl*Parameter_AchsGegenKopplung1)/512L;
316
    MesswertNick -= (tmpl * Parameter_AchsGegenKopplung1) / 512L;
302
            Mess_IntegralNick2 += MesswertNick;
317
    Mess_IntegralNick2 += MesswertNick;
303
            Mess_IntegralNick  += MesswertNick - LageKorrekturNick;
-
 
304
 
318
    Mess_IntegralNick += MesswertNick - LageKorrekturNick;
305
            if(Mess_IntegralNick > Umschlag180Nick)
319
 
306
             {
320
    if (Mess_IntegralNick > Umschlag180Nick) {
307
              Mess_IntegralNick = -(Umschlag180Nick - 25000L);
321
        Mess_IntegralNick = -(Umschlag180Nick - 25000L);
308
              Mess_IntegralNick2 = Mess_IntegralNick;
-
 
309
             }
322
        Mess_IntegralNick2 = Mess_IntegralNick;
310
            if(Mess_IntegralNick <-Umschlag180Nick)
323
    }
311
            {
324
    if (Mess_IntegralNick <-Umschlag180Nick) {
312
             Mess_IntegralNick =  (Umschlag180Nick - 25000L);
325
        Mess_IntegralNick = (Umschlag180Nick - 25000L);
313
             Mess_IntegralNick2 = Mess_IntegralNick;
326
        Mess_IntegralNick2 = Mess_IntegralNick;
314
            }
327
    }
315
            if(AdWertNick < 15)   MesswertNick = -1000;
-
 
316
            if(AdWertNick <  7)   MesswertNick = -2000;
328
    if (AdWertNick < 15) MesswertNick = -1000;
317
            if(PlatinenVersion == 10)
329
    if (AdWertNick < 7) MesswertNick = -2000;
318
                         {
-
 
319
              if(AdWertNick > 1010) MesswertNick = +1000;
330
    if (PlatinenVersion == 10) {
320
              if(AdWertNick > 1017) MesswertNick = +2000;
-
 
321
                         }
331
        if (AdWertNick > 1010) MesswertNick = +1000;
322
                         else
332
        if (AdWertNick > 1017) MesswertNick = +2000;
323
                         {
333
    } else {
324
              if(AdWertNick > 2020) MesswertNick = +1000;
334
        if (AdWertNick > 2020) MesswertNick = +1000;
325
              if(AdWertNick > 2034) MesswertNick = +2000;
335
        if (AdWertNick > 2034) MesswertNick = +2000;
326
                         }
336
    }
327
//++++++++++++++++++++++++++++++++++++++++++++++++
337
    //++++++++++++++++++++++++++++++++++++++++++++++++
Line 328... Line 338...
328
// ADC einschalten
338
    // ADC einschalten
329
    ANALOG_ON;
339
    ANALOG_ON;
330
//++++++++++++++++++++++++++++++++++++++++++++++++
340
    //++++++++++++++++++++++++++++++++++++++++++++++++
331
 
341
 
332
    Integral_Gier  = Mess_Integral_Gier;
342
    Integral_Gier = Mess_Integral_Gier;
Line 333... Line 343...
333
    IntegralNick = Mess_IntegralNick;
343
    IntegralNick = Mess_IntegralNick;
334
    IntegralRoll = Mess_IntegralRoll;
-
 
335
    IntegralNick2 = Mess_IntegralNick2;
344
    IntegralRoll = Mess_IntegralRoll;
336
    IntegralRoll2 = Mess_IntegralRoll2;
345
    IntegralNick2 = Mess_IntegralNick2;
337
 
346
    IntegralRoll2 = Mess_IntegralRoll2;
338
  if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll)
347
 
339
  {
348
    if (EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) {
340
    if(MesswertNick > 200)       MesswertNick += 4 * (MesswertNick - 200);
-
 
341
    else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200);
-
 
342
    if(MesswertRoll > 200)       MesswertRoll += 4 * (MesswertRoll - 200);
-
 
343
    else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200);
-
 
344
  }
-
 
345
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
-
 
346
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
-
 
347
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
349
        if (MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200);
348
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
350
        else if (MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200);
Line 349... Line 351...
349
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
351
        if (MesswertRoll > 200) MesswertRoll += 4 * (MesswertRoll - 200);
350
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
352
        else if (MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200);
-
 
353
    }
351
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
354
    LesePotis();
352
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
355
}
353
}
356
 
354
 
357
//############################################################################
355
//############################################################################
358
// Messwerte beim Ermitteln der Nullage
356
// Messwerte beim Ermitteln der Nullage
359
 
357
void CalibrierMittelwert(void)
360
void CalibrierMittelwert(void)
358
//############################################################################
361
//############################################################################
359
{
362
{
360
    if(PlatinenVersion == 13) SucheGyroOffset();
363
    if (PlatinenVersion == 13) SucheGyroOffset();
361
    // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern
364
    // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern
362
        ANALOG_OFF;
365
    ANALOG_OFF;
363
        MesswertNick = AdWertNick;
366
    MesswertNick = AdWertNick;
364
        MesswertRoll = AdWertRoll;
367
    MesswertRoll = AdWertRoll;
365
        MesswertGier = AdWertGier;
-
 
366
        Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick;
-
 
367
        Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll;
-
 
368
        Mittelwert_AccHoch = (long)AdWertAccHoch;
-
 
369
   // ADC einschalten
-
 
370
    ANALOG_ON;
-
 
371
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
-
 
372
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
-
 
Line -... Line 368...
-
 
368
    MesswertGier = AdWertGier;
-
 
369
    Mittelwert_AccNick = ACC_AMPLIFY * (long) AdWertAccNick;
373
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
370
    Mittelwert_AccRoll = ACC_AMPLIFY * (long) AdWertAccRoll;
374
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
371
    Mittelwert_AccHoch = (long) AdWertAccHoch;
375
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
372
    // ADC einschalten
Line 376... Line 373...
376
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
373
    ANALOG_ON;
377
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
374
 
-
 
375
    LesePotis();
378
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
376
 
379
 
377
    Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
380
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
378
    Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
381
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
379
}
382
}
380
 
383
 
381
//############################################################################
384
//############################################################################
382
// Senden der Motorwerte per I2C-Bus
Line 385... Line 383...
385
// Senden der Motorwerte per I2C-Bus
383
 
386
void SendMotorData(void)
-
 
387
//############################################################################
384
void SendMotorData(void)
388
{
385
//############################################################################
389
    DebugOut.Analog[12] = Motor_Vorne;
386
{
390
    DebugOut.Analog[13] = Motor_Hinten;
387
    DebugOut.Analog[12] = Motor_Vorne;
391
    DebugOut.Analog[14] = Motor_Links;
388
    DebugOut.Analog[13] = Motor_Hinten;
392
    DebugOut.Analog[15] = Motor_Rechts;  
389
    DebugOut.Analog[14] = Motor_Links;
393
 
390
    DebugOut.Analog[15] = Motor_Rechts;
394
    if(!( MotorenEin && PARAM_ENGINE_ENABLED ) )
391
 
395
        {
392
    if (!(MotorenEin && PARAM_ENGINE_ENABLED)) {
396
        Motor_Hinten = 0;
393
        Motor_Hinten = 0;
Line 397... Line 394...
397
        Motor_Vorne = 0;
394
        Motor_Vorne = 0;
398
        Motor_Rechts = 0;
395
        Motor_Rechts = 0;
399
        Motor_Links = 0;
396
        Motor_Links = 0;
400
        if(MotorTest[0]) Motor_Vorne = MotorTest[0];
397
        if (MotorTest[0]) Motor_Vorne = MotorTest[0];
Line 412... Line 409...
412
 
409
 
413
 
410
 
-
 
411
 
414
 
412
//############################################################################
415
//############################################################################
413
// Trägt ggf. das Poti als Parameter ein
416
// Trägt ggf. das Poti als Parameter ein
414
 
417
void ParameterZuordnung(void)
415
void ParameterZuordnung(void)
418
//############################################################################
416
//############################################################################
419
{
417
{
420
 #define CHK_POTI_MM(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; if(b <= min) b = min; else if(b >= max) b = max;}
418
#define CHK_POTI_MM(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; if(b <= min) b = min; else if(b >= max) b = max;}
421
 #define CHK_POTI(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; }
419
#define CHK_POTI(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; }
422
 CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe,0,255);
420
    CHK_POTI(Parameter_MaxHoehe, EE_Parameter.MaxHoehe, 0, 255);
423
 CHK_POTI_MM(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100);
421
    CHK_POTI_MM(Parameter_Luftdruck_D, EE_Parameter.Luftdruck_D, 0, 100);
424
 CHK_POTI_MM(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100);
422
    CHK_POTI_MM(Parameter_Hoehe_P, EE_Parameter.Hoehe_P, 0, 100);
425
 CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255);
423
    CHK_POTI(Parameter_Hoehe_ACC_Wirkung, EE_Parameter.Hoehe_ACC_Wirkung, 0, 255);
426
 CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255);
424
    CHK_POTI(Parameter_KompassWirkung, EE_Parameter.KompassWirkung, 0, 255);
427
 CHK_POTI_MM(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255);
425
    CHK_POTI_MM(Parameter_Gyro_P, EE_Parameter.Gyro_P, 10, 255);
428
 CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255);
426
    CHK_POTI(Parameter_Gyro_I, EE_Parameter.Gyro_I, 0, 255);
429
 CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255);
427
    CHK_POTI(Parameter_I_Faktor, EE_Parameter.I_Faktor, 0, 255);
430
 CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255);
428
    CHK_POTI(Parameter_UserParam1, EE_Parameter.UserParam1, 0, 255);
431
 CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255);
429
    CHK_POTI(Parameter_UserParam2, EE_Parameter.UserParam2, 0, 255);
432
 CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255);
430
    CHK_POTI(Parameter_UserParam3, EE_Parameter.UserParam3, 0, 255);
433
 CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255);
431
    CHK_POTI(Parameter_UserParam4, EE_Parameter.UserParam4, 0, 255);
434
 CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255);
432
    CHK_POTI(Parameter_UserParam5, EE_Parameter.UserParam5, 0, 255);
435
 CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255);
433
    CHK_POTI(Parameter_UserParam6, EE_Parameter.UserParam6, 0, 255);
436
 CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255);
434
    CHK_POTI(Parameter_UserParam7, EE_Parameter.UserParam7, 0, 255);
437
 CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255);
435
    CHK_POTI(Parameter_UserParam8, EE_Parameter.UserParam8, 0, 255);
438
 CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255);
436
    CHK_POTI(Parameter_ServoNickControl, EE_Parameter.ServoNickControl, 0, 255);
439
 CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255);
437
    CHK_POTI(Parameter_LoopGasLimit, EE_Parameter.LoopGasLimit, 0, 255);
440
 CHK_POTI(Parameter_AchsKopplung1,    EE_Parameter.AchsKopplung1,0,255);
438
    CHK_POTI(Parameter_AchsKopplung1, EE_Parameter.AchsKopplung1, 0, 255);
441
 CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255);
439
    CHK_POTI(Parameter_AchsGegenKopplung1, EE_Parameter.AchsGegenKopplung1, 0, 255);
442
 CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255);
440
    CHK_POTI(Parameter_DynamicStability, EE_Parameter.DynamicStability, 0, 255);
443
 
441
 
444
 CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255);
442
    CHK_POTI_MM(Parameter_J16Timing, EE_Parameter.J16Timing, 1, 255);
445
 CHK_POTI_MM(Parameter_J16Brightness,PARAM_LED_BRIGHTNESS_J16,0,250);
443
    CHK_POTI_MM(Parameter_J16Brightness, PARAM_LED_BRIGHTNESS_J16, 0, 250);
446
 CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255);
444
    CHK_POTI_MM(Parameter_J17Timing, EE_Parameter.J17Timing, 1, 255);
447
 CHK_POTI_MM(Parameter_J17Brightness,PARAM_LED_BRIGHTNESS_J17,0,250);
445
    CHK_POTI_MM(Parameter_J17Brightness, PARAM_LED_BRIGHTNESS_J17, 0, 250);
448
 
446
 
449
// CHK_POTI(Parameter_NaviGpsModeControl,EE_Parameter.NaviGpsModeControl,0,255);
447
    // CHK_POTI(Parameter_NaviGpsModeControl,EE_Parameter.NaviGpsModeControl,0,255);
450
 //CHK_POTI(Parameter_NaviGpsGain,EE_Parameter.NaviGpsGain,0,255);
448
    //CHK_POTI(Parameter_NaviGpsGain,EE_Parameter.NaviGpsGain,0,255);
451
// CHK_POTI(Parameter_NaviGpsP,EE_Parameter.NaviGpsP,0,255);
449
    // CHK_POTI(Parameter_NaviGpsP,EE_Parameter.NaviGpsP,0,255);
452
// CHK_POTI(Parameter_NaviGpsI,EE_Parameter.NaviGpsI,0,255);
450
    // CHK_POTI(Parameter_NaviGpsI,EE_Parameter.NaviGpsI,0,255);
453
// CHK_POTI(Parameter_NaviGpsD,EE_Parameter.NaviGpsD,0,255);
451
    // CHK_POTI(Parameter_NaviGpsD,EE_Parameter.NaviGpsD,0,255);
454
// CHK_POTI(Parameter_NaviGpsACC,EE_Parameter.NaviGpsACC,0,255);
452
    // CHK_POTI(Parameter_NaviGpsACC,EE_Parameter.NaviGpsACC,0,255);
455
// CHK_POTI_MM(Parameter_NaviOperatingRadius,EE_Parameter.NaviOperatingRadius,10,255);
453
    // CHK_POTI_MM(Parameter_NaviOperatingRadius,EE_Parameter.NaviOperatingRadius,10,255);
456
// CHK_POTI(Parameter_NaviWindCorrection,EE_Parameter.NaviWindCorrection,0,255);
454
    // CHK_POTI(Parameter_NaviWindCorrection,EE_Parameter.NaviWindCorrection,0,255);
457
// CHK_POTI(Parameter_NaviSpeedCompensation,EE_Parameter.NaviSpeedCompensation,0,255);
455
    // CHK_POTI(Parameter_NaviSpeedCompensation,EE_Parameter.NaviSpeedCompensation,0,255);
458
 
456
 
459
 CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255);
457
    CHK_POTI(Parameter_ExternalControl, EE_Parameter.ExternalControl, 0, 255);
460
 
458
 
461
 Ki = (float) Parameter_I_Faktor * 0.0001;
459
    Ki = (float) Parameter_I_Faktor * 0.0001;
Line 462... Line 460...
462
 MAX_GAS = EE_Parameter.Gas_Max;
460
    MAX_GAS = EE_Parameter.Gas_Max;
463
 MIN_GAS = EE_Parameter.Gas_Min;
461
    MIN_GAS = EE_Parameter.Gas_Min;
-
 
462
}
464
}
463
 
465
 
464
 
466
 
465
 
467
 
466
//############################################################################
468
//############################################################################
467
//
469
//
468
 
470
void MotorRegler(void)
469
void MotorRegler(void)
471
//############################################################################
470
//############################################################################
472
{
471
{
473
         int motorwert,pd_ergebnis,tmp_int;
472
    int motorwert, pd_ergebnis, tmp_int;
474
         int GierMischanteil,GasMischanteil;
473
    int GierMischanteil, GasMischanteil;
475
     static long SummeNick=0,SummeRoll=0;
474
    static long SummeNick = 0, SummeRoll = 0;
476
     static long sollGier = 0,tmp_long,tmp_long2;
475
    static long sollGier = 0, tmp_long, tmp_long2;
477
     static long IntegralFehlerNick = 0;
476
    static long IntegralFehlerNick = 0;
478
     static long IntegralFehlerRoll = 0;
477
    static long IntegralFehlerRoll = 0;
Line 479... Line 478...
479
         static unsigned int RcLostTimer;
478
    static unsigned int RcLostTimer;
Line 480... Line 479...
480
         static unsigned char delay_neutral = 0;
479
    static unsigned char delay_neutral = 0;
481
         static unsigned char delay_einschalten = 0,delay_ausschalten = 0;
480
    static unsigned char delay_einschalten = 0, delay_ausschalten = 0;
482
     static char TimerWerteausgabe = 0;
481
    static char TimerWerteausgabe = 0;
483
     static char NeueKompassRichtungMerken = 0;
482
    static char NeueKompassRichtungMerken = 0;
484
     static long ausgleichNick, ausgleichRoll;
483
    static long ausgleichNick, ausgleichRoll;
485
 
484
 
486
        Mittelwert();
485
    Mittelwert();
487
 
486
 
488
    GRN_ON;
487
    GRN_ON;
489
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
490
// Gaswert ermitteln
488
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
491
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
492
        GasMischanteil = StickGas;
489
    // Gaswert ermitteln
493
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
494
// Empfang schlecht
490
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
495
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
491
    GasMischanteil = StickGas;
496
   if(SenderOkay < 100)
492
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
497
        {
493
    // Empfang schlecht
498
        if(!PcZugriff)
494
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
499
         {
495
    if (SenderOkay < 100) {
500
           if(BeepMuster == 0xffff)
-
 
501
            {
496
        if (!PcZugriff) {
502
             beeptime = 15000;
497
            if (BeepMuster == 0xffff) {
503
             BeepMuster = 0x0c00;
498
                beeptime = 15000;
504
            }
499
                BeepMuster = 0x0c00;
505
         }
500
            }
506
        if(RcLostTimer) RcLostTimer--;
501
        }
507
        else
502
        if (RcLostTimer) RcLostTimer--;
508
         {
503
        else {
509
          MotorenEin = 0;
504
            MotorenEin = 0;
510
          Notlandung = 0;
505
            Notlandung = 0;
511
         }
506
        }
512
        ROT_ON;
507
        ROT_ON;
513
        if(modell_fliegt > 1000)  // wahrscheinlich in der Luft --> langsam absenken
508
        if (modell_fliegt > 1000) // wahrscheinlich in der Luft --> langsam absenken
-
 
509
        {
-
 
510
            GasMischanteil = EE_Parameter.NotGas;
-
 
511
            Notlandung = 1;
514
            {
512
            PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
-
 
513
            PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
-
 
514
            PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
515
            GasMischanteil = EE_Parameter.NotGas;
515
            PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
-
 
516
            PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
-
 
517
        } else MotorenEin = 0;
-
 
518
    } else
516
            Notlandung = 1;
519
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
517
            PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
-
 
518
            PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
-
 
519
            PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
-
 
520
            PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
-
 
521
            PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
-
 
522
            }
-
 
523
         else MotorenEin = 0;
-
 
524
        }
-
 
525
        else
-
 
526
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
527
// Emfang gut
-
 
528
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
529
        if(SenderOkay > 140)
520
        // Emfang gut
530
            {
-
 
531
            Notlandung = 0;
521
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
532
            RcLostTimer = EE_Parameter.NotGasZeit * 50;
522
        if (SenderOkay > 140) {
533
            if(GasMischanteil > 40 && MotorenEin)
523
        Notlandung = 0;
534
                {
-
 
535
                if(modell_fliegt < 0xffff) modell_fliegt++;
524
        RcLostTimer = EE_Parameter.NotGasZeit * 50;
536
                }
525
        if (GasMischanteil > 40 && MotorenEin) {
537
            if((modell_fliegt < 256))
526
            if (modell_fliegt < 0xffff) modell_fliegt++;
538
                {
527
        }
539
                SummeNick = 0;
528
        if ((modell_fliegt < 256)) {
540
                SummeRoll = 0;
529
            SummeNick = 0;
Line 541... Line 530...
541
                if(modell_fliegt == 250)
530
            SummeRoll = 0;
-
 
531
            if (modell_fliegt == 250) {
-
 
532
                NeueKompassRichtungMerken = 1;
-
 
533
                sollGier = 0;
-
 
534
                Mess_Integral_Gier = 0;
-
 
535
                //                  Mess_Integral_Gier2 = 0;
-
 
536
            }
542
                 {
537
        } else MikroKopterFlags |= FLAG_FLY;
543
                  NeueKompassRichtungMerken = 1;
-
 
544
                  sollGier = 0;
-
 
545
                  Mess_Integral_Gier = 0;
-
 
546
//                  Mess_Integral_Gier2 = 0;
-
 
547
                 }
-
 
548
                } else MikroKopterFlags |= FLAG_FLY;
-
 
549
 
-
 
550
            if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0)
538
 
551
                {
539
        if ((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) {
552
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
540
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
553
// auf Nullwerte kalibrieren
541
            // auf Nullwerte kalibrieren
554
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
542
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
555
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
-
 
556
                    {
543
            if (PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) // Neutralwerte
557
                    if(++delay_neutral > 200)  // nicht sofort
544
            {
558
                        {
545
                if (++delay_neutral > 200) // nicht sofort
559
                        GRN_OFF;
546
                {
560
                        MotorenEin = 0;
547
                    GRN_OFF;
561
                        delay_neutral = 0;
548
                    MotorenEin = 0;
562
                        modell_fliegt = 0;
549
                    delay_neutral = 0;
563
                        if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70)
-
 
564
                        {
-
 
565
                         unsigned char setting=1;
-
 
566
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1;
-
 
567
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2;
-
 
568
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
-
 
569
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
-
 
570
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
-
 
571
                         SetActiveParamSetNumber(setting);  // aktiven Datensatz merken
-
 
572
                        }
-
 
573
//                        else
-
 
574
                         if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 30 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70)
-
 
575
                          {
-
 
576
                           WinkelOut.CalcState = 1;
-
 
577
                           beeptime = 1000;
-
 
578
                          }
-
 
579
                          else
-
 
580
                          {
-
 
581
                               ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
550
                    modell_fliegt = 0;
582
                           if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
551
                    if (PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70) {
583
                            {
552
                        unsigned char setting = 1;
-
 
553
                        if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1;
-
 
554
                        if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2;
584
                             if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
555
                        if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
-
 
556
                        if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
585
                            }
557
                        if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
586
                           SetNeutral();
558
                        SetActiveParamSetNumber(setting); // aktiven Datensatz merken
587
                           Piep(GetActiveParamSetNumber());
-
 
588
                         }
559
                    }
589
                        }
560
                    //                        else
590
                    }
-
 
591
                 else
-
 
592
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
561
                    if (abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 30 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70) {
593
                    {
-
 
594
                    if(++delay_neutral > 200)  // nicht sofort
-
 
595
                        {
-
 
596
                        GRN_OFF;
-
 
597
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],0xff); // Werte löschen
-
 
598
                        MotorenEin = 0;
-
 
599
                        delay_neutral = 0;
562
                        WinkelOut.CalcState = 1;
600
                        modell_fliegt = 0;
-
 
601
                        SetNeutral();
563
                        beeptime = 1000;
602
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],NeutralAccX / 256); // ACC-NeutralWerte speichern
-
 
603
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1],NeutralAccX % 256); // ACC-NeutralWerte speichern
564
                    } else {
604
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL],NeutralAccY / 256);
-
 
605
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256);
565
                        ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) & EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
606
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256);
566
                        if ((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert?
-
 
567
                        {
607
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256);
568
                            if ((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
608
                        Piep(GetActiveParamSetNumber());
569
                        }
609
                        }
570
                        SetNeutral();
-
 
571
                        Piep(GetActiveParamSetNumber());
-
 
572
                    }
-
 
573
                }
-
 
574
            } else
-
 
575
                if (PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern
-
 
576
            {
-
 
577
                if (++delay_neutral > 200) // nicht sofort
610
                    }
578
                {
-
 
579
                    GRN_OFF;
-
 
580
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK], 0xff); // Werte löschen
-
 
581
                    MotorenEin = 0;
-
 
582
                    delay_neutral = 0;
611
                 else delay_neutral = 0;
583
                    modell_fliegt = 0;
-
 
584
                    SetNeutral();
-
 
585
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK], NeutralAccX / 256); // ACC-NeutralWerte speichern
612
                }
586
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK + 1], NeutralAccX % 256); // ACC-NeutralWerte speichern
613
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
587
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL], NeutralAccY / 256);
614
// Gas ist unten
588
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL + 1], NeutralAccY % 256);
-
 
589
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z], (int) NeutralAccZ / 256);
-
 
590
                    eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z + 1], (int) NeutralAccZ % 256);
-
 
591
                    Piep(GetActiveParamSetNumber());
-
 
592
                }
615
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
593
            } else delay_neutral = 0;
-
 
594
        }
616
            if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120)
595
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
617
                {
596
        // Gas ist unten
618
                // Starten
597
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
619
                if( !MotorenEin && PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75 )
598
        if (PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35 - 125) {
620
                    {
599
            // Starten
621
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
600
            if (!MotorenEin && PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) {
622
// Einschalten
601
                // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
623
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
602
                // Einschalten
624
                    if(++delay_einschalten > 200)
603
                // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
625
                        {
604
                if (++delay_einschalten > 200) {
626
                        delay_einschalten = 200;
605
                    delay_einschalten = 200;
627
                        modell_fliegt = 1;
606
                    modell_fliegt = 1;
628
                        MotorenEin = 1;
607
                    MotorenEin = 1;
629
                        sollGier = 0;
608
                    sollGier = 0;
630
                        Mess_Integral_Gier = 0;
609
                    Mess_Integral_Gier = 0;
631
                        Mess_Integral_Gier2 = 0;
610
                    Mess_Integral_Gier2 = 0;
632
                        Mess_IntegralNick = 0;
611
                    Mess_IntegralNick = 0;
633
                        Mess_IntegralRoll = 0;
612
                    Mess_IntegralRoll = 0;
634
                        Mess_IntegralNick2 = IntegralNick;
613
                    Mess_IntegralNick2 = IntegralNick;
635
                        Mess_IntegralRoll2 = IntegralRoll;
-
 
636
                        SummeNick = 0;
-
 
637
                        SummeRoll = 0;
-
 
638
                        MikroKopterFlags |= FLAG_START;
-
 
639
                       
-
 
640
                        // Beim Einschalten automatisch kalibrieren
-
 
641
                        if( PARAM_CAL_ON_START ) {
-
 
642
                                if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) {
-
 
643
                                        if((MessLuftdruck > 950) || (MessLuftdruck < 750)) {
614
                    Mess_IntegralRoll2 = IntegralRoll;
644
                                                SucheLuftruckOffset();
-
 
645
                                        }
-
 
646
                                }
-
 
647
                               
-
 
648
                                SetNeutral();
-
 
649
                        }
-
 
650
                        }
-
 
651
                    }
615
                    SummeNick = 0;
652
                    else delay_einschalten = 0;
-
 
653
                //Auf Neutralwerte setzen
-
 
654
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
655
// Auschalten
616
                    SummeRoll = 0;
-
 
617
                    MikroKopterFlags |= FLAG_START;
-
 
618
 
656
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
619
                    // Beim Einschalten automatisch kalibrieren
657
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)
-
 
658
                    {
620
                    if (PARAM_CAL_ON_START) {
-
 
621
                        if ((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) {
-
 
622
                            if ((MessLuftdruck > 950) || (MessLuftdruck < 750)) {
-
 
623
                                SucheLuftruckOffset();
-
 
624
                            }
-
 
625
                        }
-
 
626
 
-
 
627
                        SetNeutral();
-
 
628
                    }
-
 
629
                }
-
 
630
            } else delay_einschalten = 0;
-
 
631
            //Auf Neutralwerte setzen
659
                    if(++delay_ausschalten > 200)  // nicht sofort
632
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
633
            // Auschalten
-
 
634
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
635
            if (PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) {
Line 660... Line 636...
660
                        {
636
                if (++delay_ausschalten > 200) // nicht sofort
661
                        MotorenEin = 0;
637
                {
662
                        delay_ausschalten = 200;
638
                    MotorenEin = 0;
663
                        modell_fliegt = 0;
639
                    delay_ausschalten = 200;
664
                        }
640
                    modell_fliegt = 0;
665
                    }
641
                }
666
                else delay_ausschalten = 0;
642
            } else delay_ausschalten = 0;
667
                }
643
        }
668
            }
644
    }
669
 
645
 
Line 670... Line 646...
670
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
646
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
671
// neue Werte von der Funke
647
    // neue Werte von der Funke
Line 672... Line 648...
672
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
648
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
673
 if(!NewPpmData-- || Notlandung) {
649
    if (!NewPpmData-- || Notlandung) {
Line 674... Line 650...
674
        static int chanNickPrev = 0;
650
        static int chanNickPrev = 0;
675
        static int chanRollPrev = 0;
651
        static int chanRollPrev = 0;
Line 676... Line 652...
676
       
652
 
677
        static int stick_nick,stick_roll;
653
        static int stick_nick, stick_roll;
678
       
654
 
679
        ParameterZuordnung();
655
        ParameterZuordnung();
680
 
656
 
681
#define MAX_CHAN_VAL 125L
657
#define MAX_CHAN_VAL 125L
682
#define COS45        7071L              // cos( -45 ) * 10000
658
#define COS45        7071L              // cos( -45 ) * 10000
683
 
659
 
684
        long chanNick = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]];
660
        long chanNick = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]];
685
        long chanRoll = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]];
661
        long chanRoll = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]];
686
 
662
 
687
        int  chanNickDiff;
663
        int chanNickDiff;
688
        int  chanRollDiff;
664
        int chanRollDiff;
689
 
665
 
690
        /* Über Parameter läßt sich zwischen "+" und "X" - Formations
666
        /* Über Parameter läßt sich zwischen "+" und "X" - Formations
691
         * umschalten (sh. parameter.h)
667
         * umschalten (sh. parameter.h)
692
         */
668
         */
693
        if( PARAM_X_FORMATION ) {
669
        if (PARAM_X_FORMATION) {
694
       
670
 
695
                chanRoll = -chanRoll;
671
            chanRoll = -chanRoll;
696
               
672
 
697
                // Stick-Koordinatensystem um -45° (rechts) drehen
673
            // Stick-Koordinatensystem um -45° (rechts) drehen
698
                chanNick *= COS45;
674
            chanNick *= COS45;
699
                chanRoll *= COS45;
675
            chanRoll *= COS45;
700
       
676
 
701
                int chanNickTemp = ( chanNick - chanRoll ) / 10000L;
-
 
702
                int chanRollTemp = ( chanRoll + chanNick ) / 10000L;
-
 
703
 
-
 
704
                chanNick =  chanNickTemp;
-
 
705
                chanRoll = -chanRollTemp;
-
 
706
 
-
 
707
                if (chanNick >  MAX_CHAN_VAL)
-
 
708
                        chanNick =  MAX_CHAN_VAL;
-
 
709
                if (chanNick < -MAX_CHAN_VAL)
-
 
710
                        chanNick = -MAX_CHAN_VAL;
-
 
711
                if (chanRoll >  MAX_CHAN_VAL)
-
 
712
                        chanRoll =  MAX_CHAN_VAL;
-
 
713
                if (chanRoll < -MAX_CHAN_VAL)
-
 
714
                        chanRoll = -MAX_CHAN_VAL;      
-
 
715
        }
-
 
716
 
-
 
717
        chanNickDiff = ( ( chanNick - chanNickPrev ) / 3) * 3;
-
 
718
        chanRollDiff = ( ( chanRoll - chanRollPrev ) / 3) * 3;
-
 
719
       
-
 
720
        chanNickPrev = chanNick;
-
 
721
        chanRollPrev = chanRoll;
-
 
722
               
-
 
723
        stick_nick = (stick_nick * 3 + ( (int) chanNick ) * EE_Parameter.Stick_P) / 4;
-
 
724
        stick_nick += chanNickDiff * EE_Parameter.Stick_D;
-
 
725
        StickNick = stick_nick - GPS_Nick;
-
 
726
 
-
 
727
        stick_roll = (stick_roll * 3 + ( (int) chanRoll ) * EE_Parameter.Stick_P) / 4;
-
 
728
        stick_roll += chanRollDiff * EE_Parameter.Stick_D;
-
 
729
        StickRoll = stick_roll - GPS_Roll;
-
 
730
 
-
 
731
        StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]];
-
 
732
 
-
 
733
        // Gaswert übernehmen
-
 
734
        StickGas = pitch_value();
-
 
735
 
677
            int chanNickTemp = (chanNick - chanRoll) / 10000L;
736
        GyroFaktor     = ((float)Parameter_Gyro_P + 10.0) / (256 / STICK_GAIN );
-
 
Line -... Line 678...
-
 
678
            int chanRollTemp = (chanRoll + chanNick) / 10000L;
-
 
679
 
-
 
680
            chanNick = chanNickTemp;
-
 
681
            chanRoll = -chanRollTemp;
-
 
682
 
-
 
683
            if (chanNick > MAX_CHAN_VAL)
-
 
684
                chanNick = MAX_CHAN_VAL;
-
 
685
            if (chanNick < -MAX_CHAN_VAL)
-
 
686
                chanNick = -MAX_CHAN_VAL;
-
 
687
            if (chanRoll > MAX_CHAN_VAL)
-
 
688
                chanRoll = MAX_CHAN_VAL;
-
 
689
            if (chanRoll < -MAX_CHAN_VAL)
-
 
690
                chanRoll = -MAX_CHAN_VAL;
-
 
691
        }
-
 
692
 
-
 
693
        chanNickDiff = ((chanNick - chanNickPrev) / 3) * 3;
-
 
694
        chanRollDiff = ((chanRoll - chanRollPrev) / 3) * 3;
-
 
695
 
-
 
696
        chanNickPrev = chanNick;
-
 
697
        chanRollPrev = chanRoll;
-
 
698
 
-
 
699
        stick_nick = (stick_nick * 3 + ((int) chanNick) * EE_Parameter.Stick_P) / 4;
-
 
700
        stick_nick += chanNickDiff * EE_Parameter.Stick_D;
-
 
701
        StickNick = stick_nick - GPS_Nick;
-
 
702
 
-
 
703
        stick_roll = (stick_roll * 3 + ((int) chanRoll) * EE_Parameter.Stick_P) / 4;
-
 
704
        stick_roll += chanRollDiff * EE_Parameter.Stick_D;
-
 
705
        StickRoll = stick_roll - GPS_Roll;
-
 
706
 
-
 
707
        StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]];
-
 
708
 
-
 
709
        // Gaswert übernehmen
-
 
710
        if (pitchNeutral()) {
-
 
711
            StickGas = pitch();
-
 
712
        } else {
-
 
713
            //            Warum 120? Gas= 0 ist -125
-
 
714
            //            StickGas  = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120;
-
 
715
            StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 125;
-
 
716
        }
-
 
717
 
737
        IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN );
718
        GyroFaktor = ((float) Parameter_Gyro_P + 10.0) / (256 / STICK_GAIN);
738
 
719
        IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN);
739
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
720
 
740
//+ Analoge Steuerung per Seriell
721
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
741
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
722
        //+ Analoge Steuerung per Seriell
742
   if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128)
-
 
743
    {
723
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
744
         StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
724
        if (ExternControl.Config & 0x01 && Parameter_ExternalControl > 128) {
745
         StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
-
 
746
         StickGier += ExternControl.Gier;
725
            StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
747
     ExternHoehenValue =  (int) ExternControl.Hight * (int)EE_Parameter.Hoehe_Verstaerkung;
726
            StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
748
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
-
 
749
    }
727
            StickGier += ExternControl.Gier;
750
    if(StickGas < 0) StickGas = 0;
728
            ExternHoehenValue = (int) ExternControl.Hight * (int) EE_Parameter.Hoehe_Verstaerkung;
-
 
729
            if (ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
751
 
730
        }
752
    if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0;
731
        if (StickGas < 0) StickGas = 0;
753
    if(GyroFaktor < 0) GyroFaktor = 0;
732
 
-
 
733
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0;
754
    if(IntegralFaktor < 0) IntegralFaktor = 0;
734
        if (GyroFaktor < 0) GyroFaktor = 0;
755
 
735
        if (IntegralFaktor < 0) IntegralFaktor = 0;
756
    if(abs(StickNick/STICK_GAIN) > MaxStickNick)
736
 
757
     {
737
        if (abs(StickNick / STICK_GAIN) > MaxStickNick) {
758
      MaxStickNick = abs(StickNick)/STICK_GAIN;
738
            MaxStickNick = abs(StickNick) / STICK_GAIN;
759
      if(MaxStickNick > 100) MaxStickNick = 100;
739
            if (MaxStickNick > 100) MaxStickNick = 100;
760
     }
-
 
761
     else MaxStickNick--;
740
        } else MaxStickNick--;
762
    if(abs(StickRoll/STICK_GAIN) > MaxStickRoll)
741
        if (abs(StickRoll / STICK_GAIN) > MaxStickRoll) {
763
     {
742
            MaxStickRoll = abs(StickRoll) / STICK_GAIN;
764
      MaxStickRoll = abs(StickRoll)/STICK_GAIN;
743
            if (MaxStickRoll > 100) MaxStickRoll = 100;
765
      if(MaxStickRoll > 100) MaxStickRoll = 100;
744
        } else MaxStickRoll--;
766
     }
745
        if (Notlandung) {
767
     else MaxStickRoll--;
-
 
768
    if(Notlandung)  {MaxStickNick = 0; MaxStickRoll = 0;}
746
            MaxStickNick = 0;
769
 
747
            MaxStickRoll = 0;
770
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
748
        }
771
// Looping?
749
 
772
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
750
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
773
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS)  Looping_Links = 1;
751
        // Looping?
774
  else
752
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
775
   {
753
        if ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS) Looping_Links = 1;
776
     {
-
 
777
      if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0;
754
        else {
778
     }
755
            {
779
   }
756
                if ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0;
780
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1;
757
            }
781
   else
758
        }
782
   {
759
        if ((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1;
783
   if(Looping_Rechts) // Hysterese
760
        else {
784
     {
-
 
785
      if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0;
761
            if (Looping_Rechts) // Hysterese
786
     }
762
            {
787
   }
763
                if (PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0;
788
 
764
            }
789
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_OBEN) Looping_Oben = 1;
765
        }
790
  else
766
 
791
   {
767
        if ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_OBEN) Looping_Oben = 1;
792
    if(Looping_Oben)  // Hysterese
-
 
793
     {
768
        else {
794
      if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0;
-
 
795
     }
769
            if (Looping_Oben) // Hysterese
796
   }
-
 
797
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_UNTEN) Looping_Unten = 1;
-
 
798
   else
-
 
799
   {
-
 
800
    if(Looping_Unten) // Hysterese
-
 
801
     {
-
 
802
      if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0;
770
            {
803
     }
-
 
804
   }
-
 
805
 
-
 
806
   if(Looping_Links || Looping_Rechts)   Looping_Roll = 1; else Looping_Roll = 0;
771
                if ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0;
807
   if(Looping_Oben  || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0;
772
            }
808
  } // Ende neue Funken-Werte
773
        }
809
 
774
        if ((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_UNTEN) Looping_Unten = 1;
810
  if(Looping_Roll || Looping_Nick)
775
        else {
-
 
776
            if (Looping_Unten) // Hysterese
811
   {
777
            {
812
    if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit;
778
                if (PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0;
813
   }
779
            }
Line 814... Line 780...
814
 
780
        }
815
 
781
 
816
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
782
        if (Looping_Links || Looping_Rechts) Looping_Roll = 1;
-
 
783
        else Looping_Roll = 0;
-
 
784
        if (Looping_Oben || Looping_Unten) {
-
 
785
            Looping_Nick = 1;
-
 
786
            Looping_Roll = 0;
-
 
787
            Looping_Links = 0;
-
 
788
            Looping_Rechts = 0;
-
 
789
        } else Looping_Nick = 0;
817
// Bei Empfangsausfall im Flug
790
    } // Ende neue Funken-Werte
-
 
791
 
Line 818... Line -...
818
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
819
   if(Notlandung)
-
 
820
    {
-
 
821
     StickGier = 0;
-
 
822
     StickNick = 0;
-
 
823
     StickRoll = 0;
-
 
824
     GyroFaktor     = (float) 100 / (256.0 / STICK_GAIN);
-
 
825
     IntegralFaktor = (float) 120 / (44000 / STICK_GAIN);
-
 
826
     Looping_Roll = 0;
-
 
827
     Looping_Nick = 0;
-
 
828
    }
-
 
829
 
-
 
830
 
-
 
831
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
832
// Integrale auf ACC-Signal abgleichen
-
 
833
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
834
#define ABGLEICH_ANZAHL 256L
-
 
835
 
-
 
836
 MittelIntegralNick  += IntegralNick;    // Für die Mittelwertbildung aufsummieren
-
 
837
 MittelIntegralRoll  += IntegralRoll;
-
 
838
 MittelIntegralNick2 += IntegralNick2;
-
 
839
 MittelIntegralRoll2 += IntegralRoll2;
-
 
840
 
-
 
841
 if(Looping_Nick || Looping_Roll)
-
 
842
  {
-
 
843
    IntegralAccNick = 0;
-
 
844
    IntegralAccRoll = 0;
-
 
845
    MittelIntegralNick = 0;
-
 
846
    MittelIntegralRoll = 0;
-
 
847
    MittelIntegralNick2 = 0;
-
 
848
    MittelIntegralRoll2 = 0;
-
 
849
    Mess_IntegralNick2 = Mess_IntegralNick;
-
 
850
    Mess_IntegralRoll2 = Mess_IntegralRoll;
-
 
851
    ZaehlMessungen = 0;
-
 
852
    LageKorrekturNick = 0;
-
 
853
    LageKorrekturRoll = 0;
-
 
854
  }
-
 
855
 
-
 
856
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
857
  if(!Looping_Nick && !Looping_Roll)
-
 
858
  {
-
 
859
   long tmp_long, tmp_long2;
-
 
860
   if(FromNaviCtrl_Value.Kalman_K != -1)
-
 
861
     {
-
 
862
      tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
-
 
863
      tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
-
 
864
      tmp_long  = (tmp_long  * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
-
 
865
      tmp_long2 = (tmp_long2 * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
-
 
866
     if((MaxStickNick > 64) || (MaxStickRoll > 64))
-
 
867
      {
-
 
868
      tmp_long  /= 2;
-
 
869
      tmp_long2 /= 2;
-
 
870
      }
-
 
871
     if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
-
 
872
      {
-
 
873
      tmp_long  /= 3;
-
 
874
      tmp_long2 /= 3;
-
 
875
      }
-
 
876
      if(tmp_long >  (long) FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long  = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
-
 
877
      if(tmp_long <  (long)-FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long  = (long)-FromNaviCtrl_Value.Kalman_MaxFusion;
-
 
878
      if(tmp_long2 > (long) FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long2 = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
-
 
879
      if(tmp_long2 < (long)-FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long2 = (long)-FromNaviCtrl_Value.Kalman_MaxFusion;
-
 
880
     }
-
 
881
     else
-
 
882
     {
-
 
883
      tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
-
 
884
      tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
-
 
885
      tmp_long /= 16;
-
 
886
      tmp_long2 /= 16;
-
 
887
     if((MaxStickNick > 64) || (MaxStickRoll > 64))
-
 
888
      {
-
 
889
      tmp_long  /= 3;
-
 
890
      tmp_long2 /= 3;
-
 
891
      }
-
 
892
     if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
-
 
893
      {
-
 
894
      tmp_long  /= 3;
-
 
895
      tmp_long2 /= 3;
-
 
896
      }
-
 
897
 #define AUSGLEICH 32
-
 
898
      if(tmp_long >  AUSGLEICH)  tmp_long  = AUSGLEICH;
-
 
899
      if(tmp_long < -AUSGLEICH)  tmp_long  =-AUSGLEICH;
-
 
900
      if(tmp_long2 > AUSGLEICH)  tmp_long2 = AUSGLEICH;
-
 
901
      if(tmp_long2 <-AUSGLEICH)  tmp_long2 =-AUSGLEICH;
-
 
902
     }
-
 
903
 
-
 
904
    Mess_IntegralNick -= tmp_long;
-
 
905
    Mess_IntegralRoll -= tmp_long2;
-
 
906
  }
-
 
907
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
908
 if(ZaehlMessungen >= ABGLEICH_ANZAHL)
-
 
Line -... Line 792...
-
 
792
    if (Looping_Roll || Looping_Nick) {
909
 {
793
        if (GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit;
-
 
794
    }
910
  static int cnt = 0;
795
 
Line 911... Line 796...
911
  static char last_n_p,last_n_n,last_r_p,last_r_n;
796
 
-
 
797
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
798
    // Bei Empfangsausfall im Flug
-
 
799
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
912
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
800
    if (Notlandung) {
-
 
801
        StickGier = 0;
-
 
802
        StickNick = 0;
-
 
803
        StickRoll = 0;
-
 
804
        GyroFaktor = (float) 100 / (256.0 / STICK_GAIN);
-
 
805
        IntegralFaktor = (float) 120 / (44000 / STICK_GAIN);
-
 
806
        Looping_Roll = 0;
-
 
807
        Looping_Nick = 0;
-
 
808
    }
-
 
809
 
-
 
810
 
913
  if(!Looping_Nick && !Looping_Roll && !TrichterFlug)
811
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
914
  {
812
    // Integrale auf ACC-Signal abgleichen
915
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
813
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 916... Line 814...
916
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
814
#define ABGLEICH_ANZAHL 256L
-
 
815
 
917
        IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
816
    MittelIntegralNick += IntegralNick; // Für die Mittelwertbildung aufsummieren
-
 
817
    MittelIntegralRoll += IntegralRoll;
918
        IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
818
    MittelIntegralNick2 += IntegralNick2;
-
 
819
    MittelIntegralRoll2 += IntegralRoll2;
-
 
820
 
-
 
821
    if (Looping_Nick || Looping_Roll) {
-
 
822
        IntegralAccNick = 0;
-
 
823
        IntegralAccRoll = 0;
919
    IntegralAccZ    = IntegralAccZ / ABGLEICH_ANZAHL;
824
        MittelIntegralNick = 0;
-
 
825
        MittelIntegralRoll = 0;
-
 
826
        MittelIntegralNick2 = 0;
-
 
827
        MittelIntegralRoll2 = 0;
920
#define MAX_I 0//(Poti2/10)
828
        Mess_IntegralNick2 = Mess_IntegralNick;
-
 
829
        Mess_IntegralRoll2 = Mess_IntegralRoll;
-
 
830
        ZaehlMessungen = 0;
-
 
831
        LageKorrekturNick = 0;
-
 
832
        LageKorrekturRoll = 0;
-
 
833
    }
-
 
834
 
921
// Nick ++++++++++++++++++++++++++++++++++++++++++++++++
835
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
922
    IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick);
836
    if (!Looping_Nick && !Looping_Roll) {
-
 
837
        long tmp_long, tmp_long2;
-
 
838
        if (FromNaviCtrl_Value.Kalman_K != -1) {
923
    ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich;
839
            tmp_long = (long) (IntegralNick / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccNick);
924
// Roll ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
925
    IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll);
840
            tmp_long2 = (long) (IntegralRoll / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccRoll);
926
    ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich;
841
            tmp_long = (tmp_long * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
-
 
842
            tmp_long2 = (tmp_long2 * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
-
 
843
            if ((MaxStickNick > 64) || (MaxStickRoll > 64)) {
927
 
844
                tmp_long /= 2;
928
    LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL;
845
                tmp_long2 /= 2;
929
    LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL;
846
            }
-
 
847
            if (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25) {
930
 
848
                tmp_long /= 3;
931
   if(((MaxStickNick > 64) || (MaxStickRoll > 64) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)) && (FromNaviCtrl_Value.Kalman_K == -1))
849
                tmp_long2 /= 3;
932
    {
850
            }
933
     LageKorrekturNick /= 2;
851
            if (tmp_long > (long) FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
-
 
852
            if (tmp_long < (long) - FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long = (long) - FromNaviCtrl_Value.Kalman_MaxFusion;
Line -... Line 853...
-
 
853
            if (tmp_long2 > (long) FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long2 = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
934
     LageKorrekturRoll /= 2;
854
            if (tmp_long2 < (long) - FromNaviCtrl_Value.Kalman_MaxFusion) tmp_long2 = (long) - FromNaviCtrl_Value.Kalman_MaxFusion;
-
 
855
        } else {
-
 
856
            tmp_long = (long) (IntegralNick / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccNick);
935
    }
857
            tmp_long2 = (long) (IntegralRoll / EE_Parameter.GyroAccFaktor - (long) Mittelwert_AccRoll);
936
 
858
            tmp_long /= 16;
-
 
859
            tmp_long2 /= 16;
-
 
860
            if ((MaxStickNick > 64) || (MaxStickRoll > 64)) {
-
 
861
                tmp_long /= 3;
-
 
862
                tmp_long2 /= 3;
-
 
863
            }
-
 
864
            if (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25) {
-
 
865
                tmp_long /= 3;
-
 
866
                tmp_long2 /= 3;
-
 
867
            }
-
 
868
#define AUSGLEICH 32
-
 
869
            if (tmp_long > AUSGLEICH) tmp_long = AUSGLEICH;
-
 
870
            if (tmp_long < -AUSGLEICH) tmp_long = -AUSGLEICH;
-
 
871
            if (tmp_long2 > AUSGLEICH) tmp_long2 = AUSGLEICH;
-
 
872
            if (tmp_long2 <-AUSGLEICH) tmp_long2 = -AUSGLEICH;
-
 
873
        }
-
 
874
 
-
 
875
        Mess_IntegralNick -= tmp_long;
-
 
876
        Mess_IntegralRoll -= tmp_long2;
-
 
877
    }
-
 
878
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
879
    if (ZaehlMessungen >= ABGLEICH_ANZAHL) {
-
 
880
        static int cnt = 0;
-
 
881
        static char last_n_p, last_n_n, last_r_p, last_r_n;
Line -... Line 882...
-
 
882
        static long MittelIntegralNick_Alt, MittelIntegralRoll_Alt;
-
 
883
        if (!Looping_Nick && !Looping_Roll && !TrichterFlug) {
-
 
884
            MittelIntegralNick /= ABGLEICH_ANZAHL;
-
 
885
            MittelIntegralRoll /= ABGLEICH_ANZAHL;
-
 
886
            IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
-
 
887
            IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
-
 
888
            IntegralAccZ = IntegralAccZ / ABGLEICH_ANZAHL;
-
 
889
#define MAX_I 0//(Poti2/10)
-
 
890
            // Nick ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
891
            IntegralFehlerNick = (long) (MittelIntegralNick - (long) IntegralAccNick);
-
 
892
            ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich;
-
 
893
            // Roll ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
894
            IntegralFehlerRoll = (long) (MittelIntegralRoll - (long) IntegralAccRoll);
-
 
895
            ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich;
-
 
896
 
-
 
897
            LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL;
-
 
898
            LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL;
-
 
899
 
-
 
900
            if (((MaxStickNick > 64) || (MaxStickRoll > 64) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)) && (FromNaviCtrl_Value.Kalman_K == -1)) {
-
 
901
                LageKorrekturNick /= 2;
-
 
902
                LageKorrekturRoll /= 2;
-
 
903
            }
-
 
904
 
-
 
905
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line -... Line 906...
-
 
906
            // Gyro-Drift ermitteln
-
 
907
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
908
            MittelIntegralNick2 /= ABGLEICH_ANZAHL;
-
 
909
            MittelIntegralRoll2 /= ABGLEICH_ANZAHL;
-
 
910
            tmp_long = IntegralNick2 - IntegralNick;
937
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
911
            tmp_long2 = IntegralRoll2 - IntegralRoll;
938
// Gyro-Drift ermitteln
912
            //DebugOut.Analog[25] = MittelIntegralRoll2 / 26;
939
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
913
 
940
    MittelIntegralNick2 /= ABGLEICH_ANZAHL;
914
            IntegralFehlerNick = tmp_long;
941
    MittelIntegralRoll2 /= ABGLEICH_ANZAHL;
915
            IntegralFehlerRoll = tmp_long2;
942
    tmp_long  = IntegralNick2 - IntegralNick;
916
            Mess_IntegralNick2 -= IntegralFehlerNick;
943
    tmp_long2 = IntegralRoll2 - IntegralRoll;
917
            Mess_IntegralRoll2 -= IntegralFehlerRoll;
944
    //DebugOut.Analog[25] = MittelIntegralRoll2 / 26;
918
 
945
 
919
            //    IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2;
946
    IntegralFehlerNick = tmp_long;
920
            //    IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2;
947
    IntegralFehlerRoll = tmp_long2;
921
            if (GierGyroFehler > ABGLEICH_ANZAHL / 2) {
948
    Mess_IntegralNick2 -= IntegralFehlerNick;
922
                AdNeutralGier++;
Line 949... Line 923...
949
    Mess_IntegralRoll2 -= IntegralFehlerRoll;
923
                AdNeutralGierBias++;
950
 
924
            }
951
//    IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2;
925
            if (GierGyroFehler <-ABGLEICH_ANZAHL / 2) {
952
//    IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2;
926
                AdNeutralGier--;
953
    if(GierGyroFehler > ABGLEICH_ANZAHL/2) { AdNeutralGier++; AdNeutralGierBias++; }
927
                AdNeutralGierBias--;
954
    if(GierGyroFehler <-ABGLEICH_ANZAHL/2) { AdNeutralGier--; AdNeutralGierBias--; }
928
            }
955
 
-
 
956
DebugOut.Analog[22] = MittelIntegralRoll / 26;
929
 
957
//DebugOut.Analog[24] = GierGyroFehler;
-
 
958
    GierGyroFehler = 0;
930
            DebugOut.Analog[22] = MittelIntegralRoll / 26;
959
 
-
 
960
 
931
            //DebugOut.Analog[24] = GierGyroFehler;
961
/*DebugOut.Analog[17] = IntegralAccNick / 26;
932
            GierGyroFehler = 0;
962
DebugOut.Analog[18] = IntegralAccRoll / 26;
933
 
963
DebugOut.Analog[19] = IntegralFehlerNick;// / 26;
934
 
964
DebugOut.Analog[20] = IntegralFehlerRoll;// / 26;
-
 
965
*/
935
            /*DebugOut.Analog[17] = IntegralAccNick / 26;
966
//DebugOut.Analog[21] = MittelIntegralNick / 26;
936
            DebugOut.Analog[18] = IntegralAccRoll / 26;
967
//MittelIntegralRoll = MittelIntegralRoll;
937
            DebugOut.Analog[19] = IntegralFehlerNick;// / 26;
968
//DebugOut.Analog[28] = ausgleichNick;
-
 
969
/*
938
            DebugOut.Analog[20] = IntegralFehlerRoll;// / 26;
970
DebugOut.Analog[29] = ausgleichRoll;
-
 
971
DebugOut.Analog[30] = LageKorrekturRoll * 10;
939
             */
972
*/
940
            //DebugOut.Analog[21] = MittelIntegralNick / 26;
973
 
941
            //MittelIntegralRoll = MittelIntegralRoll;
974
#define FEHLER_LIMIT  (ABGLEICH_ANZAHL * 4)
942
            //DebugOut.Analog[28] = ausgleichNick;
-
 
943
            /*
-
 
944
            DebugOut.Analog[29] = ausgleichRoll;
-
 
945
            DebugOut.Analog[30] = LageKorrekturRoll * 10;
-
 
946
             */
-
 
947
 
975
#define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16)
948
#define FEHLER_LIMIT  (ABGLEICH_ANZAHL * 4)
-
 
949
#define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16)
-
 
950
#define BEWEGUNGS_LIMIT 20000
-
 
951
            // Nick +++++++++++++++++++++++++++++++++++++++++++++++++
-
 
952
            cnt = 1; // + labs(IntegralFehlerNick) / 4096;
-
 
953
            if (labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3 * 16)) {
-
 
954
                if (IntegralFehlerNick > FEHLER_LIMIT2) {
-
 
955
                    if (last_n_p) {
-
 
956
                        cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
-
 
957
                        ausgleichNick = IntegralFehlerNick / 8;
-
 
958
                        if (ausgleichNick > 5000) ausgleichNick = 5000;
-
 
959
                        LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
-
 
960
                    } else last_n_p = 1;
-
 
961
                } else last_n_p = 0;
-
 
962
                if (IntegralFehlerNick < -FEHLER_LIMIT2) {
-
 
963
                    if (last_n_n) {
-
 
964
                        cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
-
 
965
                        ausgleichNick = IntegralFehlerNick / 8;
976
#define BEWEGUNGS_LIMIT 20000
966
                        if (ausgleichNick < -5000) ausgleichNick = -5000;
-
 
967
                        LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
-
 
968
                    } else last_n_n = 1;
-
 
969
                } else last_n_n = 0;
-
 
970
            } else {
-
 
971
                cnt = 0;
-
 
972
                KompassSignalSchlecht = 1000;
-
 
973
            }
977
// Nick +++++++++++++++++++++++++++++++++++++++++++++++++
974
            if (cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
978
        cnt = 1;// + labs(IntegralFehlerNick) / 4096;
975
            if (cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift / 16;
-
 
976
            if (IntegralFehlerNick > FEHLER_LIMIT) AdNeutralNick += cnt;
-
 
977
            if (IntegralFehlerNick < -FEHLER_LIMIT) AdNeutralNick -= cnt;
979
        if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16))
978
 
-
 
979
            // Roll +++++++++++++++++++++++++++++++++++++++++++++++++
-
 
980
            cnt = 1; // + labs(IntegralFehlerNick) / 4096;
-
 
981
 
-
 
982
            ausgleichRoll = 0;
980
        {
983
            if (labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3 * 16)) {
981
        if(IntegralFehlerNick >  FEHLER_LIMIT2)
984
                if (IntegralFehlerRoll > FEHLER_LIMIT2) {
982
         {
985
                    if (last_r_p) {
-
 
986
                        cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
983
           if(last_n_p)
987
                        ausgleichRoll = IntegralFehlerRoll / 8;
984
           {
-
 
985
            cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
-
 
986
            ausgleichNick = IntegralFehlerNick / 8;
-
 
987
            if(ausgleichNick > 5000) ausgleichNick = 5000;
-
 
Line -... Line 988...
-
 
988
                        if (ausgleichRoll > 5000) ausgleichRoll = 5000;
-
 
989
                        LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
-
 
990
                    } else last_r_p = 1;
-
 
991
                } else last_r_p = 0;
988
            LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
992
                if (IntegralFehlerRoll < -FEHLER_LIMIT2) {
-
 
993
                    if (last_r_n) {
-
 
994
                        cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
-
 
995
                        ausgleichRoll = IntegralFehlerRoll / 8;
-
 
996
                        if (ausgleichRoll < -5000) ausgleichRoll = -5000;
-
 
997
                        LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
-
 
998
                    } else last_r_n = 1;
-
 
999
                } else last_r_n = 0;
-
 
1000
            } else {
989
           }
1001
                cnt = 0;
-
 
1002
                KompassSignalSchlecht = 1000;
-
 
1003
            }
-
 
1004
            if (cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
-
 
1005
            if (cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift / 16;
Line 990... Line -...
990
           else last_n_p = 1;
-
 
991
         } else  last_n_p = 0;
-
 
992
        if(IntegralFehlerNick < -FEHLER_LIMIT2)
-
 
993
         {
-
 
994
           if(last_n_n)
-
 
995
            {
-
 
996
             cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
-
 
997
             ausgleichNick = IntegralFehlerNick / 8;
-
 
998
             if(ausgleichNick < -5000) ausgleichNick = -5000;
-
 
999
             LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
-
 
1000
            }
-
 
1001
           else last_n_n = 1;
-
 
1002
         } else  last_n_n = 0;
-
 
1003
        }
-
 
1004
        else
-
 
1005
        {
-
 
1006
         cnt = 0;
-
 
1007
         KompassSignalSchlecht = 1000;
-
 
1008
        }
-
 
1009
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
-
 
1010
        if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16;
-
 
1011
        if(IntegralFehlerNick >  FEHLER_LIMIT)   AdNeutralNick += cnt;
-
 
1012
        if(IntegralFehlerNick < -FEHLER_LIMIT)   AdNeutralNick -= cnt;
-
 
1013
 
-
 
1014
// Roll +++++++++++++++++++++++++++++++++++++++++++++++++
-
 
1015
        cnt = 1;// + labs(IntegralFehlerNick) / 4096;
-
 
1016
 
-
 
1017
        ausgleichRoll = 0;
-
 
1018
        if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16))
-
 
1019
        {
-
 
1020
        if(IntegralFehlerRoll >  FEHLER_LIMIT2)
-
 
1021
         {
-
 
1022
           if(last_r_p)
-
 
1023
           {
-
 
1024
            cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
-
 
1025
            ausgleichRoll = IntegralFehlerRoll / 8;
-
 
1026
            if(ausgleichRoll > 5000) ausgleichRoll = 5000;
-
 
1027
            LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
-
 
1028
           }
-
 
1029
           else last_r_p = 1;
-
 
1030
         } else  last_r_p = 0;
-
 
1031
        if(IntegralFehlerRoll < -FEHLER_LIMIT2)
-
 
1032
         {
-
 
1033
           if(last_r_n)
-
 
1034
           {
-
 
1035
            cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
-
 
1036
            ausgleichRoll = IntegralFehlerRoll / 8;
-
 
1037
            if(ausgleichRoll < -5000) ausgleichRoll = -5000;
-
 
1038
            LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
-
 
1039
           }
-
 
1040
           else last_r_n = 1;
-
 
1041
         } else  last_r_n = 0;
-
 
1042
        } else
-
 
1043
        {
-
 
1044
         cnt = 0;
-
 
1045
         KompassSignalSchlecht = 1000;
-
 
1046
        }
-
 
1047
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
-
 
1048
        if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16;
1006
            if (IntegralFehlerRoll > FEHLER_LIMIT) AdNeutralRoll += cnt;
1049
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
1007
            if (IntegralFehlerRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt;
1050
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
1008
        } else {
1051
  }
1009
            LageKorrekturRoll = 0;
1052
  else
1010
            LageKorrekturNick = 0;
1053
  {
1011
            TrichterFlug = 0;
1054
   LageKorrekturRoll = 0;
1012
        }
1055
   LageKorrekturNick = 0;
1013
 
1056
   TrichterFlug = 0;
-
 
1057
  }
1014
        if (!IntegralFaktor) {
1058
 
1015
            LageKorrekturRoll = 0;
1059
  if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH
1016
            LageKorrekturNick = 0;
1060
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
1017
        } // z.B. bei HH
1061
   MittelIntegralNick_Alt = MittelIntegralNick;
1018
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++
1062
   MittelIntegralRoll_Alt = MittelIntegralRoll;
1019
        MittelIntegralNick_Alt = MittelIntegralNick;
1063
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
1020
        MittelIntegralRoll_Alt = MittelIntegralRoll;
1064
    IntegralAccNick = 0;
1021
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++
1065
    IntegralAccRoll = 0;
1022
        IntegralAccNick = 0;
Line 1066... Line 1023...
1066
    IntegralAccZ = 0;
1023
        IntegralAccRoll = 0;
1067
    MittelIntegralNick = 0;
1024
        IntegralAccZ = 0;
1068
    MittelIntegralRoll = 0;
1025
        MittelIntegralNick = 0;
1069
    MittelIntegralNick2 = 0;
1026
        MittelIntegralRoll = 0;
1070
    MittelIntegralRoll2 = 0;
1027
        MittelIntegralNick2 = 0;
1071
    ZaehlMessungen = 0;
1028
        MittelIntegralRoll2 = 0;
1072
 }
-
 
1073
//DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor);
1029
        ZaehlMessungen = 0;
1074
 
1030
    }
1075
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1031
    //DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor);
1076
//  Gieren
1032
 
1077
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1033
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1078
//    if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;};
1034
    //  Gieren
1079
    if(abs(StickGier) > 15) // war 35
-
 
1080
     {
-
 
1081
      KompassSignalSchlecht = 1000;
-
 
1082
      if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX))
-
 
1083
       {
-
 
1084
         NeueKompassRichtungMerken = 1;
-
 
1085
        };
-
 
1086
     }
-
 
1087
    tmp_int  = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo  y = ax + bx²
1035
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1088
    tmp_int += (EE_Parameter.Gier_P * StickGier) / 4;
-
 
1089
    sollGier = tmp_int;
1036
    //    if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;};
1090
    Mess_Integral_Gier -= tmp_int;
-
 
1091
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
1037
    if (abs(StickGier) > 15) // war 35
1092
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
-
 
1093
 
-
 
1094
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1038
    {
1095
//  Kompass
1039
        KompassSignalSchlecht = 1000;
1096
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
1097
//DebugOut.Analog[29] = (MaxStickNick + MaxStickRoll);
-
 
1098
 
-
 
1099
    if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV))
-
 
1100
     {
1040
        if (!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) {
1101
       int w,v,r,fehler,korrektur;
-
 
1102
       w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln
1041
            NeueKompassRichtungMerken = 1;
1103
       v = abs(IntegralRoll /512);
-
 
1104
       if(v > w) w = v; // grösste Neigung ermitteln
1042
        };
1105
       korrektur = w / 8 + 1;
1043
    }
1106
       fehler = ((540 + KompassValue - (ErsatzKompass/GIER_GRAD_FAKTOR)) % 360) - 180;
1044
    tmp_int = (long) EE_Parameter.Gier_P * ((long) StickGier * abs(StickGier)) / 512L; // expo  y = ax + bx²
1107
           if(NeueKompassRichtungMerken)
-
 
1108
            {
-
 
1109
                 fehler = 0;
-
 
1110
                 ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
1045
    tmp_int += (EE_Parameter.Gier_P * StickGier) / 4;
1111
                }
1046
    sollGier = tmp_int;
1112
       if(!KompassSignalSchlecht && w < 25)
-
 
1113
        {
1047
    Mess_Integral_Gier -= tmp_int;
-
 
1048
    if (Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen
-
 
1049
    if (Mess_Integral_Gier <-50000) Mess_Integral_Gier = -50000;
-
 
1050
 
-
 
1051
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
1052
    //  Kompass
-
 
1053
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
1054
    //DebugOut.Analog[29] = (MaxStickNick + MaxStickRoll);
-
 
1055
 
-
 
1056
    if (KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) {
-
 
1057
        int w, v, r, fehler, korrektur;
-
 
1058
        w = abs(IntegralNick / 512); // mit zunehmender Neigung den Einfluss drosseln
-
 
1059
        v = abs(IntegralRoll / 512);
-
 
1060
        if (v > w) w = v; // grösste Neigung ermitteln
-
 
1061
        korrektur = w / 8 + 1;
-
 
1062
        fehler = ((540 + KompassValue - (ErsatzKompass / GIER_GRAD_FAKTOR)) % 360) - 180;
-
 
1063
        if (NeueKompassRichtungMerken) {
1114
        GierGyroFehler += fehler;
1064
            fehler = 0;
1115
        if(NeueKompassRichtungMerken)
1065
            ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
1116
         {
1066
        }
1117
          beeptime = 200;
1067
        if (!KompassSignalSchlecht && w < 25) {
1118
//         KompassStartwert = KompassValue;
1068
            GierGyroFehler += fehler;
1119
          KompassStartwert = (ErsatzKompass/GIER_GRAD_FAKTOR);
1069
            if (NeueKompassRichtungMerken) {
1120
          NeueKompassRichtungMerken = 0;
1070
                beeptime = 200;
1121
         }
1071
                //         KompassStartwert = KompassValue;
1122
        }
-
 
1123
       ErsatzKompass += (fehler * 8) / korrektur;
1072
                KompassStartwert = (ErsatzKompass / GIER_GRAD_FAKTOR);
1124
       w = (w * Parameter_KompassWirkung) / 32;           // auf die Wirkung normieren
1073
                NeueKompassRichtungMerken = 0;
1125
       w = Parameter_KompassWirkung - w;                  // Wirkung ggf drosseln
1074
            }
1126
       if(w >= 0)
1075
        }
1127
        {
1076
        ErsatzKompass += (fehler * 8) / korrektur;
1128
          if(!KompassSignalSchlecht)
1077
        w = (w * Parameter_KompassWirkung) / 32; // auf die Wirkung normieren
1129
          {
1078
        w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln
1130
           v = 64 + ((MaxStickNick + MaxStickRoll)) / 8;
1079
        if (w >= 0) {
1131
           r = ((540 + (ErsatzKompass/GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180;
1080
            if (!KompassSignalSchlecht) {
1132
//           r = KompassRichtung;
1081
                v = 64 + ((MaxStickNick + MaxStickRoll)) / 8;
1133
           v = (r * w) / v;  // nach Kompass ausrichten
1082
                r = ((540 + (ErsatzKompass / GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180;
1134
           w = 3 * Parameter_KompassWirkung;
1083
                //           r = KompassRichtung;
1135
           if(v > w) v = w; // Begrenzen
1084
                v = (r * w) / v; // nach Kompass ausrichten
1136
           else
1085
                w = 3 * Parameter_KompassWirkung;
1137
           if(v < -w) v = -w;
1086
                if (v > w) v = w; // Begrenzen
1138
           Mess_Integral_Gier += v;
1087
                else
1139
          }
1088
                    if (v < -w) v = -w;
1140
          if(KompassSignalSchlecht) KompassSignalSchlecht--;
1089
                Mess_Integral_Gier += v;
1141
        }
1090
            }
1142
        else KompassSignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek
1091
            if (KompassSignalSchlecht) KompassSignalSchlecht--;
1143
     }
1092
        } else KompassSignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek
1144
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1093
    }
1145
 
1094
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1146
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1095
 
1147
//  Debugwerte zuordnen
1096
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1148
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1097
    //  Debugwerte zuordnen
1149
  if(!TimerWerteausgabe--)
1098
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1150
   {
1099
    if (!TimerWerteausgabe--) {
1151
    TimerWerteausgabe = 24;
1100
        TimerWerteausgabe = 24;
1152
 
1101
 
1153
    DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor;
1102
        DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor;
1154
    DebugOut.Analog[1] = IntegralRoll / EE_Parameter.GyroAccFaktor;
1103
        DebugOut.Analog[1] = IntegralRoll / EE_Parameter.GyroAccFaktor;
1155
    DebugOut.Analog[2] = Mittelwert_AccNick;
1104
        DebugOut.Analog[2] = Mittelwert_AccNick;
1156
    DebugOut.Analog[3] = Mittelwert_AccRoll;
1105
        DebugOut.Analog[3] = Mittelwert_AccRoll;
1157
    DebugOut.Analog[4] = MesswertGier;
1106
        DebugOut.Analog[4] = MesswertGier;
1158
    DebugOut.Analog[5] = HoehenWert;
1107
        DebugOut.Analog[5] = HoehenWert;
1159
    DebugOut.Analog[6] = (Mess_Integral_Hoch / 512);
1108
        DebugOut.Analog[6] = (Mess_Integral_Hoch / 512);
1160
    DebugOut.Analog[8] = KompassValue;
1109
        DebugOut.Analog[8] = KompassValue;
1161
    DebugOut.Analog[9] = UBat;
1110
        DebugOut.Analog[9] = UBat;
1162
    DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR;
1111
        DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR;
1163
    DebugOut.Analog[10] = SenderOkay;
1112
        DebugOut.Analog[10] = SenderOkay;
1164
    //DebugOut.Analog[16] = Mittelwert_AccHoch;
1113
        //DebugOut.Analog[16] = Mittelwert_AccHoch;
1165
    DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
1114
        DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
1166
    DebugOut.Analog[18] = (int)FromNaviCtrl_Value.OsdBar;
1115
        DebugOut.Analog[18] = (int) FromNaviCtrl_Value.OsdBar;
1167
    DebugOut.Analog[19] = WinkelOut.CalcState;
1116
        DebugOut.Analog[19] = WinkelOut.CalcState;
1168
    DebugOut.Analog[20] = ServoValue;
1117
        DebugOut.Analog[20] = ServoValue;
1169
//    DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift;
1118
        //    DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift;
1170
//    DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K;
1119
        //    DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K;
1171
//    DebugOut.Analog[30] = GPS_Nick;
1120
        //    DebugOut.Analog[30] = GPS_Nick;
1172
//    DebugOut.Analog[31] = GPS_Roll;
1121
        //    DebugOut.Analog[31] = GPS_Roll;
1173
 
1122
 
1174
 
1123
 
1175
//    DebugOut.Analog[19] -= DebugOut.Analog[19]/128;
1124
        //    DebugOut.Analog[19] -= DebugOut.Analog[19]/128;
1176
//    if(DebugOut.Analog[19] > 0) DebugOut.Analog[19]--; else DebugOut.Analog[19]++;
1125
        //    if(DebugOut.Analog[19] > 0) DebugOut.Analog[19]--; else DebugOut.Analog[19]++;
1177
 
1126
 
1178
/*    DebugOut.Analog[16] = motor_rx[0];
1127
        /*    DebugOut.Analog[16] = motor_rx[0];
1179
    DebugOut.Analog[17] = motor_rx[1];
1128
            DebugOut.Analog[17] = motor_rx[1];
1180
    DebugOut.Analog[18] = motor_rx[2];
1129
            DebugOut.Analog[18] = motor_rx[2];
1181
    DebugOut.Analog[19] = motor_rx[3];
1130
            DebugOut.Analog[19] = motor_rx[3];
1182
    DebugOut.Analog[20] = motor_rx[0] + motor_rx[1] + motor_rx[2] + motor_rx[3];
1131
            DebugOut.Analog[20] = motor_rx[0] + motor_rx[1] + motor_rx[2] + motor_rx[3];
Line 1183... Line 1132...
1183
    DebugOut.Analog[20] /= 14;
1132
            DebugOut.Analog[20] /= 14;
1184
    DebugOut.Analog[21] = motor_rx[4];
1133
            DebugOut.Analog[21] = motor_rx[4];
Line 1185... Line 1134...
1185
    DebugOut.Analog[22] = motor_rx[5];
1134
            DebugOut.Analog[22] = motor_rx[5];
1186
    DebugOut.Analog[23] = motor_rx[6];
1135
            DebugOut.Analog[23] = motor_rx[6];
1187
    DebugOut.Analog[24] = motor_rx[7];
1136
            DebugOut.Analog[24] = motor_rx[7];
1188
    DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
1137
            DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
1189
*/
1138
         */
1190
//    DebugOut.Analog[9] = MesswertNick;
1139
        //    DebugOut.Analog[9] = MesswertNick;
1191
//    DebugOut.Analog[9] = SollHoehe;
1140
        //    DebugOut.Analog[9] = SollHoehe;
1192
//    DebugOut.Analog[10] = Mess_Integral_Gier / 128;
1141
        //    DebugOut.Analog[10] = Mess_Integral_Gier / 128;
1193
//    DebugOut.Analog[11] = KompassStartwert;
1142
        //    DebugOut.Analog[11] = KompassStartwert;
1194
//    DebugOut.Analog[10] = Parameter_Gyro_I;
1143
        //    DebugOut.Analog[10] = Parameter_Gyro_I;
1195
//    DebugOut.Analog[10] = EE_Parameter.Gyro_I;
1144
        //    DebugOut.Analog[10] = EE_Parameter.Gyro_I;
1196
//    DebugOut.Analog[9] = KompassRichtung;
1145
        //    DebugOut.Analog[9] = KompassRichtung;
Line 1197... Line 1146...
1197
//    DebugOut.Analog[10] = GasMischanteil;
1146
        //    DebugOut.Analog[10] = GasMischanteil;
1198
//    DebugOut.Analog[3] = HoeheD * 32;
1147
        //    DebugOut.Analog[3] = HoeheD * 32;
Line 1199... Line 1148...
1199
//    DebugOut.Analog[4] = hoehenregler;
1148
        //    DebugOut.Analog[4] = hoehenregler;
1200
  }
1149
    }
Line 1201... Line 1150...
1201
 
1150
 
Line 1237... Line 1186...
1237
 
1186
 
1238
        // Begrenzung des Gasmischanteils auf MAX_GAS - 20 (Reserve für Motoren)
1187
        // Begrenzung des Gasmischanteils auf MAX_GAS - 20 (Reserve für Motoren)
1239
        if( GasMischanteil > ( MAX_GAS - 20 ) * STICK_GAIN )
1188
        if( GasMischanteil > ( MAX_GAS - 20 ) * STICK_GAIN )
Line -... Line 1189...
-
 
1189
                GasMischanteil = ( MAX_GAS - 20 ) * STICK_GAIN;
-
 
1190
 
-
 
1191
    // Mindestens auf Minimalgas stellen
-
 
1192
    if (GasMischanteil < MIN_GAS)
-
 
1193
        GasMischanteil = MIN_GAS;
-
 
1194
 
-
 
1195
    // Begrenzung des Gasmischanteils auf MAX_GAS - 20 (Reserve für Motoren)
-
 
1196
    if (GasMischanteil > (MAX_GAS - 20) * STICK_GAIN)
1240
                GasMischanteil = ( MAX_GAS - 20 ) * STICK_GAIN;
1197
        GasMischanteil = (MAX_GAS - 20) * STICK_GAIN;
1241
 
1198
 
1242
        DebugOut.Analog[7] = GasMischanteil;
1199
    DebugOut.Analog[7] = GasMischanteil;
1243
 
1200
 
1244
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
1201
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1245
        // Gier-Anteil
1202
    // Gier-Anteil
1246
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
1203
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1247
 
1204
 
1248
    GierMischanteil = MesswertGier - ( sollGier * STICK_GAIN );     // Regler für Gier
1205
    GierMischanteil = MesswertGier - (sollGier * STICK_GAIN); // Regler für Gier
1249
 
1206
 
1250
        #define MIN_GIERGAS  ( 40 * STICK_GAIN )  // unter diesem Gaswert trotzdem Gieren
1207
#define MIN_GIERGAS  ( 40 * STICK_GAIN )  // unter diesem Gaswert trotzdem Gieren
1251
 
1208
 
1252
        // Reduzierten Gieranteil berechnen
1209
    // Reduzierten Gieranteil berechnen
1253
        if( GasMischanteil < MIN_GIERGAS ) {
1210
    if (GasMischanteil < MIN_GIERGAS) {
1254
                GierMischanteil = ( GierMischanteil * GasMischanteil ) / MIN_GIERGAS;
1211
        GierMischanteil = (GierMischanteil * GasMischanteil) / MIN_GIERGAS;
1255
        }
1212
    }
1256
 
1213
 
1257
        // Gieranteil darf nicht größer als der halbe Gasanteil sein
1214
    // Gieranteil darf nicht größer als der halbe Gasanteil sein
1258
        if( GierMischanteil >  ( GasMischanteil >> 1 ) )
1215
    if (GierMischanteil > (GasMischanteil >> 1))
1259
                GierMischanteil =    GasMischanteil >> 1;
1216
        GierMischanteil = GasMischanteil >> 1;
Line 1260... Line 1217...
1260
        if( GierMischanteil < -( GasMischanteil >> 1 ) )
1217
    if (GierMischanteil < -(GasMischanteil >> 1))
1261
                GierMischanteil = -( GasMischanteil >> 1 );
1218
        GierMischanteil = -(GasMischanteil >> 1);
1262
 
1219
 
1263
    tmp_int = MAX_GAS * STICK_GAIN;
1220
    tmp_int = MAX_GAS * STICK_GAIN;
1264
       
1221
 
1265
        // Gieranteil darf die Gasreserve nicht überschreiten
1222
    // Gieranteil darf die Gasreserve nicht überschreiten
1266
    if( GierMischanteil >  ( ( tmp_int - GasMischanteil ) ) )
1223
    if (GierMischanteil > ((tmp_int - GasMischanteil)))
1267
                GierMischanteil =  ( ( tmp_int - GasMischanteil ) );
1224
        GierMischanteil = ((tmp_int - GasMischanteil));
1268
    if( GierMischanteil < -( ( tmp_int - GasMischanteil ) ) )
1225
    if (GierMischanteil < -((tmp_int - GasMischanteil)))
1269
                GierMischanteil = -( ( tmp_int - GasMischanteil ) );
1226
        GierMischanteil = -((tmp_int - GasMischanteil));
1270
 
1227
 
1271
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1228
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1272
// Nick-Achse
1229
    // Nick-Achse
1273
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1230
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1274
    DiffNick = MesswertNick - StickNick;        // Differenz bestimmen
1231
    DiffNick = MesswertNick - StickNick; // Differenz bestimmen
1275
    if(IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - StickNick; // I-Anteil bei Winkelregelung
1232
    if (IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - StickNick; // I-Anteil bei Winkelregelung
1276
    else  SummeNick += DiffNick; // I-Anteil bei HH
1233
    else SummeNick += DiffNick; // I-Anteil bei HH
1277
    if(SummeNick >  (STICK_GAIN * 16000L)) SummeNick =  (STICK_GAIN * 16000L);
1234
    if (SummeNick > (STICK_GAIN * 16000L)) SummeNick = (STICK_GAIN * 16000L);
1278
    if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
1235
    if (SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
1279
    pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick
1236
    pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick
1280
    // Motor Vorn
1237
    // Motor Vorn
Line 1281... Line 1238...
1281
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1238
    tmp_int = (long) ((long) Parameter_DynamicStability * (long) (GasMischanteil + abs(GierMischanteil) / 2)) / 64;
1282
    if(pd_ergebnis >  tmp_int) pd_ergebnis =  tmp_int;
1239
    if (pd_ergebnis > tmp_int) pd_ergebnis = tmp_int;
1283
    if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1240
    if (pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1284
 
1241
 
1285
    motorwert = GasMischanteil + pd_ergebnis + GierMischanteil;   // Mischer
1242
    motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; // Mischer
1286
    motorwert /= STICK_GAIN;
1243
    motorwert /= STICK_GAIN;
1287
        if ((motorwert < 0)) motorwert = 0;
1244
    if ((motorwert < 0)) motorwert = 0;
1288
        else if(motorwert > MAX_GAS)        motorwert = MAX_GAS;
1245
    else if (motorwert > MAX_GAS) motorwert = MAX_GAS;
1289
        if (motorwert < MIN_GAS)            motorwert = MIN_GAS;
1246
    if (motorwert < MIN_GAS) motorwert = MIN_GAS;
1290
        Motor_Vorne = motorwert;
1247
    Motor_Vorne = motorwert;
1291
    // Motor Heck
1248
    // Motor Heck
1292
        motorwert = GasMischanteil - pd_ergebnis + GierMischanteil;
1249
    motorwert = GasMischanteil - pd_ergebnis + GierMischanteil;
1293
    motorwert /= STICK_GAIN;
1250
    motorwert /= STICK_GAIN;
1294
        if ((motorwert < 0)) motorwert = 0;
1251
    if ((motorwert < 0)) motorwert = 0;
1295
        else if(motorwert > MAX_GAS)        motorwert = MAX_GAS;
1252
    else if (motorwert > MAX_GAS) motorwert = MAX_GAS;
1296
        if (motorwert < MIN_GAS)            motorwert = MIN_GAS;
1253
    if (motorwert < MIN_GAS) motorwert = MIN_GAS;
1297
        Motor_Hinten = motorwert;
1254
    Motor_Hinten = motorwert;
1298
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1255
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1299
// Roll-Achse
1256
    // Roll-Achse
1300
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1257
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1301
        DiffRoll = MesswertRoll - StickRoll;    // Differenz bestimmen
1258
    DiffRoll = MesswertRoll - StickRoll; // Differenz bestimmen
1302
    if(IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - StickRoll;// I-Anteil bei Winkelregelung
1259
    if (IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - StickRoll; // I-Anteil bei Winkelregelung
1303
    else                 SummeRoll += DiffRoll;  // I-Anteil bei HH
1260
    else SummeRoll += DiffRoll; // I-Anteil bei HH
1304
    if(SummeRoll >  (STICK_GAIN * 16000L)) SummeRoll =  (STICK_GAIN * 16000L);
1261
    if (SummeRoll > (STICK_GAIN * 16000L)) SummeRoll = (STICK_GAIN * 16000L);
1305
    if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN);
1262
    if (SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN);
1306
    pd_ergebnis = DiffRoll + Ki * SummeRoll;    // PI-Regler für Roll
1263
    pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll
1307
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1264
    tmp_int = (long) ((long) Parameter_DynamicStability * (long) (GasMischanteil + abs(GierMischanteil) / 2)) / 64;
1308
    if(pd_ergebnis >  tmp_int) pd_ergebnis =  tmp_int;
1265
    if (pd_ergebnis > tmp_int) pd_ergebnis = tmp_int;
1309
    if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1266
    if (pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1310
    // Motor Links
1267
    // Motor Links
1311
    motorwert = GasMischanteil + pd_ergebnis - GierMischanteil;
1268
    motorwert = GasMischanteil + pd_ergebnis - GierMischanteil;
1312
    motorwert /= STICK_GAIN;
1269
    motorwert /= STICK_GAIN;
1313
        if ((motorwert < 0)) motorwert = 0;
1270
    if ((motorwert < 0)) motorwert = 0;
1314
        else if(motorwert > MAX_GAS)            motorwert = MAX_GAS;
1271
    else if (motorwert > MAX_GAS) motorwert = MAX_GAS;
1315
        if (motorwert < MIN_GAS)            motorwert = MIN_GAS;
1272
    if (motorwert < MIN_GAS) motorwert = MIN_GAS;
1316
    Motor_Links = motorwert;
1273
    Motor_Links = motorwert;
1317
    // Motor Rechts
1274
    // Motor Rechts
1318
        motorwert = GasMischanteil - pd_ergebnis - GierMischanteil;
1275
    motorwert = GasMischanteil - pd_ergebnis - GierMischanteil;
1319
    motorwert /= STICK_GAIN;
1276
    motorwert /= STICK_GAIN;
1320
        if ((motorwert < 0)) motorwert = 0;
1277
    if ((motorwert < 0)) motorwert = 0;
1321
        else if(motorwert > MAX_GAS)            motorwert = MAX_GAS;
1278
    else if (motorwert > MAX_GAS) motorwert = MAX_GAS;