Subversion Repositories FlightCtrl

Rev

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

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