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