Subversion Repositories FlightCtrl

Rev

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

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