Subversion Repositories FlightCtrl

Rev

Rev 1166 | Rev 1171 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1166 Rev 1167
1
/*#######################################################################################
1
/*#######################################################################################
2
Flight Control
2
Flight Control
3
#######################################################################################*/
3
#######################################################################################*/
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
// + Copyright (c) 04.2007 Holger Buss
5
// + Copyright (c) 04.2007 Holger Buss
6
// + Nur für den privaten Gebrauch
6
// + Nur für den privaten Gebrauch
7
// + www.MikroKopter.com
7
// + www.MikroKopter.com
8
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
9
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
10
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
10
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
11
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
11
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
12
// + bzgl. der Nutzungsbedingungen aufzunehmen.
12
// + bzgl. der Nutzungsbedingungen aufzunehmen.
13
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
13
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
14
// + Verkauf von Luftbildaufnahmen, usw.
14
// + Verkauf von Luftbildaufnahmen, usw.
15
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
16
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
17
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
17
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
18
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
19
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
20
// + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
20
// + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
21
// + eindeutig als Ursprung verlinkt werden
21
// + eindeutig als Ursprung verlinkt werden
22
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
23
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
24
// + Benutzung auf eigene Gefahr
24
// + Benutzung auf eigene Gefahr
25
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
25
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
26
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27
// + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
27
// + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
28
// + mit unserer Zustimmung zulässig
28
// + mit unserer Zustimmung zulässig
29
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
30
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
31
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
32
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
33
// + this list of conditions and the following disclaimer.
33
// + this list of conditions and the following disclaimer.
34
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
34
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
35
// +     from this software without specific prior written permission.
35
// +     from this software without specific prior written permission.
36
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permittet
36
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permittet
37
// +     for non-commercial use (directly or indirectly)
37
// +     for non-commercial use (directly or indirectly)
38
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
38
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
39
// +     with our written permission
39
// +     with our written permission
40
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
40
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
41
// +     clearly linked as origin
41
// +     clearly linked as origin
42
// +   * porting to systems other than hardware from www.mikrokopter.de is not allowed
42
// +   * porting to systems other than hardware from www.mikrokopter.de is not allowed
43
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
46
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
47
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
48
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52
// +  POSSIBILITY OF SUCH DAMAGE.
52
// +  POSSIBILITY OF SUCH DAMAGE.
53
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54
 
54
 
55
#include "main.h"
55
#include "main.h"
56
#include "eeprom.c"
56
#include "eeprom.c"
57
 
57
 
58
unsigned char h,m,s;
58
unsigned char h,m,s;
59
volatile unsigned int I2CTimeout = 100;
59
volatile unsigned int I2CTimeout = 100;
60
int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias, RohMesswertNick,RohMesswertRoll;
60
int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias, RohMesswertNick,RohMesswertRoll;
61
int TrimNick, TrimRoll;
61
int TrimNick, TrimRoll;
62
int AdNeutralGierBias;
62
int AdNeutralGierBias;
63
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
63
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
64
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
64
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
65
int NaviAccNick, NaviAccRoll,NaviCntAcc = 0;
65
int NaviAccNick, NaviAccRoll,NaviCntAcc = 0;
66
volatile float NeutralAccZ = 0;
66
volatile float NeutralAccZ = 0;
67
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
67
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
68
long IntegralNick = 0,IntegralNick2 = 0;
68
long IntegralNick = 0,IntegralNick2 = 0;
69
long IntegralRoll = 0,IntegralRoll2 = 0;
69
long IntegralRoll = 0,IntegralRoll2 = 0;
70
long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
70
long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
71
long Integral_Gier = 0;
71
long Integral_Gier = 0;
72
long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0;
72
long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0;
73
long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0;
73
long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0;
74
long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0;
74
long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0;
75
long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2;
75
long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2;
76
volatile long Mess_Integral_Hoch = 0;
76
volatile long Mess_Integral_Hoch = 0;
77
int  KompassValue = 0;
77
int  KompassValue = 0;
78
int  KompassStartwert = 0;
78
int  KompassStartwert = 0;
79
int  KompassRichtung = 0;
79
int  KompassRichtung = 0;
80
unsigned int  KompassSignalSchlecht = 500;
80
unsigned int  KompassSignalSchlecht = 500;
81
unsigned char  MAX_GAS,MIN_GAS;
81
unsigned char  MAX_GAS,MIN_GAS;
82
unsigned char Notlandung = 0;
82
unsigned char Notlandung = 0;
83
unsigned char HoehenReglerAktiv = 0;
83
unsigned char HoehenReglerAktiv = 0;
84
unsigned char TrichterFlug = 0;
84
unsigned char TrichterFlug = 0;
85
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
85
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
86
long  ErsatzKompass;
86
long  ErsatzKompass;
87
int   ErsatzKompassInGrad; // Kompasswert in Grad
87
int   ErsatzKompassInGrad; // Kompasswert in Grad
88
int   GierGyroFehler = 0;
88
int   GierGyroFehler = 0;
89
char GyroFaktor;
89
char GyroFaktor;
90
char IntegralFaktor;
90
char IntegralFaktor;
91
int  DiffNick,DiffRoll;
91
int  DiffNick,DiffRoll;
92
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
92
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
93
volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links;
93
volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links;
94
volatile unsigned char Motor1, Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8;
94
volatile unsigned char Motor1, Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8;
95
volatile unsigned char SenderOkay = 0;
95
volatile unsigned char SenderOkay = 0;
96
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
96
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
97
char MotorenEin = 0;
97
char MotorenEin = 0;
98
int HoehenWert = 0;
98
int HoehenWert = 0;
99
int SollHoehe = 0;
99
int SollHoehe = 0;
100
int LageKorrekturRoll = 0,LageKorrekturNick = 0;
100
int LageKorrekturRoll = 0,LageKorrekturNick = 0;
101
//float Ki =  FAKTOR_I;
101
//float Ki =  FAKTOR_I;
102
int Ki = 10300 / 33;
102
int Ki = 10300 / 33;
103
unsigned char Looping_Nick = 0,Looping_Roll = 0;
103
unsigned char Looping_Nick = 0,Looping_Roll = 0;
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_D = 8;             // Wert : 0-250
111
unsigned char Parameter_Gyro_D = 8;             // Wert : 0-250
112
unsigned char Parameter_Gyro_P = 150;           // Wert : 10-250
112
unsigned char Parameter_Gyro_P = 150;           // Wert : 10-250
113
unsigned char Parameter_Gyro_I = 150;           // Wert : 0-250
113
unsigned char Parameter_Gyro_I = 150;           // Wert : 0-250
114
unsigned char Parameter_Gier_P = 2;             // Wert : 1-20
114
unsigned char Parameter_Gier_P = 2;             // Wert : 1-20
115
unsigned char Parameter_I_Faktor = 10;          // Wert : 1-20
115
unsigned char Parameter_I_Faktor = 10;          // Wert : 1-20
116
unsigned char Parameter_UserParam1 = 0;
116
unsigned char Parameter_UserParam1 = 0;
117
unsigned char Parameter_UserParam2 = 0;
117
unsigned char Parameter_UserParam2 = 0;
118
unsigned char Parameter_UserParam3 = 0;
118
unsigned char Parameter_UserParam3 = 0;
119
unsigned char Parameter_UserParam4 = 0;
119
unsigned char Parameter_UserParam4 = 0;
120
unsigned char Parameter_UserParam5 = 0;
120
unsigned char Parameter_UserParam5 = 0;
121
unsigned char Parameter_UserParam6 = 0;
121
unsigned char Parameter_UserParam6 = 0;
122
unsigned char Parameter_UserParam7 = 0;
122
unsigned char Parameter_UserParam7 = 0;
123
unsigned char Parameter_UserParam8 = 0;
123
unsigned char Parameter_UserParam8 = 0;
124
unsigned char Parameter_ServoNickControl = 100;
124
unsigned char Parameter_ServoNickControl = 100;
125
unsigned char Parameter_LoopGasLimit = 70;
125
unsigned char Parameter_LoopGasLimit = 70;
126
unsigned char Parameter_AchsKopplung1 = 90;
126
unsigned char Parameter_AchsKopplung1 = 90;
127
unsigned char Parameter_AchsKopplung2 = 65;
127
unsigned char Parameter_AchsKopplung2 = 65;
128
unsigned char Parameter_CouplingYawCorrection = 64;
128
unsigned char Parameter_CouplingYawCorrection = 64;
129
//unsigned char Parameter_AchsGegenKopplung1 = 0;
129
//unsigned char Parameter_AchsGegenKopplung1 = 0;
130
unsigned char Parameter_DynamicStability = 100;
130
unsigned char Parameter_DynamicStability = 100;
131
unsigned char Parameter_J16Bitmask;             // for the J16 Output
131
unsigned char Parameter_J16Bitmask;             // for the J16 Output
132
unsigned char Parameter_J16Timing;              // for the J16 Output
132
unsigned char Parameter_J16Timing;              // for the J16 Output
133
unsigned char Parameter_J17Bitmask;             // for the J17 Output
133
unsigned char Parameter_J17Bitmask;             // for the J17 Output
134
unsigned char Parameter_J17Timing;              // for the J17 Output
134
unsigned char Parameter_J17Timing;              // for the J17 Output
135
unsigned char Parameter_NaviGpsModeControl;     // Parameters for the Naviboard
135
unsigned char Parameter_NaviGpsModeControl;     // Parameters for the Naviboard
136
unsigned char Parameter_NaviGpsGain;
136
unsigned char Parameter_NaviGpsGain;
137
unsigned char Parameter_NaviGpsP;
137
unsigned char Parameter_NaviGpsP;
138
unsigned char Parameter_NaviGpsI;
138
unsigned char Parameter_NaviGpsI;
139
unsigned char Parameter_NaviGpsD;
139
unsigned char Parameter_NaviGpsD;
140
unsigned char Parameter_NaviGpsACC;
140
unsigned char Parameter_NaviGpsACC;
141
unsigned char Parameter_NaviOperatingRadius;
141
unsigned char Parameter_NaviOperatingRadius;
142
unsigned char Parameter_NaviWindCorrection;
142
unsigned char Parameter_NaviWindCorrection;
143
unsigned char Parameter_NaviSpeedCompensation;
143
unsigned char Parameter_NaviSpeedCompensation;
144
unsigned char Parameter_ExternalControl;
144
unsigned char Parameter_ExternalControl;
145
struct mk_param_struct EE_Parameter;
145
struct mk_param_struct EE_Parameter;
146
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
146
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
147
int MaxStickNick = 0,MaxStickRoll = 0;
147
int MaxStickNick = 0,MaxStickRoll = 0;
148
unsigned int  modell_fliegt = 0;
148
unsigned int  modell_fliegt = 0;
149
unsigned char MikroKopterFlags = 0;
149
unsigned char MikroKopterFlags = 0;
150
long GIER_GRAD_FAKTOR = 1291;
150
long GIER_GRAD_FAKTOR = 1291;
151
signed int KopplungsteilNickRoll,KopplungsteilRollNick;
151
signed int KopplungsteilNickRoll,KopplungsteilRollNick;
152
 
152
 
153
 
153
 
154
int MotorSmoothing(int neu, int alt)
154
int MotorSmoothing(int neu, int alt)
155
{
155
{
156
 int motor;
156
 int motor;
157
 if(neu > alt) motor = (1*(int)alt + neu) / 2;
157
 if(neu > alt) motor = (1*(int)alt + neu) / 2;
158
 else   motor = neu - (alt - neu)*1;
158
 else   motor = neu - (alt - neu)*1;
159
//if(Poti2 < 20)  return(neu);
159
//if(Poti2 < 20)  return(neu);
160
 return(motor);
160
 return(motor);
161
}
161
}
162
 
162
 
163
 
163
 
164
void Piep(unsigned char Anzahl)
164
void Piep(unsigned char Anzahl)
165
{
165
{
166
 while(Anzahl--)
166
 while(Anzahl--)
167
 {
167
 {
168
  if(MotorenEin) return; //auf keinen Fall im Flug!
168
  if(MotorenEin) return; //auf keinen Fall im Flug!
169
  beeptime = 100;
169
  beeptime = 100;
170
  Delay_ms(250);
170
  Delay_ms(250);
171
 }
171
 }
172
}
172
}
173
 
173
 
174
//############################################################################
174
//############################################################################
175
//  Nullwerte ermitteln
175
//  Nullwerte ermitteln
176
void SetNeutral(void)
176
void SetNeutral(void)
177
//############################################################################
177
//############################################################################
178
{
178
{
179
 unsigned char i;
179
 unsigned char i;
180
 unsigned int gier_neutral=0, nick_neutral=0, roll_neutral=0;
180
 unsigned int gier_neutral=0, nick_neutral=0, roll_neutral=0;
181
        NeutralAccX = 0;
181
        NeutralAccX = 0;
182
        NeutralAccY = 0;
182
        NeutralAccY = 0;
183
        NeutralAccZ = 0;
183
        NeutralAccZ = 0;
184
    AdNeutralNick = 0;
184
    AdNeutralNick = 0;
185
        AdNeutralRoll = 0;
185
        AdNeutralRoll = 0;
186
        AdNeutralGier = 0;
186
        AdNeutralGier = 0;
187
    AdNeutralGierBias = 0;
187
    AdNeutralGierBias = 0;
188
    Parameter_AchsKopplung1 = 0;
188
    Parameter_AchsKopplung1 = 0;
189
    Parameter_AchsKopplung2 = 0;
189
    Parameter_AchsKopplung2 = 0;
190
    ExpandBaro = 0;
190
    ExpandBaro = 0;
191
    CalibrierMittelwert();
191
    CalibrierMittelwert();
192
    Delay_ms_Mess(100);
192
    Delay_ms_Mess(100);
193
        CalibrierMittelwert();
193
        CalibrierMittelwert();
194
    if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
194
    if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
195
     {
195
     {
196
      if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
196
      if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
197
     }
197
     }
198
#define NEUTRAL_FILTER 32
198
#define NEUTRAL_FILTER 32
199
    for(i=0; i<NEUTRAL_FILTER; i++)
199
    for(i=0; i<NEUTRAL_FILTER; i++)
200
         {
200
         {
201
          Delay_ms_Mess(10);
201
          Delay_ms_Mess(10);
202
          gier_neutral += AdWertGier;
202
          gier_neutral += AdWertGier;
203
          nick_neutral += AdWertNick;
203
          nick_neutral += AdWertNick;
204
          roll_neutral += AdWertRoll;
204
          roll_neutral += AdWertRoll;
205
         }
205
         }
206
     AdNeutralNick= nick_neutral / NEUTRAL_FILTER;
206
     AdNeutralNick= nick_neutral / NEUTRAL_FILTER;
207
         AdNeutralRoll= roll_neutral / NEUTRAL_FILTER;
207
         AdNeutralRoll= roll_neutral / NEUTRAL_FILTER;
208
         AdNeutralGier= gier_neutral / NEUTRAL_FILTER;
208
         AdNeutralGier= gier_neutral / NEUTRAL_FILTER;
209
     AdNeutralGierBias = AdNeutralGier;
209
     AdNeutralGierBias = AdNeutralGier;
210
     StartNeutralRoll = AdNeutralRoll;
210
     StartNeutralRoll = AdNeutralRoll;
211
     StartNeutralNick = AdNeutralNick;
211
     StartNeutralNick = AdNeutralNick;
212
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
212
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
213
    {
213
    {
214
      NeutralAccY = abs(Mittelwert_AccRoll) / (4*ACC_AMPLIFY);
214
      NeutralAccY = abs(Mittelwert_AccRoll) / (4*ACC_AMPLIFY);
215
          NeutralAccX = abs(Mittelwert_AccNick) / (4*ACC_AMPLIFY);
215
          NeutralAccX = abs(Mittelwert_AccNick) / (4*ACC_AMPLIFY);
216
          NeutralAccZ = Aktuell_az;
216
          NeutralAccZ = Aktuell_az;
217
    }
217
    }
218
    else
218
    else
219
    {
219
    {
220
      NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]);
220
      NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]);
221
          NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]);
221
          NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]);
222
          NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]);
222
          NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]);
223
    }
223
    }
224
 
224
 
225
        Mess_IntegralNick = 0;
225
        Mess_IntegralNick = 0;
226
    Mess_IntegralNick2 = 0;
226
    Mess_IntegralNick2 = 0;
227
    Mess_IntegralRoll = 0;
227
    Mess_IntegralRoll = 0;
228
    Mess_IntegralRoll2 = 0;
228
    Mess_IntegralRoll2 = 0;
229
    Mess_Integral_Gier = 0;
229
    Mess_Integral_Gier = 0;
230
    MesswertNick = 0;
230
    MesswertNick = 0;
231
    MesswertRoll = 0;
231
    MesswertRoll = 0;
232
    MesswertGier = 0;
232
    MesswertGier = 0;
233
    Delay_ms_Mess(100);
233
    Delay_ms_Mess(100);
234
    StartLuftdruck = Luftdruck;
234
    StartLuftdruck = Luftdruck;
235
    HoeheD = 0;
235
    HoeheD = 0;
236
    Mess_Integral_Hoch = 0;
236
    Mess_Integral_Hoch = 0;
237
    KompassStartwert = KompassValue;
237
    KompassStartwert = KompassValue;
238
    GPS_Neutral();
238
    GPS_Neutral();
239
    beeptime = 50;
239
    beeptime = 50;
240
        Umschlag180Nick = ((long) EE_Parameter.WinkelUmschlagNick * 2500L) + 15000L;
240
        Umschlag180Nick = ((long) EE_Parameter.WinkelUmschlagNick * 2500L) + 15000L;
241
        Umschlag180Roll = ((long) EE_Parameter.WinkelUmschlagRoll * 2500L) + 15000L;
241
        Umschlag180Roll = ((long) EE_Parameter.WinkelUmschlagRoll * 2500L) + 15000L;
242
    ExternHoehenValue = 0;
242
    ExternHoehenValue = 0;
243
    ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
243
    ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
244
    GierGyroFehler = 0;
244
    GierGyroFehler = 0;
245
    SendVersionToNavi = 1;
245
    SendVersionToNavi = 1;
246
    LED_Init();
246
    LED_Init();
247
    MikroKopterFlags |= FLAG_CALIBRATE;
247
    MikroKopterFlags |= FLAG_CALIBRATE;
248
    FromNaviCtrl_Value.Kalman_K = -1;
248
    FromNaviCtrl_Value.Kalman_K = -1;
249
    FromNaviCtrl_Value.Kalman_MaxDrift = EE_Parameter.Driftkomp * 16;
249
    FromNaviCtrl_Value.Kalman_MaxDrift = EE_Parameter.Driftkomp * 16;
250
    FromNaviCtrl_Value.Kalman_MaxFusion = 32;
250
    FromNaviCtrl_Value.Kalman_MaxFusion = 32;
251
}
251
}
252
 
252
 
253
//############################################################################
253
//############################################################################
254
// Bearbeitet die Messwerte
254
// Bearbeitet die Messwerte
255
void Mittelwert(void)
255
void Mittelwert(void)
256
//############################################################################
256
//############################################################################
257
{
257
{
258
    static signed long tmpl,tmpl2,tmpl3,tmpl4;
258
    static signed long tmpl,tmpl2,tmpl3,tmpl4;
259
        static signed int oldNick, oldRoll, d2Roll, d2Nick;
259
        static signed int oldNick, oldRoll, d2Roll, d2Nick;
260
        signed int tmp_int;
260
        signed int tmp_int;
261
        signed long winkel_nick, winkel_roll;
261
        signed long winkel_nick, winkel_roll;
262
        MesswertGier = (signed int) AdNeutralGier - AdWertGier;
262
        MesswertGier = (signed int) AdNeutralGier - AdWertGier;
263
//    MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier;
263
//    MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier;
264
    MesswertNick = (signed int) AdWertNickFilter / 20;
264
    MesswertNick = (signed int) AdWertNickFilter / 20;
265
    MesswertRoll = (signed int) AdWertRollFilter / 20;
265
    MesswertRoll = (signed int) AdWertRollFilter / 20;
266
    RohMesswertNick = MesswertNick;
266
    RohMesswertNick = MesswertNick;
267
    RohMesswertRoll = MesswertRoll;
267
    RohMesswertRoll = MesswertRoll;
268
//DebugOut.Analog[21] = MesswertNick;
268
//DebugOut.Analog[21] = MesswertNick;
269
//DebugOut.Analog[22] = MesswertRoll;
269
//DebugOut.Analog[22] = MesswertRoll;
270
//DebugOut.Analog[22] = Mess_Integral_Gier;
270
//DebugOut.Analog[22] = Mess_Integral_Gier;
271
 
-
 
272
//DebugOut.Analog[21] = MesswertNick;  
271
//DebugOut.Analog[21] = MesswertNick;  
273
//DebugOut.Analog[22] = MesswertRoll; 
272
//DebugOut.Analog[22] = MesswertRoll; 
274
 
273
 
275
// Beschleunigungssensor  ++++++++++++++++++++++++++++++++++++++++++++++++
274
// Beschleunigungssensor  ++++++++++++++++++++++++++++++++++++++++++++++++
276
        Mittelwert_AccNick = ((long)Mittelwert_AccNick * 3 + ((ACC_AMPLIFY * (long)AdWertAccNick))) / 4L;
275
        Mittelwert_AccNick = ((long)Mittelwert_AccNick * 3 + ((ACC_AMPLIFY * (long)AdWertAccNick))) / 4L;
277
        Mittelwert_AccRoll = ((long)Mittelwert_AccRoll * 3 + ((ACC_AMPLIFY * (long)AdWertAccRoll))) / 4L;
276
        Mittelwert_AccRoll = ((long)Mittelwert_AccRoll * 3 + ((ACC_AMPLIFY * (long)AdWertAccRoll))) / 4L;
278
        Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 3 + ((long)AdWertAccHoch)) / 4L;
277
        Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 3 + ((long)AdWertAccHoch)) / 4L;
279
    IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
278
    IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
280
    IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
279
    IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
281
    NaviAccNick    += AdWertAccNick;
280
    NaviAccNick    += AdWertAccNick;
282
    NaviAccRoll    += AdWertAccRoll;
281
    NaviAccRoll    += AdWertAccRoll;
283
    NaviCntAcc++;
282
    NaviCntAcc++;
284
    IntegralAccZ  += Aktuell_az - NeutralAccZ;
283
    IntegralAccZ  += Aktuell_az - NeutralAccZ;
285
 
284
 
286
//++++++++++++++++++++++++++++++++++++++++++++++++
285
//++++++++++++++++++++++++++++++++++++++++++++++++
287
// ADC einschalten
286
// ADC einschalten
288
        AdReady = 0;
287
        AdReady = 0;
289
    ANALOG_ON;
288
    ANALOG_ON;
290
//++++++++++++++++++++++++++++++++++++++++++++++++
289
//++++++++++++++++++++++++++++++++++++++++++++++++
291
 
290
 
292
    if(Mess_IntegralRoll > 93000L) winkel_roll = 93000L;
291
    if(Mess_IntegralRoll > 93000L) winkel_roll = 93000L;
293
        else if(Mess_IntegralRoll <-93000L) winkel_roll = -93000L;
292
        else if(Mess_IntegralRoll <-93000L) winkel_roll = -93000L;
294
        else winkel_roll = Mess_IntegralRoll;
293
        else winkel_roll = Mess_IntegralRoll;
295
 
294
 
296
    if(Mess_IntegralNick > 93000L) winkel_nick = 93000L;
295
    if(Mess_IntegralNick > 93000L) winkel_nick = 93000L;
297
        else if(Mess_IntegralNick <-93000L) winkel_nick = -93000L;
296
        else if(Mess_IntegralNick <-93000L) winkel_nick = -93000L;
298
        else winkel_nick = Mess_IntegralNick;
297
        else winkel_nick = Mess_IntegralNick;
299
 
298
 
300
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
299
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
301
   Mess_Integral_Gier += MesswertGier;
300
   Mess_Integral_Gier += MesswertGier;
302
   ErsatzKompass += MesswertGier;
301
   ErsatzKompass += MesswertGier;
303
 
302
 
304
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
303
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
305
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
304
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
306
         {
305
         {
307
            tmpl3 = (MesswertRoll * winkel_nick) / 2048L;
306
            tmpl3 = (MesswertRoll * winkel_nick) / 2048L;
308
            tmpl3 *= Parameter_AchsKopplung2; //65
307
            tmpl3 *= Parameter_AchsKopplung2; //65
309
            tmpl3 /= 4096L;
308
            tmpl3 /= 4096L;
310
            tmpl4 = (MesswertNick * winkel_roll) / 2048L;
309
            tmpl4 = (MesswertNick * winkel_roll) / 2048L;
311
            tmpl4 *= Parameter_AchsKopplung2; //65  
310
            tmpl4 *= Parameter_AchsKopplung2; //65  
312
            tmpl4 /= 4096L;
311
            tmpl4 /= 4096L;
313
            KopplungsteilNickRoll = tmpl3;
312
            KopplungsteilNickRoll = tmpl3;
314
            KopplungsteilRollNick = tmpl4;
313
            KopplungsteilRollNick = tmpl4;
315
            tmpl4 -= tmpl3;
314
            tmpl4 -= tmpl3;
316
            ErsatzKompass += tmpl4;
315
            ErsatzKompass += tmpl4;
317
            if(!Parameter_CouplingYawCorrection) Mess_Integral_Gier -= tmpl4/2; // Gier nachhelfen
316
            if(!Parameter_CouplingYawCorrection) Mess_Integral_Gier -= tmpl4/2; // Gier nachhelfen
318
 
317
 
319
            tmpl = ((MesswertGier + tmpl4) * winkel_nick) / 2048L;
318
            tmpl = ((MesswertGier + tmpl4) * winkel_nick) / 2048L;
320
            tmpl *= Parameter_AchsKopplung1;  // 90
319
            tmpl *= Parameter_AchsKopplung1;  // 90
321
            tmpl /= 4096L;
320
            tmpl /= 4096L;
322
            tmpl2 = ((MesswertGier + tmpl4) * winkel_roll) / 2048L;
321
            tmpl2 = ((MesswertGier + tmpl4) * winkel_roll) / 2048L;
323
            tmpl2 *= Parameter_AchsKopplung1;
322
            tmpl2 *= Parameter_AchsKopplung1;
324
            tmpl2 /= 4096L;
323
            tmpl2 /= 4096L;
325
            if(labs(tmpl) > 128 || labs(tmpl2) > 128 /* || abs(KopplungsteilNickRoll) > 128 || abs(KopplungsteilRollNick) > 128)*/) TrichterFlug = 1;
324
            if(labs(tmpl) > 128 || labs(tmpl2) > 128 /* || abs(KopplungsteilNickRoll) > 128 || abs(KopplungsteilRollNick) > 128)*/) TrichterFlug = 1;
326
            //MesswertGier += (Parameter_CouplingYawCorrection * tmpl4) / 256;
325
            //MesswertGier += (Parameter_CouplingYawCorrection * tmpl4) / 256;
327
         }
326
         }
328
      else  tmpl = tmpl2 = KopplungsteilNickRoll = KopplungsteilRollNick = 0;
327
      else  tmpl = tmpl2 = KopplungsteilNickRoll = KopplungsteilRollNick = 0;
329
 
328
 
330
TrimRoll = tmpl - tmpl2 / 100L;
329
TrimRoll = tmpl - tmpl2 / 100L;
331
TrimNick = -tmpl2 + tmpl / 100L;
330
TrimNick = -tmpl2 + tmpl / 100L;
332
 
331
 
333
// Kompasswert begrenzen  ++++++++++++++++++++++++++++++++++++++++++++++++
332
// Kompasswert begrenzen  ++++++++++++++++++++++++++++++++++++++++++++++++
334
                    if(ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR;  // 360° Umschlag
333
                    if(ErsatzKompass >= (360L * GIER_GRAD_FAKTOR)) ErsatzKompass -= 360L * GIER_GRAD_FAKTOR;  // 360° Umschlag
335
                    if(ErsatzKompass < 0)                          ErsatzKompass += 360L * GIER_GRAD_FAKTOR;
334
                    if(ErsatzKompass < 0)                          ErsatzKompass += 360L * GIER_GRAD_FAKTOR;
336
// Roll  ++++++++++++++++++++++++++++++++++++++++++++++++
335
// Roll  ++++++++++++++++++++++++++++++++++++++++++++++++
337
//            MesswertRoll += tmpl;
-
 
338
//            MesswertRoll += tmpl2 / 100L; // War: *5/512
-
 
339
//            MesswertRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109
-
 
340
            Mess_IntegralRoll2 += MesswertRoll + TrimRoll;
336
            Mess_IntegralRoll2 += MesswertRoll + TrimRoll;
341
            Mess_IntegralRoll +=  MesswertRoll + TrimRoll - LageKorrekturRoll;
337
            Mess_IntegralRoll +=  MesswertRoll + TrimRoll - LageKorrekturRoll;
342
 
-
 
343
            if(Mess_IntegralRoll > Umschlag180Roll)
338
            if(Mess_IntegralRoll > Umschlag180Roll)
344
            {
339
            {
345
             Mess_IntegralRoll  = -(Umschlag180Roll - 25000L);
340
             Mess_IntegralRoll  = -(Umschlag180Roll - 25000L);
346
             Mess_IntegralRoll2 = Mess_IntegralRoll;
341
             Mess_IntegralRoll2 = Mess_IntegralRoll;
347
            }
342
            }
348
            if(Mess_IntegralRoll <-Umschlag180Roll)
343
            if(Mess_IntegralRoll <-Umschlag180Roll)
349
            {
344
            {
350
             Mess_IntegralRoll =  (Umschlag180Roll - 25000L);
345
             Mess_IntegralRoll =  (Umschlag180Roll - 25000L);
351
             Mess_IntegralRoll2 = Mess_IntegralRoll;
346
             Mess_IntegralRoll2 = Mess_IntegralRoll;
352
            }
347
            }
353
            if(AdWertRoll < 15)   MesswertRoll = -1000;
-
 
354
            if(AdWertRoll <  7)   MesswertRoll = -2000;
-
 
355
            if(PlatinenVersion == 10)
-
 
356
                         {
-
 
357
              if(AdWertRoll > 1010) MesswertRoll = +1000;
-
 
358
              if(AdWertRoll > 1017) MesswertRoll = +2000;
-
 
359
                         }
-
 
360
                         else
-
 
361
                         {
-
 
362
              if(AdWertRoll > 2000) MesswertRoll = +1000;
-
 
363
              if(AdWertRoll > 2015) MesswertRoll = +2000;
-
 
364
                         }
-
 
365
// Nick  ++++++++++++++++++++++++++++++++++++++++++++++++
348
// Nick  ++++++++++++++++++++++++++++++++++++++++++++++++
366
//            MesswertNick -= tmpl2;
-
 
367
//            MesswertNick -= (tmpl*Parameter_AchsGegenKopplung1)/512L; 
-
 
368
//            MesswertNick -= tmpl / 100L; //109
-
 
369
            Mess_IntegralNick2 += MesswertNick + TrimNick;
349
            Mess_IntegralNick2 += MesswertNick + TrimNick;
370
            Mess_IntegralNick  += MesswertNick + TrimNick - LageKorrekturNick;
350
            Mess_IntegralNick  += MesswertNick + TrimNick - LageKorrekturNick;
371
 
-
 
372
            if(Mess_IntegralNick > Umschlag180Nick)
351
            if(Mess_IntegralNick > Umschlag180Nick)
373
             {
352
             {
374
              Mess_IntegralNick = -(Umschlag180Nick - 25000L);
353
              Mess_IntegralNick = -(Umschlag180Nick - 25000L);
375
              Mess_IntegralNick2 = Mess_IntegralNick;
354
              Mess_IntegralNick2 = Mess_IntegralNick;
376
             }
355
             }
377
            if(Mess_IntegralNick <-Umschlag180Nick)
356
            if(Mess_IntegralNick <-Umschlag180Nick)
378
            {
357
            {
379
             Mess_IntegralNick =  (Umschlag180Nick - 25000L);
358
             Mess_IntegralNick =  (Umschlag180Nick - 25000L);
380
             Mess_IntegralNick2 = Mess_IntegralNick;
359
             Mess_IntegralNick2 = Mess_IntegralNick;
381
            }
360
            }
382
            if(AdWertNick < 15)   MesswertNick = -1000;
-
 
383
            if(AdWertNick <  7)   MesswertNick = -2000;
-
 
384
            if(PlatinenVersion == 10)
-
 
385
                         {
-
 
386
              if(AdWertNick > 1010) MesswertNick = +1000;
-
 
387
              if(AdWertNick > 1017) MesswertNick = +2000;
-
 
388
                         }
-
 
389
                         else
-
 
390
                         {
-
 
391
              if(AdWertNick > 2000) MesswertNick = +1000;
-
 
392
              if(AdWertNick > 2015) MesswertNick = +2000;
-
 
393
                         }
-
 
394
 
361
 
395
    Integral_Gier  = Mess_Integral_Gier;
362
    Integral_Gier  = Mess_Integral_Gier;
396
    IntegralNick = Mess_IntegralNick;
363
    IntegralNick = Mess_IntegralNick;
397
    IntegralRoll = Mess_IntegralRoll;
364
    IntegralRoll = Mess_IntegralRoll;
398
    IntegralNick2 = Mess_IntegralNick2;
365
    IntegralNick2 = Mess_IntegralNick2;
399
    IntegralRoll2 = Mess_IntegralRoll2;
366
    IntegralRoll2 = Mess_IntegralRoll2;
400
//    MesswertNick = (RohMesswertNick + 2 * MesswertNick) / 3;
-
 
401
//    MesswertRoll = (RohMesswertRoll + 2 * MesswertRoll) / 3;
-
 
402
 
367
 
403
#define D_LIMIT 128
368
#define D_LIMIT 128
404
 
369
 
405
MesswertNick = HiResNick / 20;
370
   MesswertNick = HiResNick / 20;
-
 
371
   MesswertRoll = HiResRoll / 20;
-
 
372
 
-
 
373
   if(AdWertNick < 15)   MesswertNick = -1000;  if(AdWertNick <  7)   MesswertNick = -2000;
-
 
374
   if(PlatinenVersion == 10)  { if(AdWertNick > 1010) MesswertNick = +1000;  if(AdWertNick > 1017) MesswertNick = +2000; }
-
 
375
   else  {  if(AdWertNick > 2000) MesswertNick = +1000;  if(AdWertNick > 2015) MesswertNick = +2000; }
-
 
376
   if(AdWertRoll < 15)   MesswertRoll = -1000;  if(AdWertRoll <  7)   MesswertRoll = -2000;
-
 
377
   if(PlatinenVersion == 10) { if(AdWertRoll > 1010) MesswertRoll = +1000;  if(AdWertRoll > 1017) MesswertRoll = +2000; }
406
MesswertRoll = HiResRoll / 20;
378
   else { if(AdWertRoll > 2000) MesswertRoll = +1000;  if(AdWertRoll > 2015) MesswertRoll = +2000;  }
407
 
379
 
408
  if(Parameter_Gyro_D)
380
  if(Parameter_Gyro_D)
409
  {
381
  {
410
   d2Nick = HiResNick - oldNick;
382
   d2Nick = HiResNick - oldNick;
411
   oldNick = (oldNick + HiResNick)/2;
383
   oldNick = (oldNick + HiResNick)/2;
412
   if(d2Nick > D_LIMIT) d2Nick = D_LIMIT;
384
   if(d2Nick > D_LIMIT) d2Nick = D_LIMIT;
413
   else if(d2Nick < -D_LIMIT) d2Nick = -D_LIMIT;
385
   else if(d2Nick < -D_LIMIT) d2Nick = -D_LIMIT;
414
   MesswertNick += (d2Nick * (signed int) Parameter_Gyro_D) / 16;
386
   MesswertNick += (d2Nick * (signed int) Parameter_Gyro_D) / 16;
415
   d2Roll = HiResRoll - oldRoll;
387
   d2Roll = HiResRoll - oldRoll;
416
   oldRoll = (oldRoll + HiResRoll)/2;
388
   oldRoll = (oldRoll + HiResRoll)/2;
417
   if(d2Roll > D_LIMIT) d2Roll = D_LIMIT;
389
   if(d2Roll > D_LIMIT) d2Roll = D_LIMIT;
418
   else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT;
390
   else if(d2Roll < -D_LIMIT) d2Roll = -D_LIMIT;
419
   MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16;
391
   MesswertRoll += (d2Roll * (signed int) Parameter_Gyro_D) / 16;
420
   HiResNick += (d2Nick * (signed int) Parameter_Gyro_D);
392
   HiResNick += (d2Nick * (signed int) Parameter_Gyro_D);
421
   HiResRoll += (d2Roll * (signed int) Parameter_Gyro_D);
393
   HiResRoll += (d2Roll * (signed int) Parameter_Gyro_D);
422
  }
394
  }
423
 
395
 
424
 if(RohMesswertRoll > 0) TrimRoll  += ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
396
 if(RohMesswertRoll > 0) TrimRoll  += ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
425
 else                    TrimRoll -= ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
397
 else                    TrimRoll -= ((long) abs(KopplungsteilNickRoll) * Parameter_CouplingYawCorrection) / 64L;
426
 if(RohMesswertNick > 0) TrimNick += ((long) abs(KopplungsteilRollNick) * Parameter_CouplingYawCorrection) / 64L;
398
 if(RohMesswertNick > 0) TrimNick += ((long) abs(KopplungsteilRollNick) * Parameter_CouplingYawCorrection) / 64L;
427
 else                    TrimNick -= ((long) abs(KopplungsteilRollNick) * Parameter_CouplingYawCorrection) / 64L;
399
 else                    TrimNick -= ((long) abs(KopplungsteilRollNick) * Parameter_CouplingYawCorrection) / 64L;
428
 
400
 
429
  if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll)
401
  if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll)
430
  {
402
  {
431
    if(RohMesswertNick > 256)       MesswertNick += 1 * (RohMesswertNick - 256);
403
    if(RohMesswertNick > 256)       MesswertNick += 1 * (RohMesswertNick - 256);
432
    else if(RohMesswertNick < -256) MesswertNick += 1 * (RohMesswertNick + 256);
404
    else if(RohMesswertNick < -256) MesswertNick += 1 * (RohMesswertNick + 256);
433
    if(RohMesswertRoll > 256)       MesswertRoll += 1 * (RohMesswertRoll - 256);
405
    if(RohMesswertRoll > 256)       MesswertRoll += 1 * (RohMesswertRoll - 256);
434
    else if(RohMesswertRoll < -256) MesswertRoll += 1 * (RohMesswertRoll + 256);
406
    else if(RohMesswertRoll < -256) MesswertRoll += 1 * (RohMesswertRoll + 256);
435
  }
407
  }
436
 
408
 
437
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
409
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
438
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
410
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
439
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
411
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
440
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
412
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
441
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
413
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
442
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
414
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
443
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
415
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
444
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
416
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
445
}
417
}
446
 
418
 
447
//############################################################################
419
//############################################################################
448
// Messwerte beim Ermitteln der Nullage
420
// Messwerte beim Ermitteln der Nullage
449
void CalibrierMittelwert(void)
421
void CalibrierMittelwert(void)
450
//############################################################################
422
//############################################################################
451
{
423
{
452
    if(PlatinenVersion == 13) SucheGyroOffset();
424
    if(PlatinenVersion == 13) SucheGyroOffset();
453
    // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern
425
    // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern
454
        ANALOG_OFF;
426
        ANALOG_OFF;
455
        MesswertNick = AdWertNick;
427
        MesswertNick = AdWertNick;
456
        MesswertRoll = AdWertRoll;
428
        MesswertRoll = AdWertRoll;
457
        MesswertGier = AdWertGier;
429
        MesswertGier = AdWertGier;
458
        Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick;
430
        Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick;
459
        Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll;
431
        Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll;
460
        Mittelwert_AccHoch = (long)AdWertAccHoch;
432
        Mittelwert_AccHoch = (long)AdWertAccHoch;
461
   // ADC einschalten
433
   // ADC einschalten
462
    ANALOG_ON;
434
    ANALOG_ON;
463
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
435
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
464
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
436
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
465
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
437
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
466
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
438
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
467
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
439
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
468
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
440
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
469
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
441
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
470
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
442
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
471
 
443
 
472
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
444
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
473
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
445
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
474
}
446
}
475
 
447
 
476
//############################################################################
448
//############################################################################
477
// Senden der Motorwerte per I2C-Bus
449
// Senden der Motorwerte per I2C-Bus
478
void SendMotorData(void)
450
void SendMotorData(void)
479
//############################################################################
451
//############################################################################
480
{
452
{
481
    if(!MotorenEin)
453
    if(!MotorenEin)
482
        {
454
        {
483
#ifndef QUADRO
455
#ifndef QUADRO
484
                Motor1 = 0;Motor2 = 0;Motor3 = 0;Motor4 = 0;Motor5 = 0;Motor6 = 0;Motor7 = 0;Motor8 = 0;
456
                Motor1 = 0;Motor2 = 0;Motor3 = 0;Motor4 = 0;Motor5 = 0;Motor6 = 0;Motor7 = 0;Motor8 = 0;
485
        if(MotorTest[0]) {Motor1 = MotorTest[0]; Motor2 = MotorTest[0];}
457
        if(MotorTest[0]) {Motor1 = MotorTest[0]; Motor2 = MotorTest[0];}
486
        if(MotorTest[3]) {Motor3 = MotorTest[3]; Motor4 = MotorTest[3];}
458
        if(MotorTest[3]) {Motor3 = MotorTest[3]; Motor4 = MotorTest[3];}
487
        if(MotorTest[1]) {Motor5 = MotorTest[1]; Motor6 = MotorTest[1];}
459
        if(MotorTest[1]) {Motor5 = MotorTest[1]; Motor6 = MotorTest[1];}
488
        if(MotorTest[2]) {Motor7 = MotorTest[2]; Motor8 = MotorTest[2];}
460
        if(MotorTest[2]) {Motor7 = MotorTest[2]; Motor8 = MotorTest[2];}
489
#else 
461
#else 
490
        Motor_Hinten = 0; Motor_Vorne = 0; Motor_Rechts = 0; Motor_Links = 0;
462
        Motor_Hinten = 0; Motor_Vorne = 0; Motor_Rechts = 0; Motor_Links = 0;
491
        if(MotorTest[0]) Motor_Vorne = MotorTest[0];
463
        if(MotorTest[0]) Motor_Vorne = MotorTest[0];
492
        if(MotorTest[1]) Motor_Hinten = MotorTest[1];
464
        if(MotorTest[1]) Motor_Hinten = MotorTest[1];
493
        if(MotorTest[2]) Motor_Links = MotorTest[2];
465
        if(MotorTest[2]) Motor_Links = MotorTest[2];
494
        if(MotorTest[3]) Motor_Rechts = MotorTest[3];
466
        if(MotorTest[3]) Motor_Rechts = MotorTest[3];
495
#endif
467
#endif
496
 
468
 
497
        MikroKopterFlags &= ~(FLAG_MOTOR_RUN | FLAG_FLY);
469
        MikroKopterFlags &= ~(FLAG_MOTOR_RUN | FLAG_FLY);
498
        } else MikroKopterFlags |= FLAG_MOTOR_RUN;
470
        } else MikroKopterFlags |= FLAG_MOTOR_RUN;
499
 
471
 
500
    DebugOut.Analog[12] = Motor_Vorne;
472
    DebugOut.Analog[12] = Motor_Vorne;
501
    DebugOut.Analog[13] = Motor_Hinten;
473
    DebugOut.Analog[13] = Motor_Hinten;
502
    DebugOut.Analog[14] = Motor_Links;
474
    DebugOut.Analog[14] = Motor_Links;
503
    DebugOut.Analog[15] = Motor_Rechts;
475
    DebugOut.Analog[15] = Motor_Rechts;
504
 
476
 
505
    //Start I2C Interrupt Mode
477
    //Start I2C Interrupt Mode
506
    twi_state = 0;
478
    twi_state = 0;
507
    motor = 0;
479
    motor = 0;
508
    i2c_start();
480
    i2c_start();
509
}
481
}
510
 
482
 
511
 
483
 
512
 
484
 
513
//############################################################################
485
//############################################################################
514
// Trägt ggf. das Poti als Parameter ein
486
// Trägt ggf. das Poti als Parameter ein
515
void ParameterZuordnung(void)
487
void ParameterZuordnung(void)
516
//############################################################################
488
//############################################################################
517
{
489
{
518
 #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;}
490
 #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;}
519
 #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; }
491
 #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; }
520
 CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe,0,255);
492
 CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe,0,255);
521
 CHK_POTI_MM(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100);
493
 CHK_POTI_MM(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100);
522
 CHK_POTI_MM(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100);
494
 CHK_POTI_MM(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100);
523
 CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255);
495
 CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255);
524
 CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255);
496
 CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255);
525
 CHK_POTI_MM(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255);
497
 CHK_POTI_MM(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255);
526
 CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255);
498
 CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255);
527
 CHK_POTI(Parameter_Gyro_D,EE_Parameter.Gyro_D,0,255);
499
 CHK_POTI(Parameter_Gyro_D,EE_Parameter.Gyro_D,0,255);
528
 CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255);
500
 CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255);
529
 CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255);
501
 CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255);
530
 CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255);
502
 CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255);
531
 CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255);
503
 CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255);
532
 CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255);
504
 CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255);
533
 CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255);
505
 CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255);
534
 CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255);
506
 CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255);
535
 CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255);
507
 CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255);
536
 CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255);
508
 CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255);
537
 CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255);
509
 CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255);
538
 CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255);
510
 CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255);
539
 CHK_POTI(Parameter_AchsKopplung1,    EE_Parameter.AchsKopplung1,0,255);
511
 CHK_POTI(Parameter_AchsKopplung1,    EE_Parameter.AchsKopplung1,0,255);
540
 CHK_POTI(Parameter_AchsKopplung2,    EE_Parameter.AchsKopplung2,0,255);
512
 CHK_POTI(Parameter_AchsKopplung2,    EE_Parameter.AchsKopplung2,0,255);
541
 CHK_POTI(Parameter_CouplingYawCorrection,EE_Parameter.CouplingYawCorrection,0,255);
513
 CHK_POTI(Parameter_CouplingYawCorrection,EE_Parameter.CouplingYawCorrection,0,255);
542
 
-
 
543
// CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255);
514
// CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255);
544
 CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255);
515
 CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255);
545
 CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255);
516
 CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255);
546
 CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255);
517
 CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255);
547
 
-
 
548
// CHK_POTI(Parameter_NaviGpsModeControl,EE_Parameter.NaviGpsModeControl,0,255);
-
 
549
 //CHK_POTI(Parameter_NaviGpsGain,EE_Parameter.NaviGpsGain,0,255);
-
 
550
// CHK_POTI(Parameter_NaviGpsP,EE_Parameter.NaviGpsP,0,255);
-
 
551
// CHK_POTI(Parameter_NaviGpsI,EE_Parameter.NaviGpsI,0,255);
-
 
552
// CHK_POTI(Parameter_NaviGpsD,EE_Parameter.NaviGpsD,0,255);
-
 
553
// CHK_POTI(Parameter_NaviGpsACC,EE_Parameter.NaviGpsACC,0,255);
-
 
554
// CHK_POTI_MM(Parameter_NaviOperatingRadius,EE_Parameter.NaviOperatingRadius,10,255);
-
 
555
// CHK_POTI(Parameter_NaviWindCorrection,EE_Parameter.NaviWindCorrection,0,255);
-
 
556
// CHK_POTI(Parameter_NaviSpeedCompensation,EE_Parameter.NaviSpeedCompensation,0,255);
-
 
557
 
-
 
558
 CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255);
518
 CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255);
559
 
-
 
560
 //Ki = (float) Parameter_I_Faktor * 0.0001;
-
 
561
 Ki = 10300 / (Parameter_I_Faktor + 1);
519
 Ki = 10300 / (Parameter_I_Faktor + 1);
562
 MAX_GAS = EE_Parameter.Gas_Max;
520
 MAX_GAS = EE_Parameter.Gas_Max;
563
 MIN_GAS = EE_Parameter.Gas_Min;
521
 MIN_GAS = EE_Parameter.Gas_Min;
564
}
522
}
565
 
523
 
566
 
524
 
567
 
525
 
568
//############################################################################
526
//############################################################################
569
//
527
//
570
void MotorRegler(void)
528
void MotorRegler(void)
571
//############################################################################
529
//############################################################################
572
{
530
{
573
         int motorwert,pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int;
531
         int motorwert,pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int;
574
         int GierMischanteil,GasMischanteil;
532
         int GierMischanteil,GasMischanteil;
575
     static long SummeNick=0,SummeRoll=0;
533
     static long SummeNick=0,SummeRoll=0;
576
     static long sollGier = 0,tmp_long,tmp_long2;
534
     static long sollGier = 0,tmp_long,tmp_long2;
577
     static long IntegralFehlerNick = 0;
535
     static long IntegralFehlerNick = 0;
578
     static long IntegralFehlerRoll = 0;
536
     static long IntegralFehlerRoll = 0;
579
         static unsigned int RcLostTimer;
537
         static unsigned int RcLostTimer;
580
         static unsigned char delay_neutral = 0;
538
         static unsigned char delay_neutral = 0;
581
         static unsigned char delay_einschalten = 0,delay_ausschalten = 0;
539
         static unsigned char delay_einschalten = 0,delay_ausschalten = 0;
582
     static int hoehenregler = 0;
540
     static int hoehenregler = 0;
583
         static int motorwert1,motorwert2,motorwert3,motorwert4,motorwert5,motorwert6,motorwert7,motorwert8;
541
         static int motorwert1,motorwert2,motorwert3,motorwert4,motorwert5,motorwert6,motorwert7,motorwert8;
584
     static char TimerWerteausgabe = 0;
542
     static char TimerWerteausgabe = 0;
585
     static char NeueKompassRichtungMerken = 0;
543
     static char NeueKompassRichtungMerken = 0;
586
     static long ausgleichNick, ausgleichRoll;
544
     static long ausgleichNick, ausgleichRoll;
587
     int IntegralNickMalFaktor,IntegralRollMalFaktor;
545
     int IntegralNickMalFaktor,IntegralRollMalFaktor;
588
        Mittelwert();
546
        Mittelwert();
589
 
547
 
590
    GRN_ON;
548
    GRN_ON;
591
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
549
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
592
// Gaswert ermitteln
550
// Gaswert ermitteln
593
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
551
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
594
        GasMischanteil = StickGas;
552
        GasMischanteil = StickGas;
595
    if(GasMischanteil < MIN_GAS + 10) GasMischanteil = MIN_GAS + 10;
553
    if(GasMischanteil < MIN_GAS + 10) GasMischanteil = MIN_GAS + 10;
596
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
554
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
597
// Empfang schlecht
555
// Empfang schlecht
598
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
556
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
599
   if(SenderOkay < 100)
557
   if(SenderOkay < 100)
600
        {
558
        {
601
        if(!PcZugriff)
559
        if(!PcZugriff)
602
         {
560
         {
603
           if(BeepMuster == 0xffff)
561
           if(BeepMuster == 0xffff)
604
            {
562
            {
605
             beeptime = 15000;
563
             beeptime = 15000;
606
             BeepMuster = 0x0c00;
564
             BeepMuster = 0x0c00;
607
            }
565
            }
608
         }
566
         }
609
        if(RcLostTimer) RcLostTimer--;
567
        if(RcLostTimer) RcLostTimer--;
610
        else
568
        else
611
         {
569
         {
612
          MotorenEin = 0;
570
          MotorenEin = 0;
613
          Notlandung = 0;
571
          Notlandung = 0;
614
         }
572
         }
615
        ROT_ON;
573
        ROT_ON;
616
        if(modell_fliegt > 1000)  // wahrscheinlich in der Luft --> langsam absenken
574
        if(modell_fliegt > 1000)  // wahrscheinlich in der Luft --> langsam absenken
617
            {
575
            {
618
            GasMischanteil = EE_Parameter.NotGas;
576
            GasMischanteil = EE_Parameter.NotGas;
619
            Notlandung = 1;
577
            Notlandung = 1;
620
            PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
578
            PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
621
            PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
579
            PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
622
            PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
580
            PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
623
            PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
581
            PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
624
            PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
582
            PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
625
            }
583
            }
626
         else MotorenEin = 0;
584
         else MotorenEin = 0;
627
        }
585
        }
628
        else
586
        else
629
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
587
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
630
// Emfang gut
588
// Emfang gut
631
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
589
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
632
        if(SenderOkay > 140)
590
        if(SenderOkay > 140)
633
            {
591
            {
634
            Notlandung = 0;
592
            Notlandung = 0;
635
            RcLostTimer = EE_Parameter.NotGasZeit * 50;
593
            RcLostTimer = EE_Parameter.NotGasZeit * 50;
636
            if(GasMischanteil > 40 && MotorenEin)
594
            if(GasMischanteil > 40 && MotorenEin)
637
                {
595
                {
638
                if(modell_fliegt < 0xffff) modell_fliegt++;
596
                if(modell_fliegt < 0xffff) modell_fliegt++;
639
                }
597
                }
640
            if((modell_fliegt < 256))
598
            if((modell_fliegt < 256))
641
                {
599
                {
642
                SummeNick = 0;
600
                SummeNick = 0;
643
                SummeRoll = 0;
601
                SummeRoll = 0;
644
                if(modell_fliegt == 250)
602
                if(modell_fliegt == 250)
645
                 {
603
                 {
646
                  NeueKompassRichtungMerken = 1;
604
                  NeueKompassRichtungMerken = 1;
647
                  sollGier = 0;
605
                  sollGier = 0;
648
                  Mess_Integral_Gier = 0;
606
                  Mess_Integral_Gier = 0;
649
//                  Mess_Integral_Gier2 = 0;
607
//                  Mess_Integral_Gier2 = 0;
650
                 }
608
                 }
651
                } else MikroKopterFlags |= FLAG_FLY;
609
                } else MikroKopterFlags |= FLAG_FLY;
652
 
610
 
653
            if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0)
611
            if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0)
654
                {
612
                {
655
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
613
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
656
// auf Nullwerte kalibrieren
614
// auf Nullwerte kalibrieren
657
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
615
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
658
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
616
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
659
                    {
617
                    {
660
                    if(++delay_neutral > 200)  // nicht sofort
618
                    if(++delay_neutral > 200)  // nicht sofort
661
                        {
619
                        {
662
                        GRN_OFF;
620
                        GRN_OFF;
663
                        MotorenEin = 0;
621
                        MotorenEin = 0;
664
                        delay_neutral = 0;
622
                        delay_neutral = 0;
665
                        modell_fliegt = 0;
623
                        modell_fliegt = 0;
666
                        if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70)
624
                        if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70)
667
                        {
625
                        {
668
                         unsigned char setting=1;
626
                         unsigned char setting=1;
669
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1;
627
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1;
670
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2;
628
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2;
671
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
629
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
672
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
630
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
673
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
631
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
674
                         SetActiveParamSetNumber(setting);  // aktiven Datensatz merken
632
                         SetActiveParamSetNumber(setting);  // aktiven Datensatz merken
675
                        }
633
                        }
676
//                        else
634
//                        else
677
                         if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 30 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70)
635
                         if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 30 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -70)
678
                          {
636
                          {
679
                           WinkelOut.CalcState = 1;
637
                           WinkelOut.CalcState = 1;
680
                           beeptime = 1000;
638
                           beeptime = 1000;
681
                          }
639
                          }
682
                          else
640
                          else
683
                          {
641
                          {
684
                               ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
642
                               ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
685
                           if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
643
                           if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
686
                            {
644
                            {
687
                             if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
645
                             if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
688
                            }
646
                            }
689
                           SetNeutral();
647
                           SetNeutral();
690
                           Piep(GetActiveParamSetNumber());
648
                           Piep(GetActiveParamSetNumber());
691
                         }
649
                         }
692
                        }
650
                        }
693
                    }
651
                    }
694
                 else
652
                 else
695
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
653
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
696
                    {
654
                    {
697
                    if(++delay_neutral > 200)  // nicht sofort
655
                    if(++delay_neutral > 200)  // nicht sofort
698
                        {
656
                        {
699
                        GRN_OFF;
657
                        GRN_OFF;
700
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],0xff); // Werte löschen
658
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],0xff); // Werte löschen
701
                        MotorenEin = 0;
659
                        MotorenEin = 0;
702
                        delay_neutral = 0;
660
                        delay_neutral = 0;
703
                        modell_fliegt = 0;
661
                        modell_fliegt = 0;
704
                        SetNeutral();
662
                        SetNeutral();
705
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],NeutralAccX / 256); // ACC-NeutralWerte speichern
663
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],NeutralAccX / 256); // ACC-NeutralWerte speichern
706
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1],NeutralAccX % 256); // ACC-NeutralWerte speichern
664
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1],NeutralAccX % 256); // ACC-NeutralWerte speichern
707
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL],NeutralAccY / 256);
665
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL],NeutralAccY / 256);
708
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256);
666
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256);
709
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256);
667
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256);
710
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256);
668
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256);
711
                        Piep(GetActiveParamSetNumber());
669
                        Piep(GetActiveParamSetNumber());
712
                        }
670
                        }
713
                    }
671
                    }
714
                 else delay_neutral = 0;
672
                 else delay_neutral = 0;
715
                }
673
                }
716
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
674
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
717
// Gas ist unten
675
// Gas ist unten
718
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
676
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
719
            if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120)
677
            if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120)
720
                {
678
                {
721
                // Starten
679
                // Starten
722
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)
680
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)
723
                    {
681
                    {
724
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
682
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
725
// Einschalten
683
// Einschalten
726
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
684
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
727
                    if(++delay_einschalten > 200)
685
                    if(++delay_einschalten > 200)
728
                        {
686
                        {
729
                        delay_einschalten = 200;
687
                        delay_einschalten = 200;
730
                        modell_fliegt = 1;
688
                        modell_fliegt = 1;
731
                        MotorenEin = 1;
689
                        MotorenEin = 1;
732
                        sollGier = 0;
690
                        sollGier = 0;
733
                        Mess_Integral_Gier = 0;
691
                        Mess_Integral_Gier = 0;
734
                        Mess_Integral_Gier2 = 0;
692
                        Mess_Integral_Gier2 = 0;
735
                        Mess_IntegralNick = 0;
693
                        Mess_IntegralNick = 0;
736
                        Mess_IntegralRoll = 0;
694
                        Mess_IntegralRoll = 0;
737
                        Mess_IntegralNick2 = IntegralNick;
695
                        Mess_IntegralNick2 = IntegralNick;
738
                        Mess_IntegralRoll2 = IntegralRoll;
696
                        Mess_IntegralRoll2 = IntegralRoll;
739
                        SummeNick = 0;
697
                        SummeNick = 0;
740
                        SummeRoll = 0;
698
                        SummeRoll = 0;
741
                        MikroKopterFlags |= FLAG_START;
699
                        MikroKopterFlags |= FLAG_START;
742
                        }
700
                        }
743
                    }
701
                    }
744
                    else delay_einschalten = 0;
702
                    else delay_einschalten = 0;
745
                //Auf Neutralwerte setzen
703
                //Auf Neutralwerte setzen
746
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
704
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
747
// Auschalten
705
// Auschalten
748
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
706
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
749
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)
707
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)
750
                    {
708
                    {
751
                    if(++delay_ausschalten > 200)  // nicht sofort
709
                    if(++delay_ausschalten > 200)  // nicht sofort
752
                        {
710
                        {
753
                        MotorenEin = 0;
711
                        MotorenEin = 0;
754
                        delay_ausschalten = 200;
712
                        delay_ausschalten = 200;
755
                        modell_fliegt = 0;
713
                        modell_fliegt = 0;
756
                        }
714
                        }
757
                    }
715
                    }
758
                else delay_ausschalten = 0;
716
                else delay_ausschalten = 0;
759
                }
717
                }
760
            }
718
            }
761
 
719
 
762
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
720
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
763
// neue Werte von der Funke
721
// neue Werte von der Funke
764
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
722
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
765
 
723
 
766
 if(!NewPpmData-- || Notlandung)
724
 if(!NewPpmData-- || Notlandung)
767
  {
725
  {
768
    int tmp_int;
726
    int tmp_int;
769
        static int stick_nick,stick_roll;
727
        static int stick_nick,stick_roll;
770
    ParameterZuordnung();
728
    ParameterZuordnung();
771
    stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4;
729
    stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4;
772
    stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D;
730
    stick_nick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D;
773
    StickNick = stick_nick - (GPS_Nick + GPS_Nick2);
731
    StickNick = stick_nick - (GPS_Nick + GPS_Nick2);
774
 
732
 
775
    stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4;
733
    stick_roll = (stick_roll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4;
776
    stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D;
734
    stick_roll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D;
777
    StickRoll = stick_roll - (GPS_Roll + GPS_Roll2);
735
    StickRoll = stick_roll - (GPS_Roll + GPS_Roll2);
778
 
736
 
779
    StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]];
737
    StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]];
780
        if(StickGier > 2) StickGier -= 2;       else
738
        if(StickGier > 2) StickGier -= 2;       else
781
        if(StickGier < -2) StickGier += 2; else StickGier = 0;
739
        if(StickGier < -2) StickGier += 2; else StickGier = 0;
782
 
740
 
783
        StickGas  = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120;
741
        StickGas  = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120;
784
 
742
 
785
/*   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick)
743
/*   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick)
786
     MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--;
744
     MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--;
787
   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll)
745
   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll)
788
     MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--;
746
     MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--;
789
*/
747
*/
790
//    GyroFaktor     = ((float)Parameter_Gyro_P + 10.0) / (256.0/STICK_GAIN);
748
//    GyroFaktor     = ((float)Parameter_Gyro_P + 10.0) / (256.0/STICK_GAIN);
791
    GyroFaktor     = (Parameter_Gyro_P + 10.0);
749
    GyroFaktor     = (Parameter_Gyro_P + 10.0);
792
//    IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN);
750
//    IntegralFaktor = ((float) Parameter_Gyro_I) / (44000 / STICK_GAIN);
793
    IntegralFaktor = Parameter_Gyro_I;
751
    IntegralFaktor = Parameter_Gyro_I;
794
 
752
 
795
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
753
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
796
//+ Analoge Steuerung per Seriell
754
//+ Analoge Steuerung per Seriell
797
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
755
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
798
   if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128)
756
   if(ExternControl.Config & 0x01 && Parameter_ExternalControl > 128)
799
    {
757
    {
800
         StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
758
         StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
801
         StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
759
         StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
802
         StickGier += ExternControl.Gier;
760
         StickGier += ExternControl.Gier;
803
     ExternHoehenValue =  (int) ExternControl.Hight * (int)EE_Parameter.Hoehe_Verstaerkung;
761
     ExternHoehenValue =  (int) ExternControl.Hight * (int)EE_Parameter.Hoehe_Verstaerkung;
804
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
762
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
805
    }
763
    }
806
    if(StickGas < 0) StickGas = 0;
764
    if(StickGas < 0) StickGas = 0;
807
 
765
 
808
    if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0;
766
    if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0;
809
    if(GyroFaktor < 0) GyroFaktor = 0;
767
    if(GyroFaktor < 0) GyroFaktor = 0;
810
    if(IntegralFaktor < 0) IntegralFaktor = 0;
768
    if(IntegralFaktor < 0) IntegralFaktor = 0;
811
 
769
 
812
    if(abs(StickNick/STICK_GAIN) > MaxStickNick)
770
    if(abs(StickNick/STICK_GAIN) > MaxStickNick)
813
     {
771
     {
814
      MaxStickNick = abs(StickNick)/STICK_GAIN;
772
      MaxStickNick = abs(StickNick)/STICK_GAIN;
815
      if(MaxStickNick > 100) MaxStickNick = 100;
773
      if(MaxStickNick > 100) MaxStickNick = 100;
816
     }
774
     }
817
     else MaxStickNick--;
775
     else MaxStickNick--;
818
    if(abs(StickRoll/STICK_GAIN) > MaxStickRoll)
776
    if(abs(StickRoll/STICK_GAIN) > MaxStickRoll)
819
     {
777
     {
820
      MaxStickRoll = abs(StickRoll)/STICK_GAIN;
778
      MaxStickRoll = abs(StickRoll)/STICK_GAIN;
821
      if(MaxStickRoll > 100) MaxStickRoll = 100;
779
      if(MaxStickRoll > 100) MaxStickRoll = 100;
822
     }
780
     }
823
     else MaxStickRoll--;
781
     else MaxStickRoll--;
824
    if(Notlandung)  {MaxStickNick = 0; MaxStickRoll = 0;}
782
    if(Notlandung)  {MaxStickNick = 0; MaxStickRoll = 0;}
825
 
783
 
826
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
784
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
827
// Looping?
785
// Looping?
828
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
786
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
829
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS)  Looping_Links = 1;
787
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_LINKS)  Looping_Links = 1;
830
  else
788
  else
831
   {
789
   {
832
     {
790
     {
833
      if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0;
791
      if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0;
834
     }
792
     }
835
   }
793
   }
836
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1;
794
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1;
837
   else
795
   else
838
   {
796
   {
839
   if(Looping_Rechts) // Hysterese
797
   if(Looping_Rechts) // Hysterese
840
     {
798
     {
841
      if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0;
799
      if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0;
842
     }
800
     }
843
   }
801
   }
844
 
802
 
845
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_OBEN) Looping_Oben = 1;
803
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_OBEN) Looping_Oben = 1;
846
  else
804
  else
847
   {
805
   {
848
    if(Looping_Oben)  // Hysterese
806
    if(Looping_Oben)  // Hysterese
849
     {
807
     {
850
      if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0;
808
      if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0;
851
     }
809
     }
852
   }
810
   }
853
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_UNTEN) Looping_Unten = 1;
811
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.BitConfig & CFG_LOOP_UNTEN) Looping_Unten = 1;
854
   else
812
   else
855
   {
813
   {
856
    if(Looping_Unten) // Hysterese
814
    if(Looping_Unten) // Hysterese
857
     {
815
     {
858
      if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0;
816
      if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0;
859
     }
817
     }
860
   }
818
   }
861
 
819
 
862
   if(Looping_Links || Looping_Rechts)   Looping_Roll = 1; else Looping_Roll = 0;
820
   if(Looping_Links || Looping_Rechts)   Looping_Roll = 1; else Looping_Roll = 0;
863
   if(Looping_Oben  || Looping_Unten) {  Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0;
821
   if(Looping_Oben  || Looping_Unten) {  Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0;
864
  } // Ende neue Funken-Werte
822
  } // Ende neue Funken-Werte
865
 
823
 
866
  if(Looping_Roll || Looping_Nick)
824
  if(Looping_Roll || Looping_Nick)
867
   {
825
   {
868
    if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit;
826
    if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit;
869
        TrichterFlug = 1;
827
        TrichterFlug = 1;
870
   }
828
   }
871
 
829
 
872
 
830
 
873
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
831
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
874
// Bei Empfangsausfall im Flug
832
// Bei Empfangsausfall im Flug
875
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
833
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
876
   if(Notlandung)
834
   if(Notlandung)
877
    {
835
    {
878
     StickGier = 0;
836
     StickGier = 0;
879
     StickNick = 0;
837
     StickNick = 0;
880
     StickRoll = 0;
838
     StickRoll = 0;
881
     GyroFaktor     = 90;//(float) 100 / (256.0 / STICK_GAIN);
839
     GyroFaktor     = 90;//(float) 100 / (256.0 / STICK_GAIN);
882
     IntegralFaktor = 120;//(float) 120 / (44000 / STICK_GAIN);
840
     IntegralFaktor = 120;//(float) 120 / (44000 / STICK_GAIN);
883
     Looping_Roll = 0;
841
     Looping_Roll = 0;
884
     Looping_Nick = 0;
842
     Looping_Nick = 0;
885
    }
843
    }
886
 
844
 
887
 
845
 
888
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
846
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
889
// Integrale auf ACC-Signal abgleichen
847
// Integrale auf ACC-Signal abgleichen
890
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
848
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
891
#define ABGLEICH_ANZAHL 256L
849
#define ABGLEICH_ANZAHL 256L
892
 
850
 
893
 MittelIntegralNick  += IntegralNick;    // Für die Mittelwertbildung aufsummieren
851
 MittelIntegralNick  += IntegralNick;    // Für die Mittelwertbildung aufsummieren
894
 MittelIntegralRoll  += IntegralRoll;
852
 MittelIntegralRoll  += IntegralRoll;
895
 MittelIntegralNick2 += IntegralNick2;
853
 MittelIntegralNick2 += IntegralNick2;
896
 MittelIntegralRoll2 += IntegralRoll2;
854
 MittelIntegralRoll2 += IntegralRoll2;
897
 
855
 
898
 if(Looping_Nick || Looping_Roll)
856
 if(Looping_Nick || Looping_Roll)
899
  {
857
  {
900
    IntegralAccNick = 0;
858
    IntegralAccNick = 0;
901
    IntegralAccRoll = 0;
859
    IntegralAccRoll = 0;
902
    MittelIntegralNick = 0;
860
    MittelIntegralNick = 0;
903
    MittelIntegralRoll = 0;
861
    MittelIntegralRoll = 0;
904
    MittelIntegralNick2 = 0;
862
    MittelIntegralNick2 = 0;
905
    MittelIntegralRoll2 = 0;
863
    MittelIntegralRoll2 = 0;
906
    Mess_IntegralNick2 = Mess_IntegralNick;
864
    Mess_IntegralNick2 = Mess_IntegralNick;
907
    Mess_IntegralRoll2 = Mess_IntegralRoll;
865
    Mess_IntegralRoll2 = Mess_IntegralRoll;
908
    ZaehlMessungen = 0;
866
    ZaehlMessungen = 0;
909
    LageKorrekturNick = 0;
867
    LageKorrekturNick = 0;
910
    LageKorrekturRoll = 0;
868
    LageKorrekturRoll = 0;
911
  }
869
  }
912
 
870
 
913
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
871
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
914
  if(!Looping_Nick && !Looping_Roll)
872
  if(!Looping_Nick && !Looping_Roll)
915
  {
873
  {
916
   long tmp_long, tmp_long2;
874
   long tmp_long, tmp_long2;
917
   if(FromNaviCtrl_Value.Kalman_K != -1 && !TrichterFlug)
875
   if(FromNaviCtrl_Value.Kalman_K != -1 && !TrichterFlug)
918
     {
876
     {
919
      tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
877
      tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
920
      tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
878
      tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
921
      tmp_long  = (tmp_long  * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
879
      tmp_long  = (tmp_long  * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
922
      tmp_long2 = (tmp_long2 * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
880
      tmp_long2 = (tmp_long2 * FromNaviCtrl_Value.Kalman_K) / (32 * 16);
923
     if((MaxStickNick > 64) || (MaxStickRoll > 64))
881
     if((MaxStickNick > 64) || (MaxStickRoll > 64))
924
      {
882
      {
925
      tmp_long  /= 2;
883
      tmp_long  /= 2;
926
      tmp_long2 /= 2;
884
      tmp_long2 /= 2;
927
      }
885
      }
928
     if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
886
     if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
929
      {
887
      {
930
      tmp_long  /= 3;
888
      tmp_long  /= 3;
931
      tmp_long2 /= 3;
889
      tmp_long2 /= 3;
932
      }
890
      }
933
      if(tmp_long >  (long) FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long  = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
891
      if(tmp_long >  (long) FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long  = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
934
      if(tmp_long <  (long)-FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long  = (long)-FromNaviCtrl_Value.Kalman_MaxFusion;
892
      if(tmp_long <  (long)-FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long  = (long)-FromNaviCtrl_Value.Kalman_MaxFusion;
935
      if(tmp_long2 > (long) FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long2 = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
893
      if(tmp_long2 > (long) FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long2 = (long) FromNaviCtrl_Value.Kalman_MaxFusion;
936
      if(tmp_long2 < (long)-FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long2 = (long)-FromNaviCtrl_Value.Kalman_MaxFusion;
894
      if(tmp_long2 < (long)-FromNaviCtrl_Value.Kalman_MaxFusion)  tmp_long2 = (long)-FromNaviCtrl_Value.Kalman_MaxFusion;
937
     }
895
     }
938
     else
896
     else
939
     {
897
     {
940
      tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
898
      tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
941
      tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
899
      tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
942
      tmp_long /= 16;
900
      tmp_long /= 16;
943
      tmp_long2 /= 16;
901
      tmp_long2 /= 16;
944
     if((MaxStickNick > 64) || (MaxStickRoll > 64))
902
     if((MaxStickNick > 64) || (MaxStickRoll > 64))
945
      {
903
      {
946
      tmp_long  /= 3;
904
      tmp_long  /= 3;
947
      tmp_long2 /= 3;
905
      tmp_long2 /= 3;
948
      }
906
      }
949
     if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
907
     if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
950
      {
908
      {
951
      tmp_long  /= 3;
909
      tmp_long  /= 3;
952
      tmp_long2 /= 3;
910
      tmp_long2 /= 3;
953
      }
911
      }
954
 
-
 
955
 
912
 
956
#define AUSGLEICH  32
913
#define AUSGLEICH  32
957
      if(tmp_long >  AUSGLEICH)  tmp_long  = AUSGLEICH;
914
      if(tmp_long >  AUSGLEICH)  tmp_long  = AUSGLEICH;
958
      if(tmp_long < -AUSGLEICH)  tmp_long  =-AUSGLEICH;
915
      if(tmp_long < -AUSGLEICH)  tmp_long  =-AUSGLEICH;
959
      if(tmp_long2 > AUSGLEICH)  tmp_long2 = AUSGLEICH;
916
      if(tmp_long2 > AUSGLEICH)  tmp_long2 = AUSGLEICH;
960
      if(tmp_long2 <-AUSGLEICH)  tmp_long2 =-AUSGLEICH;
917
      if(tmp_long2 <-AUSGLEICH)  tmp_long2 =-AUSGLEICH;
961
     }
918
     }
962
 
919
 
963
//if(Poti2 > 20) { tmp_long = 0; tmp_long2 = 0;}
920
//if(Poti2 > 20) { tmp_long = 0; tmp_long2 = 0;}
964
   Mess_IntegralNick -= tmp_long;
921
   Mess_IntegralNick -= tmp_long;
965
   Mess_IntegralRoll -= tmp_long2;
922
   Mess_IntegralRoll -= tmp_long2;
966
  }
923
  }
967
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
924
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
968
 if(ZaehlMessungen >= ABGLEICH_ANZAHL)
925
 if(ZaehlMessungen >= ABGLEICH_ANZAHL)
969
 {
926
 {
970
  static int cnt = 0;
927
  static int cnt = 0;
971
  static char last_n_p,last_n_n,last_r_p,last_r_n;
928
  static char last_n_p,last_n_n,last_r_p,last_r_n;
972
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
929
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
973
  if(!Looping_Nick && !Looping_Roll && !TrichterFlug && (PlatinenVersion < 20))
930
  if(!Looping_Nick && !Looping_Roll && !TrichterFlug && (PlatinenVersion < 20))
974
  {
931
  {
975
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
932
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
976
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
933
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
977
        IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
934
        IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
978
        IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
935
        IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
979
    IntegralAccZ    = IntegralAccZ / ABGLEICH_ANZAHL;
936
    IntegralAccZ    = IntegralAccZ / ABGLEICH_ANZAHL;
980
#define MAX_I 0//(Poti2/10)
937
#define MAX_I 0//(Poti2/10)
981
// Nick ++++++++++++++++++++++++++++++++++++++++++++++++
938
// Nick ++++++++++++++++++++++++++++++++++++++++++++++++
982
    IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick);
939
    IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick);
983
    ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich;
940
    ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich;
984
// Roll ++++++++++++++++++++++++++++++++++++++++++++++++
941
// Roll ++++++++++++++++++++++++++++++++++++++++++++++++
985
    IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll);
942
    IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll);
986
    ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich;
943
    ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich;
987
 
944
 
988
    LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL;
945
    LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL;
989
    LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL;
946
    LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL;
990
 
947
 
991
   if(((MaxStickNick > 64) || (MaxStickRoll > 64) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)) && (FromNaviCtrl_Value.Kalman_K == -1))
948
   if(((MaxStickNick > 64) || (MaxStickRoll > 64) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)) && (FromNaviCtrl_Value.Kalman_K == -1))
992
    {
949
    {
993
     LageKorrekturNick /= 2;
950
     LageKorrekturNick /= 2;
994
     LageKorrekturRoll /= 2;
951
     LageKorrekturRoll /= 2;
995
    }
952
    }
996
 
953
 
997
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
954
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
998
// Gyro-Drift ermitteln
955
// Gyro-Drift ermitteln
999
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
956
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1000
    MittelIntegralNick2 /= ABGLEICH_ANZAHL;
957
    MittelIntegralNick2 /= ABGLEICH_ANZAHL;
1001
    MittelIntegralRoll2 /= ABGLEICH_ANZAHL;
958
    MittelIntegralRoll2 /= ABGLEICH_ANZAHL;
1002
    tmp_long  = IntegralNick2 - IntegralNick;
959
    tmp_long  = IntegralNick2 - IntegralNick;
1003
    tmp_long2 = IntegralRoll2 - IntegralRoll;
960
    tmp_long2 = IntegralRoll2 - IntegralRoll;
1004
    //DebugOut.Analog[25] = MittelIntegralRoll2 / 26;
961
    //DebugOut.Analog[25] = MittelIntegralRoll2 / 26;
1005
 
962
 
1006
    IntegralFehlerNick = tmp_long;
963
    IntegralFehlerNick = tmp_long;
1007
    IntegralFehlerRoll = tmp_long2;
964
    IntegralFehlerRoll = tmp_long2;
1008
    Mess_IntegralNick2 -= IntegralFehlerNick;
965
    Mess_IntegralNick2 -= IntegralFehlerNick;
1009
    Mess_IntegralRoll2 -= IntegralFehlerRoll;
966
    Mess_IntegralRoll2 -= IntegralFehlerRoll;
1010
 
967
 
1011
//    IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2;
968
//    IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2;
1012
//    IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2;
969
//    IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2;
1013
  if(EE_Parameter.Driftkomp)
970
  if(EE_Parameter.Driftkomp)
1014
   {
971
   {
1015
    if(GierGyroFehler > ABGLEICH_ANZAHL/2) { AdNeutralGier++; AdNeutralGierBias++; }
972
    if(GierGyroFehler > ABGLEICH_ANZAHL/2) { AdNeutralGier++; AdNeutralGierBias++; }
1016
    if(GierGyroFehler <-ABGLEICH_ANZAHL/2) { AdNeutralGier--; AdNeutralGierBias--; }
973
    if(GierGyroFehler <-ABGLEICH_ANZAHL/2) { AdNeutralGier--; AdNeutralGierBias--; }
1017
   }
974
   }
1018
//DebugOut.Analog[22] = MittelIntegralRoll / 26;
975
//DebugOut.Analog[22] = MittelIntegralRoll / 26;
1019
//DebugOut.Analog[24] = GierGyroFehler;
976
//DebugOut.Analog[24] = GierGyroFehler;
1020
    GierGyroFehler = 0;
977
    GierGyroFehler = 0;
1021
 
978
 
1022
 
979
 
1023
/*DebugOut.Analog[17] = IntegralAccNick / 26;
980
/*DebugOut.Analog[17] = IntegralAccNick / 26;
1024
DebugOut.Analog[18] = IntegralAccRoll / 26;
981
DebugOut.Analog[18] = IntegralAccRoll / 26;
1025
DebugOut.Analog[19] = IntegralFehlerNick;// / 26;
982
DebugOut.Analog[19] = IntegralFehlerNick;// / 26;
1026
DebugOut.Analog[20] = IntegralFehlerRoll;// / 26;
983
DebugOut.Analog[20] = IntegralFehlerRoll;// / 26;
1027
*/
984
*/
1028
//DebugOut.Analog[21] = MittelIntegralNick / 26;
985
//DebugOut.Analog[21] = MittelIntegralNick / 26;
1029
//MittelIntegralRoll = MittelIntegralRoll;
986
//MittelIntegralRoll = MittelIntegralRoll;
1030
//DebugOut.Analog[28] = ausgleichNick;
987
//DebugOut.Analog[28] = ausgleichNick;
1031
/*
988
/*
1032
DebugOut.Analog[29] = ausgleichRoll;
989
DebugOut.Analog[29] = ausgleichRoll;
1033
DebugOut.Analog[30] = LageKorrekturRoll * 10;
990
DebugOut.Analog[30] = LageKorrekturRoll * 10;
1034
*/
991
*/
1035
 
992
 
1036
#define FEHLER_LIMIT  (ABGLEICH_ANZAHL * 4)
993
#define FEHLER_LIMIT  (ABGLEICH_ANZAHL * 4)
1037
#define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16)
994
#define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16)
1038
#define BEWEGUNGS_LIMIT 20000
995
#define BEWEGUNGS_LIMIT 20000
1039
// Nick +++++++++++++++++++++++++++++++++++++++++++++++++
996
// Nick +++++++++++++++++++++++++++++++++++++++++++++++++
1040
        cnt = 1;// + labs(IntegralFehlerNick) / 4096;
997
        cnt = 1;// + labs(IntegralFehlerNick) / 4096;
1041
        if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16))
998
        if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16))
1042
        {
999
        {
1043
        if(IntegralFehlerNick >  FEHLER_LIMIT2)
1000
        if(IntegralFehlerNick >  FEHLER_LIMIT2)
1044
         {
1001
         {
1045
           if(last_n_p)
1002
           if(last_n_p)
1046
           {
1003
           {
1047
            cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
1004
            cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
1048
            ausgleichNick = IntegralFehlerNick / 8;
1005
            ausgleichNick = IntegralFehlerNick / 8;
1049
            if(ausgleichNick > 5000) ausgleichNick = 5000;
1006
            if(ausgleichNick > 5000) ausgleichNick = 5000;
1050
            LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
1007
            LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
1051
           }
1008
           }
1052
           else last_n_p = 1;
1009
           else last_n_p = 1;
1053
         } else  last_n_p = 0;
1010
         } else  last_n_p = 0;
1054
        if(IntegralFehlerNick < -FEHLER_LIMIT2)
1011
        if(IntegralFehlerNick < -FEHLER_LIMIT2)
1055
         {
1012
         {
1056
           if(last_n_n)
1013
           if(last_n_n)
1057
            {
1014
            {
1058
             cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
1015
             cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2;
1059
             ausgleichNick = IntegralFehlerNick / 8;
1016
             ausgleichNick = IntegralFehlerNick / 8;
1060
             if(ausgleichNick < -5000) ausgleichNick = -5000;
1017
             if(ausgleichNick < -5000) ausgleichNick = -5000;
1061
             LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
1018
             LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
1062
            }
1019
            }
1063
           else last_n_n = 1;
1020
           else last_n_n = 1;
1064
         } else  last_n_n = 0;
1021
         } else  last_n_n = 0;
1065
        }
1022
        }
1066
        else
1023
        else
1067
        {
1024
        {
1068
         cnt = 0;
1025
         cnt = 0;
1069
         KompassSignalSchlecht = 1000;
1026
         KompassSignalSchlecht = 1000;
1070
        }
1027
        }
1071
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
1028
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
1072
        if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16;
1029
        if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16;
1073
        if(IntegralFehlerNick >  FEHLER_LIMIT)   AdNeutralNick += cnt;
1030
        if(IntegralFehlerNick >  FEHLER_LIMIT)   AdNeutralNick += cnt;
1074
        if(IntegralFehlerNick < -FEHLER_LIMIT)   AdNeutralNick -= cnt;
1031
        if(IntegralFehlerNick < -FEHLER_LIMIT)   AdNeutralNick -= cnt;
1075
 
1032
 
1076
// Roll +++++++++++++++++++++++++++++++++++++++++++++++++
1033
// Roll +++++++++++++++++++++++++++++++++++++++++++++++++
1077
        cnt = 1;// + labs(IntegralFehlerNick) / 4096;
1034
        cnt = 1;// + labs(IntegralFehlerNick) / 4096;
1078
 
1035
 
1079
        ausgleichRoll = 0;
1036
        ausgleichRoll = 0;
1080
        if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16))
1037
        if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT || (FromNaviCtrl_Value.Kalman_MaxDrift > 3*16))
1081
        {
1038
        {
1082
        if(IntegralFehlerRoll >  FEHLER_LIMIT2)
1039
        if(IntegralFehlerRoll >  FEHLER_LIMIT2)
1083
         {
1040
         {
1084
           if(last_r_p)
1041
           if(last_r_p)
1085
           {
1042
           {
1086
            cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
1043
            cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
1087
            ausgleichRoll = IntegralFehlerRoll / 8;
1044
            ausgleichRoll = IntegralFehlerRoll / 8;
1088
            if(ausgleichRoll > 5000) ausgleichRoll = 5000;
1045
            if(ausgleichRoll > 5000) ausgleichRoll = 5000;
1089
            LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
1046
            LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
1090
           }
1047
           }
1091
           else last_r_p = 1;
1048
           else last_r_p = 1;
1092
         } else  last_r_p = 0;
1049
         } else  last_r_p = 0;
1093
        if(IntegralFehlerRoll < -FEHLER_LIMIT2)
1050
        if(IntegralFehlerRoll < -FEHLER_LIMIT2)
1094
         {
1051
         {
1095
           if(last_r_n)
1052
           if(last_r_n)
1096
           {
1053
           {
1097
            cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
1054
            cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2;
1098
            ausgleichRoll = IntegralFehlerRoll / 8;
1055
            ausgleichRoll = IntegralFehlerRoll / 8;
1099
            if(ausgleichRoll < -5000) ausgleichRoll = -5000;
1056
            if(ausgleichRoll < -5000) ausgleichRoll = -5000;
1100
            LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
1057
            LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL;
1101
           }
1058
           }
1102
           else last_r_n = 1;
1059
           else last_r_n = 1;
1103
         } else  last_r_n = 0;
1060
         } else  last_r_n = 0;
1104
        } else
1061
        } else
1105
        {
1062
        {
1106
         cnt = 0;
1063
         cnt = 0;
1107
         KompassSignalSchlecht = 1000;
1064
         KompassSignalSchlecht = 1000;
1108
        }
1065
        }
1109
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
1066
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
1110
        if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16;
1067
        if(cnt * 16 > FromNaviCtrl_Value.Kalman_MaxDrift) cnt = FromNaviCtrl_Value.Kalman_MaxDrift/16;
1111
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
1068
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
1112
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
1069
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
1113
  }
1070
  }
1114
  else
1071
  else
1115
  {
1072
  {
1116
   LageKorrekturRoll = 0;
1073
   LageKorrekturRoll = 0;
1117
   LageKorrekturNick = 0;
1074
   LageKorrekturNick = 0;
1118
   TrichterFlug = 0;
1075
   TrichterFlug = 0;
1119
  }
1076
  }
1120
 
1077
 
1121
  if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH
1078
  if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH
1122
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
1079
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
1123
   MittelIntegralNick_Alt = MittelIntegralNick;
1080
   MittelIntegralNick_Alt = MittelIntegralNick;
1124
   MittelIntegralRoll_Alt = MittelIntegralRoll;
1081
   MittelIntegralRoll_Alt = MittelIntegralRoll;
1125
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
1082
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
1126
    IntegralAccNick = 0;
1083
    IntegralAccNick = 0;
1127
    IntegralAccRoll = 0;
1084
    IntegralAccRoll = 0;
1128
    IntegralAccZ = 0;
1085
    IntegralAccZ = 0;
1129
    MittelIntegralNick = 0;
1086
    MittelIntegralNick = 0;
1130
    MittelIntegralRoll = 0;
1087
    MittelIntegralRoll = 0;
1131
    MittelIntegralNick2 = 0;
1088
    MittelIntegralNick2 = 0;
1132
    MittelIntegralRoll2 = 0;
1089
    MittelIntegralRoll2 = 0;
1133
    ZaehlMessungen = 0;
1090
    ZaehlMessungen = 0;
1134
 }
1091
 }
1135
//DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor);
1092
//DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor);
1136
 
1093
 
1137
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1094
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1138
//  Gieren
1095
//  Gieren
1139
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1096
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1140
//    if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;};
1097
//    if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;};
1141
    if(abs(StickGier) > 15) // war 35
1098
    if(abs(StickGier) > 15) // war 35
1142
     {
1099
     {
1143
      KompassSignalSchlecht = 1000;
1100
      KompassSignalSchlecht = 1000;
1144
      if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX))
1101
      if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX))
1145
       {
1102
       {
1146
         NeueKompassRichtungMerken = 1;
1103
         NeueKompassRichtungMerken = 1;
1147
        };
1104
        };
1148
     }
1105
     }
1149
    tmp_int  = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo  y = ax + bx²
1106
    tmp_int  = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo  y = ax + bx²
1150
    tmp_int += (EE_Parameter.Gier_P * StickGier) / 4;
1107
    tmp_int += (EE_Parameter.Gier_P * StickGier) / 4;
1151
    sollGier = tmp_int;
1108
    sollGier = tmp_int;
1152
    Mess_Integral_Gier -= tmp_int;
1109
    Mess_Integral_Gier -= tmp_int;
1153
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
1110
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
1154
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
1111
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
1155
 
1112
 
1156
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1113
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1157
//  Kompass
1114
//  Kompass
1158
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1115
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1159
//DebugOut.Analog[29] = (MaxStickNick + MaxStickRoll);
1116
//DebugOut.Analog[29] = (MaxStickNick + MaxStickRoll);
1160
 
1117
 
1161
    if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV))
1118
    if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV))
1162
     {
1119
     {
1163
       int w,v,r,fehler,korrektur;
1120
       int w,v,r,fehler,korrektur;
1164
       w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln
1121
       w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln
1165
       v = abs(IntegralRoll /512);
1122
       v = abs(IntegralRoll /512);
1166
       if(v > w) w = v; // grösste Neigung ermitteln
1123
       if(v > w) w = v; // grösste Neigung ermitteln
1167
       korrektur = w / 8 + 1;
1124
       korrektur = w / 8 + 1;
1168
       fehler = ((540 + KompassValue - (ErsatzKompass/GIER_GRAD_FAKTOR)) % 360) - 180;
1125
       fehler = ((540 + KompassValue - (ErsatzKompass/GIER_GRAD_FAKTOR)) % 360) - 180;
1169
           if(NeueKompassRichtungMerken)
1126
           if(NeueKompassRichtungMerken)
1170
            {
1127
            {
1171
                 fehler = 0;
1128
                 fehler = 0;
1172
                 ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
1129
                 ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR;
1173
                }
1130
                }
1174
       if(!KompassSignalSchlecht && w < 25)
1131
       if(!KompassSignalSchlecht && w < 25)
1175
        {
1132
        {
1176
        GierGyroFehler += fehler;
1133
        GierGyroFehler += fehler;
1177
        if(NeueKompassRichtungMerken)
1134
        if(NeueKompassRichtungMerken)
1178
         {
1135
         {
1179
          beeptime = 200;
1136
          beeptime = 200;
1180
//         KompassStartwert = KompassValue;
1137
//         KompassStartwert = KompassValue;
1181
          KompassStartwert = (ErsatzKompass/GIER_GRAD_FAKTOR);
1138
          KompassStartwert = (ErsatzKompass/GIER_GRAD_FAKTOR);
1182
          NeueKompassRichtungMerken = 0;
1139
          NeueKompassRichtungMerken = 0;
1183
         }
1140
         }
1184
        }
1141
        }
1185
       ErsatzKompass += (fehler * 8) / korrektur;
1142
       ErsatzKompass += (fehler * 8) / korrektur;
1186
       w = (w * Parameter_KompassWirkung) / 32;           // auf die Wirkung normieren
1143
       w = (w * Parameter_KompassWirkung) / 32;           // auf die Wirkung normieren
1187
       w = Parameter_KompassWirkung - w;                  // Wirkung ggf drosseln
1144
       w = Parameter_KompassWirkung - w;                  // Wirkung ggf drosseln
1188
       if(w >= 0)
1145
       if(w >= 0)
1189
        {
1146
        {
1190
          if(!KompassSignalSchlecht)
1147
          if(!KompassSignalSchlecht)
1191
          {
1148
          {
1192
           v = 64 + ((MaxStickNick + MaxStickRoll)) / 8;
1149
           v = 64 + ((MaxStickNick + MaxStickRoll)) / 8;
1193
           r = ((540 + (ErsatzKompass/GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180;
1150
           r = ((540 + (ErsatzKompass/GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180;
1194
//           r = KompassRichtung;
1151
//           r = KompassRichtung;
1195
           v = (r * w) / v;  // nach Kompass ausrichten
1152
           v = (r * w) / v;  // nach Kompass ausrichten
1196
           w = 3 * Parameter_KompassWirkung;
1153
           w = 3 * Parameter_KompassWirkung;
1197
           if(v > w) v = w; // Begrenzen
1154
           if(v > w) v = w; // Begrenzen
1198
           else
1155
           else
1199
           if(v < -w) v = -w;
1156
           if(v < -w) v = -w;
1200
           Mess_Integral_Gier += v;
1157
           Mess_Integral_Gier += v;
1201
          }
1158
          }
1202
          if(KompassSignalSchlecht) KompassSignalSchlecht--;
1159
          if(KompassSignalSchlecht) KompassSignalSchlecht--;
1203
        }
1160
        }
1204
        else KompassSignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek
1161
        else KompassSignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek
1205
     }
1162
     }
1206
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1163
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1207
 
1164
 
1208
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1165
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1209
//  Debugwerte zuordnen
1166
//  Debugwerte zuordnen
1210
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1167
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1211
  if(!TimerWerteausgabe--)
1168
  if(!TimerWerteausgabe--)
1212
   {
1169
   {
1213
    TimerWerteausgabe = 24;
1170
    TimerWerteausgabe = 24;
1214
 
1171
 
1215
    DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor;
1172
    DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor;
1216
    DebugOut.Analog[1] = IntegralRoll / EE_Parameter.GyroAccFaktor;
1173
    DebugOut.Analog[1] = IntegralRoll / EE_Parameter.GyroAccFaktor;
1217
    DebugOut.Analog[2] = Mittelwert_AccNick;
1174
    DebugOut.Analog[2] = Mittelwert_AccNick;
1218
    DebugOut.Analog[3] = Mittelwert_AccRoll;
1175
    DebugOut.Analog[3] = Mittelwert_AccRoll;
1219
    DebugOut.Analog[4] = MesswertGier;
1176
    DebugOut.Analog[4] = MesswertGier;
1220
    DebugOut.Analog[5] = HoehenWert;
1177
    DebugOut.Analog[5] = HoehenWert;
1221
    DebugOut.Analog[6] = Aktuell_az;//(Mess_Integral_Hoch / 512);
1178
    DebugOut.Analog[6] = Aktuell_az;//(Mess_Integral_Hoch / 512);
1222
    DebugOut.Analog[8] = KompassValue;
1179
    DebugOut.Analog[8] = KompassValue;
1223
    DebugOut.Analog[9] = UBat;
1180
    DebugOut.Analog[9] = UBat;
1224
    DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR;
1181
    DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR;
1225
    DebugOut.Analog[10] = SenderOkay;
1182
    DebugOut.Analog[10] = SenderOkay;
1226
    //DebugOut.Analog[16] = Mittelwert_AccHoch;
1183
    //DebugOut.Analog[16] = Mittelwert_AccHoch;
1227
    //DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
1184
    //DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
1228
    //DebugOut.Analog[18] = (int)FromNaviCtrl_Value.OsdBar;
1185
    //DebugOut.Analog[18] = (int)FromNaviCtrl_Value.OsdBar;
1229
    DebugOut.Analog[19] = WinkelOut.CalcState;
1186
    DebugOut.Analog[19] = WinkelOut.CalcState;
1230
    DebugOut.Analog[20] = ServoValue;
1187
    DebugOut.Analog[20] = ServoValue;
1231
    DebugOut.Analog[24] = MesswertNick/2;
1188
    DebugOut.Analog[24] = MesswertNick/2;
1232
    DebugOut.Analog[25] = MesswertRoll/2;
1189
    DebugOut.Analog[25] = MesswertRoll/2;
1233
    DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift;
1190
    DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift;
1234
    DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K;
1191
    DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K;
1235
    DebugOut.Analog[30] = GPS_Nick;
1192
    DebugOut.Analog[30] = GPS_Nick;
1236
    DebugOut.Analog[31] = GPS_Roll;
1193
    DebugOut.Analog[31] = GPS_Roll;
1237
 
1194
 
1238
 
1195
 
1239
//    DebugOut.Analog[19] -= DebugOut.Analog[19]/128;
1196
//    DebugOut.Analog[19] -= DebugOut.Analog[19]/128;
1240
//    if(DebugOut.Analog[19] > 0) DebugOut.Analog[19]--; else DebugOut.Analog[19]++;
1197
//    if(DebugOut.Analog[19] > 0) DebugOut.Analog[19]--; else DebugOut.Analog[19]++;
1241
 
1198
 
1242
/*    DebugOut.Analog[16] = motor_rx[0];
1199
/*    DebugOut.Analog[16] = motor_rx[0];
1243
    DebugOut.Analog[17] = motor_rx[1];
1200
    DebugOut.Analog[17] = motor_rx[1];
1244
    DebugOut.Analog[18] = motor_rx[2];
1201
    DebugOut.Analog[18] = motor_rx[2];
1245
    DebugOut.Analog[19] = motor_rx[3];
1202
    DebugOut.Analog[19] = motor_rx[3];
1246
    DebugOut.Analog[20] = motor_rx[0] + motor_rx[1] + motor_rx[2] + motor_rx[3];
1203
    DebugOut.Analog[20] = motor_rx[0] + motor_rx[1] + motor_rx[2] + motor_rx[3];
1247
    DebugOut.Analog[20] /= 14;
1204
    DebugOut.Analog[20] /= 14;
1248
    DebugOut.Analog[21] = motor_rx[4];
1205
    DebugOut.Analog[21] = motor_rx[4];
1249
    DebugOut.Analog[22] = motor_rx[5];
1206
    DebugOut.Analog[22] = motor_rx[5];
1250
    DebugOut.Analog[23] = motor_rx[6];
1207
    DebugOut.Analog[23] = motor_rx[6];
1251
    DebugOut.Analog[24] = motor_rx[7];
1208
    DebugOut.Analog[24] = motor_rx[7];
1252
    DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
1209
    DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
1253
*/
1210
*/
1254
//    DebugOut.Analog[9] = MesswertNick;
1211
//    DebugOut.Analog[9] = MesswertNick;
1255
//    DebugOut.Analog[9] = SollHoehe;
1212
//    DebugOut.Analog[9] = SollHoehe;
1256
//    DebugOut.Analog[10] = Mess_Integral_Gier / 128;
1213
//    DebugOut.Analog[10] = Mess_Integral_Gier / 128;
1257
//    DebugOut.Analog[11] = KompassStartwert;
1214
//    DebugOut.Analog[11] = KompassStartwert;
1258
//    DebugOut.Analog[10] = Parameter_Gyro_I;
1215
//    DebugOut.Analog[10] = Parameter_Gyro_I;
1259
//    DebugOut.Analog[10] = EE_Parameter.Gyro_I;
1216
//    DebugOut.Analog[10] = EE_Parameter.Gyro_I;
1260
//    DebugOut.Analog[9] = KompassRichtung;
1217
//    DebugOut.Analog[9] = KompassRichtung;
1261
//    DebugOut.Analog[10] = GasMischanteil;
1218
//    DebugOut.Analog[10] = GasMischanteil;
1262
//    DebugOut.Analog[3] = HoeheD * 32;
1219
//    DebugOut.Analog[3] = HoeheD * 32;
1263
//    DebugOut.Analog[4] = hoehenregler;
1220
//    DebugOut.Analog[4] = hoehenregler;
1264
  }
1221
  }
1265
 
1222
 
1266
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1223
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1267
//  Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen
1224
//  Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen
1268
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1225
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1269
  if(TrichterFlug)  { SummeRoll = 0; SummeNick = 0;};
1226
  if(TrichterFlug)  { SummeRoll = 0; SummeNick = 0;};
1270
 
1227
 
1271
    if(!Looping_Nick) IntegralNickMalFaktor = (IntegralNick * IntegralFaktor) /  (44000 / STICK_GAIN); else IntegralNickMalFaktor = 0;
1228
    if(!Looping_Nick) IntegralNickMalFaktor = (IntegralNick * IntegralFaktor) /  (44000 / STICK_GAIN); else IntegralNickMalFaktor = 0;
1272
    if(!Looping_Roll) IntegralRollMalFaktor = (IntegralRoll * IntegralFaktor) /  (44000 / STICK_GAIN); else IntegralRollMalFaktor = 0;
1229
    if(!Looping_Roll) IntegralRollMalFaktor = (IntegralRoll * IntegralFaktor) /  (44000 / STICK_GAIN); else IntegralRollMalFaktor = 0;
1273
 
1230
 
1274
#define TRIM_MAX (Poti1 * 2)
1231
#define TRIM_MAX 200
1275
 if(TrimNick > TRIM_MAX) TrimNick = TRIM_MAX; else  if(TrimNick <-TRIM_MAX) TrimNick =-TRIM_MAX;
1232
 if(TrimNick > TRIM_MAX) TrimNick = TRIM_MAX; else  if(TrimNick <-TRIM_MAX) TrimNick =-TRIM_MAX;
1276
 if(TrimRoll > TRIM_MAX) TrimRoll = TRIM_MAX; else  if(TrimRoll <-TRIM_MAX) TrimRoll =-TRIM_MAX;
1233
 if(TrimRoll > TRIM_MAX) TrimRoll = TRIM_MAX; else  if(TrimRoll <-TRIM_MAX) TrimRoll =-TRIM_MAX;
1277
 
1234
 
1278
 {
1235
 {
1279
    MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN);
1236
    MesswertNick = IntegralNickMalFaktor + (long)((long)MesswertNick * GyroFaktor + (long)TrimNick * 128L) / (256L / STICK_GAIN);
1280
    MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN);
1237
    MesswertRoll = IntegralRollMalFaktor + (long)((long)MesswertRoll * GyroFaktor + (long)TrimRoll * 128L) / (256L / STICK_GAIN);
1281
 }
1238
 }
1282
 
1239
 
1283
#ifndef QUADRO
1240
#ifndef QUADRO
1284
    MesswertGier =   (long)(MesswertGier * 4 * (long)GyroFaktor) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktor) / (4 * (44000 / STICK_GAIN));
1241
    MesswertGier =   (long)(MesswertGier * 4 * (long)GyroFaktor) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktor) / (4 * (44000 / STICK_GAIN));
1285
#else 
1242
#else 
1286
    MesswertGier =   (long)(MesswertGier * 2 * (long)GyroFaktor) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktor) / (2 * (44000 / STICK_GAIN));
1243
    MesswertGier =   (long)(MesswertGier * 2 * (long)GyroFaktor) / (256L / STICK_GAIN) + (long)(Integral_Gier * IntegralFaktor) / (2 * (44000 / STICK_GAIN));
1287
#endif 
1244
#endif 
1288
 
1245
 
1289
    // Maximalwerte abfangen
1246
    // Maximalwerte abfangen
1290
//    #define MAX_SENSOR  (4096*STICK_GAIN)
1247
//    #define MAX_SENSOR  (4096*STICK_GAIN)
1291
    #define MAX_SENSOR  (4096*4)
1248
    #define MAX_SENSOR  (4096*4)
1292
    if(MesswertNick >  MAX_SENSOR) MesswertNick =  MAX_SENSOR;
1249
    if(MesswertNick >  MAX_SENSOR) MesswertNick =  MAX_SENSOR;
1293
    if(MesswertNick < -MAX_SENSOR) MesswertNick = -MAX_SENSOR;
1250
    if(MesswertNick < -MAX_SENSOR) MesswertNick = -MAX_SENSOR;
1294
    if(MesswertRoll >  MAX_SENSOR) MesswertRoll =  MAX_SENSOR;
1251
    if(MesswertRoll >  MAX_SENSOR) MesswertRoll =  MAX_SENSOR;
1295
    if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR;
1252
    if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR;
1296
    if(MesswertGier >  MAX_SENSOR) MesswertGier =  MAX_SENSOR;
1253
    if(MesswertGier >  MAX_SENSOR) MesswertGier =  MAX_SENSOR;
1297
    if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR;
1254
    if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR;
1298
 
1255
 
1299
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1256
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1300
// Höhenregelung
1257
// Höhenregelung
1301
// Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht
1258
// Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht
1302
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1259
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1303
 
1260
 
1304
  GasMischanteil *= STICK_GAIN;
1261
  GasMischanteil *= STICK_GAIN;
1305
 if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
1262
 if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
1306
  {
1263
  {
1307
    int tmp_int;
1264
    int tmp_int;
1308
        static char delay = 100;
1265
        static char delay = 100;
1309
    if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
1266
    if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
1310
    {
1267
    {
1311
    if(((EE_Parameter.BitConfig & CFG_HIGHT_3SWITCH) && ((Parameter_MaxHoehe > 80) && (Parameter_MaxHoehe < 140))) ||
1268
    if(((EE_Parameter.BitConfig & CFG_HIGHT_3SWITCH) && ((Parameter_MaxHoehe > 80) && (Parameter_MaxHoehe < 140))) ||
1312
      (!(EE_Parameter.BitConfig & CFG_HIGHT_3SWITCH) && (Parameter_MaxHoehe < 50)))
1269
      (!(EE_Parameter.BitConfig & CFG_HIGHT_3SWITCH) && (Parameter_MaxHoehe < 50)))
1313
      {
1270
      {
1314
       if(!delay--)
1271
       if(!delay--)
1315
            {
1272
            {
1316
         if(MessLuftdruck > 1000)
1273
         if(MessLuftdruck > 1000)
1317
                  {
1274
                  {
1318
                   ExpandBaro -= 10;
1275
                   ExpandBaro -= 10;
1319
                   OCR0A = DruckOffsetSetting - ExpandBaro;
1276
                   OCR0A = DruckOffsetSetting - ExpandBaro;
1320
                   beeptime = 300;
1277
                   beeptime = 300;
1321
           delay = 250;
1278
           delay = 250;
1322
                  }
1279
                  }
1323
                  else
1280
                  else
1324
         if(MessLuftdruck < 100)
1281
         if(MessLuftdruck < 100)
1325
                  {
1282
                  {
1326
                   ExpandBaro += 10;
1283
                   ExpandBaro += 10;
1327
                   OCR0A = DruckOffsetSetting - ExpandBaro;
1284
                   OCR0A = DruckOffsetSetting - ExpandBaro;
1328
                   beeptime = 300;
1285
                   beeptime = 300;
1329
           delay = 250;
1286
           delay = 250;
1330
                  }
1287
                  }
1331
          else
1288
          else
1332
          {
1289
          {
1333
               SollHoehe = HoehenWert - 20;  // Parameter_MaxHoehe ist der PPM-Wert des Schalters
1290
               SollHoehe = HoehenWert - 20;  // Parameter_MaxHoehe ist der PPM-Wert des Schalters
1334
           HoehenReglerAktiv = 0;
1291
           HoehenReglerAktiv = 0;
1335
                   delay = 1;
1292
                   delay = 1;
1336
                  }
1293
                  }
1337
                }
1294
                }
1338
      }
1295
      }
1339
      else
1296
      else
1340
        {
1297
        {
1341
         HoehenReglerAktiv = 1;
1298
         HoehenReglerAktiv = 1;
1342
                 delay = 200;
1299
                 delay = 200;
1343
                }
1300
                }
1344
    }
1301
    }
1345
    else
1302
    else
1346
    {
1303
    {
1347
     SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20;
1304
     SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20;
1348
     HoehenReglerAktiv = 1;
1305
     HoehenReglerAktiv = 1;
1349
    }
1306
    }
1350
 
1307
 
1351
    if(Notlandung) SollHoehe = 0;
1308
    if(Notlandung) SollHoehe = 0;
1352
    h = HoehenWert;
1309
    h = HoehenWert;
1353
    if((h > SollHoehe) && HoehenReglerAktiv)      // zu hoch --> drosseln
1310
    if((h > SollHoehe) && HoehenReglerAktiv)      // zu hoch --> drosseln
1354
     {
1311
     {
1355
      h = ((h - SollHoehe) * (int) Parameter_Hoehe_P) / (16 / STICK_GAIN); // Differenz bestimmen --> P-Anteil
1312
      h = ((h - SollHoehe) * (int) Parameter_Hoehe_P) / (16 / STICK_GAIN); // Differenz bestimmen --> P-Anteil
1356
      h = GasMischanteil - h;         // vom Gas abziehen
1313
      h = GasMischanteil - h;         // vom Gas abziehen
1357
//      h -= (HoeheD * Parameter_Luftdruck_D)/(8/STICK_GAIN);    // D-Anteil
1314
//      h -= (HoeheD * Parameter_Luftdruck_D)/(8/STICK_GAIN);    // D-Anteil
1358
      h -= (HoeheD)/(8/STICK_GAIN);    // D-Anteil
1315
      h -= (HoeheD)/(8/STICK_GAIN);    // D-Anteil
1359
      tmp_int = ((Mess_Integral_Hoch / 128) * (signed long) Parameter_Hoehe_ACC_Wirkung) / (128 / STICK_GAIN);
1316
      tmp_int = ((Mess_Integral_Hoch / 128) * (signed long) Parameter_Hoehe_ACC_Wirkung) / (128 / STICK_GAIN);
1360
      if(tmp_int > 70*STICK_GAIN) tmp_int = 70*STICK_GAIN;
1317
      if(tmp_int > 70*STICK_GAIN) tmp_int = 70*STICK_GAIN;
1361
      else if(tmp_int < -(70*STICK_GAIN)) tmp_int = -(70*STICK_GAIN);
1318
      else if(tmp_int < -(70*STICK_GAIN)) tmp_int = -(70*STICK_GAIN);
1362
      h -= tmp_int;
1319
      h -= tmp_int;
1363
      hoehenregler = (hoehenregler*15 + h) / 16;
1320
      hoehenregler = (hoehenregler*15 + h) / 16;
1364
      if(hoehenregler < EE_Parameter.Hoehe_MinGas * STICK_GAIN) // nicht unter MIN
1321
      if(hoehenregler < EE_Parameter.Hoehe_MinGas * STICK_GAIN) // nicht unter MIN
1365
       {
1322
       {
1366
         if(GasMischanteil >= EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = EE_Parameter.Hoehe_MinGas * STICK_GAIN;
1323
         if(GasMischanteil >= EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = EE_Parameter.Hoehe_MinGas * STICK_GAIN;
1367
         if(GasMischanteil < EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = GasMischanteil;
1324
         if(GasMischanteil < EE_Parameter.Hoehe_MinGas * STICK_GAIN) hoehenregler = GasMischanteil;
1368
       }
1325
       }
1369
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
1326
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
1370
      GasMischanteil = hoehenregler;
1327
      GasMischanteil = hoehenregler;
1371
     }
1328
     }
1372
  }
1329
  }
1373
  if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN;
1330
  if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN;
1374
 
1331
 
1375
 
1332
 
1376
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1333
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1377
// + Mischer und PI-Regler
1334
// + Mischer und PI-Regler
1378
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1335
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1379
  DebugOut.Analog[7] = GasMischanteil;
1336
  DebugOut.Analog[7] = GasMischanteil;
1380
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1337
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1381
// Gier-Anteil
1338
// Gier-Anteil
1382
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1339
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1383
#define MUL_G  1.0
1340
#define MUL_G  1.0
1384
    GierMischanteil = MesswertGier - sollGier * STICK_GAIN;     // Regler für Gier
1341
    GierMischanteil = MesswertGier - sollGier * STICK_GAIN;     // Regler für Gier
1385
// GierMischanteil = 0;
1342
// GierMischanteil = 0;
1386
#define MIN_GIERGAS  (40*STICK_GAIN)  // unter diesem Gaswert trotzdem Gieren
1343
#define MIN_GIERGAS  (40*STICK_GAIN)  // unter diesem Gaswert trotzdem Gieren
1387
   if(GasMischanteil > MIN_GIERGAS)
1344
   if(GasMischanteil > MIN_GIERGAS)
1388
    {
1345
    {
1389
     if(GierMischanteil > (GasMischanteil / 2)) GierMischanteil = GasMischanteil / 2;
1346
     if(GierMischanteil > (GasMischanteil / 2)) GierMischanteil = GasMischanteil / 2;
1390
     if(GierMischanteil < -(GasMischanteil / 2)) GierMischanteil = -(GasMischanteil / 2);
1347
     if(GierMischanteil < -(GasMischanteil / 2)) GierMischanteil = -(GasMischanteil / 2);
1391
    }
1348
    }
1392
    else
1349
    else
1393
    {
1350
    {
1394
     if(GierMischanteil > (MIN_GIERGAS / 2))  GierMischanteil = MIN_GIERGAS / 2;
1351
     if(GierMischanteil > (MIN_GIERGAS / 2))  GierMischanteil = MIN_GIERGAS / 2;
1395
     if(GierMischanteil < -(MIN_GIERGAS / 2)) GierMischanteil = -(MIN_GIERGAS / 2);
1352
     if(GierMischanteil < -(MIN_GIERGAS / 2)) GierMischanteil = -(MIN_GIERGAS / 2);
1396
    }
1353
    }
1397
    tmp_int = MAX_GAS*STICK_GAIN;
1354
    tmp_int = MAX_GAS*STICK_GAIN;
1398
    if(GierMischanteil > ((tmp_int - GasMischanteil))) GierMischanteil = ((tmp_int - GasMischanteil));
1355
    if(GierMischanteil > ((tmp_int - GasMischanteil))) GierMischanteil = ((tmp_int - GasMischanteil));
1399
    if(GierMischanteil < -((tmp_int - GasMischanteil))) GierMischanteil = -((tmp_int - GasMischanteil));
1356
    if(GierMischanteil < -((tmp_int - GasMischanteil))) GierMischanteil = -((tmp_int - GasMischanteil));
1400
 
1357
 
1401
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1358
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1402
// Nick-Achse
1359
// Nick-Achse
1403
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1360
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1404
    DiffNick = MesswertNick - StickNick;        // Differenz bestimmen
1361
    DiffNick = MesswertNick - StickNick;        // Differenz bestimmen
1405
    if(IntegralFaktor) SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung
1362
    if(IntegralFaktor) SummeNick += IntegralNickMalFaktor - StickNick; // I-Anteil bei Winkelregelung
1406
    else  SummeNick += DiffNick; // I-Anteil bei HH
1363
    else  SummeNick += DiffNick; // I-Anteil bei HH
1407
    if(SummeNick >  (STICK_GAIN * 16000L)) SummeNick =  (STICK_GAIN * 16000L);
1364
    if(SummeNick >  (STICK_GAIN * 16000L)) SummeNick =  (STICK_GAIN * 16000L);
1408
    if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
1365
    if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
1409
    pd_ergebnis_nick = DiffNick + SummeNick / Ki; // PI-Regler für Nick
1366
    pd_ergebnis_nick = DiffNick + SummeNick / Ki; // PI-Regler für Nick
1410
    // Motor Vorn
1367
    // Motor Vorn
1411
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1368
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1412
    if(pd_ergebnis_nick >  tmp_int) pd_ergebnis_nick =  tmp_int;
1369
    if(pd_ergebnis_nick >  tmp_int) pd_ergebnis_nick =  tmp_int;
1413
    if(pd_ergebnis_nick < -tmp_int) pd_ergebnis_nick = -tmp_int;
1370
    if(pd_ergebnis_nick < -tmp_int) pd_ergebnis_nick = -tmp_int;
1414
 
1371
 
1415
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1372
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1416
// Roll-Achse
1373
// Roll-Achse
1417
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1374
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1418
        DiffRoll = MesswertRoll - StickRoll;    // Differenz bestimmen
1375
        DiffRoll = MesswertRoll - StickRoll;    // Differenz bestimmen
1419
    if(IntegralFaktor) SummeRoll += IntegralRollMalFaktor - StickRoll;// I-Anteil bei Winkelregelung
1376
    if(IntegralFaktor) SummeRoll += IntegralRollMalFaktor - StickRoll;// I-Anteil bei Winkelregelung
1420
    else                 SummeRoll += DiffRoll;  // I-Anteil bei HH
1377
    else                 SummeRoll += DiffRoll;  // I-Anteil bei HH
1421
    if(SummeRoll >  (STICK_GAIN * 16000L)) SummeRoll =  (STICK_GAIN * 16000L);
1378
    if(SummeRoll >  (STICK_GAIN * 16000L)) SummeRoll =  (STICK_GAIN * 16000L);
1422
    if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN);
1379
    if(SummeRoll < -(16000L * STICK_GAIN)) SummeRoll = -(16000L * STICK_GAIN);
1423
    pd_ergebnis_roll = DiffRoll + SummeRoll / Ki;       // PI-Regler für Roll
1380
    pd_ergebnis_roll = DiffRoll + SummeRoll / Ki;       // PI-Regler für Roll
1424
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1381
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
1425
    if(pd_ergebnis_roll >  tmp_int) pd_ergebnis_roll =  tmp_int;
1382
    if(pd_ergebnis_roll >  tmp_int) pd_ergebnis_roll =  tmp_int;
1426
    if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int;
1383
    if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int;
1427
 
1384
 
1428
#ifdef QUADRO
1385
#ifdef QUADRO
1429
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1386
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1430
// Quadro-Mischer 
1387
// Quadro-Mischer 
1431
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1388
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1432
    motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil;      // Mischer
1389
    motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil;      // Mischer
1433
    motorwert1 = MotorSmoothing(motorwert,motorwert1);
1390
    motorwert1 = MotorSmoothing(motorwert,motorwert1);
1434
    motorwert = motorwert1 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1391
    motorwert = motorwert1 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1435
    Motor_Vorne = motorwert;
1392
    Motor_Vorne = motorwert;
1436
 
1393
 
1437
        motorwert = GasMischanteil - pd_ergebnis_nick + GierMischanteil;
1394
        motorwert = GasMischanteil - pd_ergebnis_nick + GierMischanteil;
1438
    motorwert2 = MotorSmoothing(motorwert,motorwert2);
1395
    motorwert2 = MotorSmoothing(motorwert,motorwert2);
1439
    motorwert = motorwert2 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1396
    motorwert = motorwert2 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1440
        Motor_Hinten = motorwert;
1397
        Motor_Hinten = motorwert;
1441
 
1398
 
1442
    motorwert = GasMischanteil + pd_ergebnis_roll - GierMischanteil;
1399
    motorwert = GasMischanteil + pd_ergebnis_roll - GierMischanteil;
1443
    motorwert3 = MotorSmoothing(motorwert,motorwert3);
1400
    motorwert3 = MotorSmoothing(motorwert,motorwert3);
1444
    motorwert = motorwert3 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1401
    motorwert = motorwert3 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1445
    Motor_Links = motorwert;
1402
    Motor_Links = motorwert;
1446
 
1403
 
1447
        motorwert = GasMischanteil - pd_ergebnis_roll - GierMischanteil;
1404
        motorwert = GasMischanteil - pd_ergebnis_roll - GierMischanteil;
1448
    motorwert4 = MotorSmoothing(motorwert,motorwert4);
1405
    motorwert4 = MotorSmoothing(motorwert,motorwert4);
1449
    motorwert = motorwert4 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1406
    motorwert = motorwert4 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1450
    Motor_Rechts = motorwert;
1407
    Motor_Rechts = motorwert;
1451
   // +++++++++++++++++++++++++++++++++++++++++++++++
1408
   // +++++++++++++++++++++++++++++++++++++++++++++++
1452
#endif
1409
#endif
1453
#ifdef OCTO
1410
#ifdef OCTO
1454
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1411
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1455
// Octo-Mischer 
1412
// Octo-Mischer 
1456
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1413
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1457
    motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil;  
1414
    motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil;  
1458
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1415
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1459
        Motor1 = motorwert;
1416
        Motor1 = motorwert;
1460
 
1417
 
1461
    motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;  
1418
    motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;  
1462
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1419
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1463
        Motor2 = motorwert;
1420
        Motor2 = motorwert;
1464
 
1421
 
1465
        motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil;
1422
        motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil;
1466
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1423
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1467
    Motor3 = motorwert;
1424
    Motor3 = motorwert;
1468
 
1425
 
1469
        motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
1426
        motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
1470
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1427
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1471
    Motor4 = motorwert;
1428
    Motor4 = motorwert;
1472
 
1429
 
1473
        motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil;
1430
        motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil;
1474
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1431
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1475
        Motor5 = motorwert;
1432
        Motor5 = motorwert;
1476
 
1433
 
1477
        motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1434
        motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1478
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1435
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1479
        Motor6 = motorwert;
1436
        Motor6 = motorwert;
1480
 
1437
 
1481
    motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil;
1438
    motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil;
1482
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1439
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1483
    Motor7 = motorwert;
1440
    Motor7 = motorwert;
1484
 
1441
 
1485
    motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1442
    motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1486
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1443
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1487
    Motor8 = motorwert;
1444
    Motor8 = motorwert;
1488
   // +++++++++++++++++++++++++++++++++++++++++++++++
1445
   // +++++++++++++++++++++++++++++++++++++++++++++++
1489
#endif
1446
#endif
1490
#ifdef OCTO2
1447
#ifdef OCTO2
1491
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1448
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1492
// Octo-Mischer 
1449
// Octo-Mischer 
1493
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1450
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1494
    motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil;     
1451
    motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil;     
1495
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1452
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1496
        Motor1 = motorwert;
1453
        Motor1 = motorwert;
1497
 
1454
 
1498
    motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;  
1455
    motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;  
1499
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1456
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1500
        Motor2 = motorwert;
1457
        Motor2 = motorwert;
1501
 
1458
 
1502
        motorwert = GasMischanteil + - pd_ergebnis_roll + GierMischanteil;
1459
        motorwert = GasMischanteil + - pd_ergebnis_roll + GierMischanteil;
1503
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1460
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1504
    Motor3 = motorwert;
1461
    Motor3 = motorwert;
1505
 
1462
 
1506
        motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
1463
        motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
1507
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1464
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1508
    Motor4 = motorwert;
1465
    Motor4 = motorwert;
1509
 
1466
 
1510
        motorwert = GasMischanteil - pd_ergebnis_roll + GierMischanteil;
1467
        motorwert = GasMischanteil - pd_ergebnis_roll + GierMischanteil;
1511
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1468
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1512
        Motor5 = motorwert;
1469
        Motor5 = motorwert;
1513
 
1470
 
1514
        motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1471
        motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1515
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1472
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1516
        Motor6 = motorwert;
1473
        Motor6 = motorwert;
1517
 
1474
 
1518
    motorwert = GasMischanteil + pd_ergebnis_roll + GierMischanteil;
1475
    motorwert = GasMischanteil + pd_ergebnis_roll + GierMischanteil;
1519
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1476
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1520
    Motor7 = motorwert;
1477
    Motor7 = motorwert;
1521
 
1478
 
1522
    motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1479
    motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
1523
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1480
    motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
1524
    Motor8 = motorwert;
1481
    Motor8 = motorwert;
1525
   // +++++++++++++++++++++++++++++++++++++++++++++++
1482
   // +++++++++++++++++++++++++++++++++++++++++++++++
1526
#endif
1483
#endif
1527
 
1484
/*
1528
if(Poti1 > 20)  Motor1 = 0;
1485
if(Poti1 > 20)  Motor1 = 0;
1529
if(Poti1 > 90)  Motor6 = 0;
1486
if(Poti1 > 90)  Motor6 = 0;
1530
if(Poti1 > 140) Motor2 = 0;
1487
if(Poti1 > 140) Motor2 = 0;
1531
if(Poti1 > 200) Motor7 = 0;
1488
if(Poti1 > 200) Motor7 = 0;
1532
 
1489
*/
1533
}
1490
}
1534
 
1491