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