Rev 624 | Rev 685 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 624 | Rev 683 | ||
---|---|---|---|
Line 4... | Line 4... | ||
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 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 54... | Line 54... | ||
54 | 54 | ||
55 | #include "main.h" |
55 | #include "main.h" |
Line 80... | Line 80... | ||
80 | long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L; |
80 | long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L; |
Line 81... | Line 81... | ||
81 | 81 | ||
82 | float GyroFaktor; |
82 | float GyroFaktor; |
83 | float IntegralFaktor; |
83 | float IntegralFaktor; |
84 | volatile int DiffNick,DiffRoll; |
84 | volatile int DiffNick,DiffRoll; |
85 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
85 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
86 | volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count; |
86 | volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count; |
87 | unsigned char MotorWert[5]; |
87 | unsigned char MotorWert[5]; |
88 | volatile unsigned char SenderOkay = 0; |
88 | volatile unsigned char SenderOkay = 0; |
89 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
89 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
Line 124... | Line 124... | ||
124 | void Piep(unsigned char Anzahl) |
124 | void Piep(unsigned char Anzahl) |
125 | { |
125 | { |
126 | while(Anzahl--) |
126 | while(Anzahl--) |
127 | { |
127 | { |
128 | if(MotorenEin) return; //auf keinen Fall im Flug! |
128 | if(MotorenEin) return; //auf keinen Fall im Flug! |
129 | beeptime = 100; |
129 | BeepTime = 100; |
130 | Delay_ms(250); |
130 | Delay_ms(250); |
131 | } |
131 | } |
132 | } |
132 | } |
Line 133... | Line 133... | ||
133 | 133 | ||
134 | //############################################################################ |
134 | //############################################################################ |
135 | // Nullwerte ermitteln |
135 | // Nullwerte ermitteln |
136 | void SetNeutral(void) |
136 | void SetNeutral(void) |
137 | //############################################################################ |
137 | //############################################################################ |
138 | { |
138 | { |
139 | NeutralAccX = 0; |
139 | NeutralAccX = 0; |
140 | NeutralAccY = 0; |
140 | NeutralAccY = 0; |
141 | NeutralAccZ = 0; |
141 | NeutralAccZ = 0; |
142 | AdNeutralNick = 0; |
142 | AdNeutralNick = 0; |
143 | AdNeutralRoll = 0; |
143 | AdNeutralRoll = 0; |
144 | AdNeutralGier = 0; |
144 | AdNeutralGier = 0; |
145 | Parameter_AchsKopplung1 = 0; |
145 | Parameter_AchsKopplung1 = 0; |
146 | Parameter_AchsGegenKopplung1 = 0; |
146 | Parameter_AchsGegenKopplung1 = 0; |
147 | CalibrierMittelwert(); |
147 | CalibrierMittelwert(); |
148 | Delay_ms_Mess(100); |
148 | Delay_ms_Mess(100); |
149 | CalibrierMittelwert(); |
149 | CalibrierMittelwert(); |
150 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
150 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
151 | { |
151 | { |
152 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
152 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
Line 153... | Line 153... | ||
153 | } |
153 | } |
154 | 154 | ||
155 | AdNeutralNick= AdWertNick; |
155 | AdNeutralNick= AdValueGyrNick; |
156 | AdNeutralRoll= AdWertRoll; |
156 | AdNeutralRoll= AdValueGyrRoll; |
157 | AdNeutralGier= AdWertGier; |
157 | AdNeutralGier= AdValueGyrGier; |
158 | StartNeutralRoll = AdNeutralRoll; |
158 | StartNeutralRoll = AdNeutralRoll; |
159 | StartNeutralNick = AdNeutralNick; |
159 | StartNeutralNick = AdNeutralNick; |
160 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) |
160 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) |
161 | { |
161 | { |
162 | NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY; |
162 | NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY; |
163 | NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY; |
163 | NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY; |
164 | NeutralAccZ = Aktuell_az; |
164 | NeutralAccZ = Current_AccZ; |
165 | } |
165 | } |
166 | else |
166 | else |
167 | { |
167 | { |
168 | NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]); |
168 | NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]); |
169 | NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]); |
169 | NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]); |
170 | NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]); |
170 | NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]); |
171 | } |
171 | } |
172 | 172 | ||
173 | Mess_IntegralNick = 0; |
173 | Mess_IntegralNick = 0; |
174 | Mess_IntegralNick2 = 0; |
174 | Mess_IntegralNick2 = 0; |
175 | Mess_IntegralRoll = 0; |
175 | Mess_IntegralRoll = 0; |
176 | Mess_IntegralRoll2 = 0; |
176 | Mess_IntegralRoll2 = 0; |
177 | Mess_Integral_Gier = 0; |
177 | Mess_Integral_Gier = 0; |
178 | MesswertNick = 0; |
178 | MesswertNick = 0; |
179 | MesswertRoll = 0; |
179 | MesswertRoll = 0; |
180 | MesswertGier = 0; |
180 | MesswertGier = 0; |
181 | StartLuftdruck = Luftdruck; |
181 | StartLuftdruck = Luftdruck; |
182 | HoeheD = 0; |
182 | HoeheD = 0; |
183 | Mess_Integral_Hoch = 0; |
183 | Mess_Integral_Hoch = 0; |
184 | KompassStartwert = KompassValue; |
184 | KompassStartwert = KompassValue; |
185 | GPS_Neutral(); |
185 | GPS_Neutral(); |
186 | beeptime = 50; |
186 | BeepTime = 50; |
187 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
187 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
188 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
188 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
Line 189... | Line 189... | ||
189 | ExternHoehenValue = 0; |
189 | ExternHoehenValue = 0; |
190 | } |
190 | } |
191 | 191 | ||
192 | //############################################################################ |
192 | //############################################################################ |
193 | // Bearbeitet die Messwerte |
193 | // Bearbeitet die Messwerte |
194 | void Mittelwert(void) |
194 | void Mittelwert(void) |
195 | //############################################################################ |
195 | //############################################################################ |
196 | { |
196 | { |
197 | static signed long tmpl,tmpl2; |
197 | static signed long tmpl,tmpl2; |
Line 198... | Line 198... | ||
198 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
198 | MesswertGier = (signed int) AdNeutralGier - AdValueGyrGier; |
199 | MesswertRoll = (signed int) AdWertRoll - AdNeutralRoll; |
199 | MesswertRoll = (signed int) AdValueGyrRoll - AdNeutralRoll; |
Line 200... | Line 200... | ||
200 | MesswertNick = (signed int) AdWertNick - AdNeutralNick; |
200 | MesswertNick = (signed int) AdValueGyrNick - AdNeutralNick; |
201 | 201 | ||
202 | //DebugOut.Analog[26] = MesswertNick; |
202 | //DebugOut.Analog[26] = MesswertNick; |
203 | DebugOut.Analog[28] = MesswertRoll; |
203 | DebugOut.Analog[28] = MesswertRoll; |
204 | 204 | ||
205 | // Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++ |
205 | // Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++ |
206 | Mittelwert_AccNick = ((long)Mittelwert_AccNick * 1 + ((ACC_AMPLIFY * (long)AdWertAccNick))) / 2L; |
206 | Mittelwert_AccNick = ((long)Mittelwert_AccNick * 1 + ((ACC_AMPLIFY * (long)AdValueAccNick))) / 2L; |
207 | Mittelwert_AccRoll = ((long)Mittelwert_AccRoll * 1 + ((ACC_AMPLIFY * (long)AdWertAccRoll))) / 2L; |
207 | Mittelwert_AccRoll = ((long)Mittelwert_AccRoll * 1 + ((ACC_AMPLIFY * (long)AdValueAccRoll))) / 2L; |
208 | Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdWertAccHoch)) / 2L; |
208 | Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdValueAccTop)) / 2L; |
209 | IntegralAccNick += ACC_AMPLIFY * AdWertAccNick; |
209 | IntegralAccNick += ACC_AMPLIFY * AdValueAccNick; |
210 | IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll; |
210 | IntegralAccRoll += ACC_AMPLIFY * AdValueAccRoll; |
211 | IntegralAccZ += Aktuell_az - NeutralAccZ; |
211 | IntegralAccZ += Current_AccZ - NeutralAccZ; |
Line 228... | Line 228... | ||
228 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
228 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
229 | MesswertRoll += tmpl; |
229 | MesswertRoll += tmpl; |
230 | MesswertRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109 |
230 | MesswertRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109 |
231 | Mess_IntegralRoll2 += MesswertRoll; |
231 | Mess_IntegralRoll2 += MesswertRoll; |
232 | Mess_IntegralRoll += MesswertRoll - LageKorrekturRoll; |
232 | Mess_IntegralRoll += MesswertRoll - LageKorrekturRoll; |
233 | if(Mess_IntegralRoll > Umschlag180Roll) |
233 | if(Mess_IntegralRoll > Umschlag180Roll) |
234 | { |
234 | { |
235 | Mess_IntegralRoll = -(Umschlag180Roll - 10000L); |
235 | Mess_IntegralRoll = -(Umschlag180Roll - 10000L); |
236 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
236 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
237 | } |
237 | } |
238 | if(Mess_IntegralRoll <-Umschlag180Roll) |
238 | if(Mess_IntegralRoll <-Umschlag180Roll) |
239 | { |
239 | { |
240 | Mess_IntegralRoll = (Umschlag180Roll - 10000L); |
240 | Mess_IntegralRoll = (Umschlag180Roll - 10000L); |
241 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
241 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
242 | } |
242 | } |
243 | if(AdWertRoll < 15) MesswertRoll = -1000; |
243 | if(AdValueGyrRoll < 15) MesswertRoll = -1000; |
244 | if(AdWertRoll < 7) MesswertRoll = -2000; |
244 | if(AdValueGyrRoll < 7) MesswertRoll = -2000; |
245 | if(PlatinenVersion == 10) |
245 | if(PlatinenVersion == 10) |
246 | { |
246 | { |
247 | if(AdWertRoll > 1010) MesswertRoll = +1000; |
247 | if(AdValueGyrRoll > 1010) MesswertRoll = +1000; |
248 | if(AdWertRoll > 1017) MesswertRoll = +2000; |
248 | if(AdValueGyrRoll > 1017) MesswertRoll = +2000; |
249 | } |
249 | } |
250 | else |
250 | else |
251 | { |
251 | { |
252 | if(AdWertRoll > 2020) MesswertRoll = +1000; |
252 | if(AdValueGyrRoll > 2020) MesswertRoll = +1000; |
253 | if(AdWertRoll > 2034) MesswertRoll = +2000; |
253 | if(AdValueGyrRoll > 2034) MesswertRoll = +2000; |
254 | } |
254 | } |
255 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
255 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
256 | MesswertNick -= tmpl2; |
256 | MesswertNick -= tmpl2; |
257 | MesswertNick -= (tmpl*Parameter_AchsGegenKopplung1)/512L; |
257 | MesswertNick -= (tmpl*Parameter_AchsGegenKopplung1)/512L; |
258 | Mess_IntegralNick2 += MesswertNick; |
258 | Mess_IntegralNick2 += MesswertNick; |
259 | Mess_IntegralNick += MesswertNick - LageKorrekturNick; |
259 | Mess_IntegralNick += MesswertNick - LageKorrekturNick; |
260 | if(Mess_IntegralNick > Umschlag180Nick) |
260 | if(Mess_IntegralNick > Umschlag180Nick) |
261 | { |
261 | { |
262 | Mess_IntegralNick = -(Umschlag180Nick - 10000L); |
262 | Mess_IntegralNick = -(Umschlag180Nick - 10000L); |
263 | Mess_IntegralNick2 = Mess_IntegralNick; |
263 | Mess_IntegralNick2 = Mess_IntegralNick; |
264 | } |
264 | } |
265 | if(Mess_IntegralNick <-Umschlag180Nick) |
265 | if(Mess_IntegralNick <-Umschlag180Nick) |
266 | { |
266 | { |
267 | Mess_IntegralNick = (Umschlag180Nick - 10000L); |
267 | Mess_IntegralNick = (Umschlag180Nick - 10000L); |
268 | Mess_IntegralNick2 = Mess_IntegralNick; |
268 | Mess_IntegralNick2 = Mess_IntegralNick; |
269 | } |
269 | } |
270 | if(AdWertNick < 15) MesswertNick = -1000; |
270 | if(AdValueGyrNick < 15) MesswertNick = -1000; |
271 | if(AdWertNick < 7) MesswertNick = -2000; |
271 | if(AdValueGyrNick < 7) MesswertNick = -2000; |
272 | if(PlatinenVersion == 10) |
272 | if(PlatinenVersion == 10) |
273 | { |
273 | { |
274 | if(AdWertNick > 1010) MesswertNick = +1000; |
274 | if(AdValueGyrNick > 1010) MesswertNick = +1000; |
275 | if(AdWertNick > 1017) MesswertNick = +2000; |
275 | if(AdValueGyrNick > 1017) MesswertNick = +2000; |
276 | } |
276 | } |
277 | else |
277 | else |
278 | { |
278 | { |
279 | if(AdWertNick > 2020) MesswertNick = +1000; |
279 | if(AdValueGyrNick > 2020) MesswertNick = +1000; |
280 | if(AdWertNick > 2034) MesswertNick = +2000; |
280 | if(AdValueGyrNick > 2034) MesswertNick = +2000; |
281 | } |
281 | } |
282 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
282 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
283 | // ADC einschalten |
283 | // ADC einschalten |
284 | ANALOG_ON; |
284 | ADC_Enable(); |
285 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
285 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 286... | Line 286... | ||
286 | 286 | ||
287 | Integral_Gier = Mess_Integral_Gier; |
287 | Integral_Gier = Mess_Integral_Gier; |
288 | IntegralNick = Mess_IntegralNick; |
288 | IntegralNick = Mess_IntegralNick; |
289 | IntegralRoll = Mess_IntegralRoll; |
289 | IntegralRoll = Mess_IntegralRoll; |
290 | IntegralNick2 = Mess_IntegralNick2; |
290 | IntegralNick2 = Mess_IntegralNick2; |
Line 291... | Line 291... | ||
291 | IntegralRoll2 = Mess_IntegralRoll2; |
291 | IntegralRoll2 = Mess_IntegralRoll2; |
292 | 292 | ||
293 | if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) |
293 | if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll) |
294 | { |
294 | { |
295 | if(MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200); |
295 | if(MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200); |
296 | else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200); |
296 | else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200); |
297 | if(MesswertRoll > 200) MesswertRoll += 4 * (MesswertRoll - 200); |
297 | if(MesswertRoll > 200) MesswertRoll += 4 * (MesswertRoll - 200); |
298 | else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200); |
298 | else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200); |
299 | } |
299 | } |
300 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
300 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
301 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
301 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
Line 309... | Line 309... | ||
309 | 309 | ||
310 | //############################################################################ |
310 | //############################################################################ |
311 | // Messwerte beim Ermitteln der Nullage |
311 | // Messwerte beim Ermitteln der Nullage |
312 | void CalibrierMittelwert(void) |
312 | void CalibrierMittelwert(void) |
313 | //############################################################################ |
313 | //############################################################################ |
314 | { |
314 | { |
315 | // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern |
315 | // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern |
316 | ANALOG_OFF; |
316 | ADC_Disable(); |
317 | MesswertNick = AdWertNick; |
317 | MesswertNick = AdValueGyrNick; |
318 | MesswertRoll = AdWertRoll; |
318 | MesswertRoll = AdValueGyrRoll; |
319 | MesswertGier = AdWertGier; |
319 | MesswertGier = AdValueGyrGier; |
320 | Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick; |
320 | Mittelwert_AccNick = ACC_AMPLIFY * (long)AdValueAccNick; |
321 | Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll; |
321 | Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdValueAccRoll; |
322 | Mittelwert_AccHoch = (long)AdWertAccHoch; |
322 | Mittelwert_AccHoch = (long)AdValueAccTop; |
323 | // ADC einschalten |
323 | // ADC einschalten |
324 | ANALOG_ON; |
324 | ADC_Enable(); |
325 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
325 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
326 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
326 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
327 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
327 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
328 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
328 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
Line 337... | Line 337... | ||
337 | 337 | ||
338 | //############################################################################ |
338 | //############################################################################ |
339 | // Senden der Motorwerte per I2C-Bus |
339 | // Senden der Motorwerte per I2C-Bus |
340 | void SendMotorData(void) |
340 | void SendMotorData(void) |
341 | //############################################################################ |
341 | //############################################################################ |
342 | { |
342 | { |
343 | if(MOTOR_OFF || !MotorenEin) |
343 | if(MOTOR_OFF || !MotorenEin) |
344 | { |
344 | { |
345 | Motor_Hinten = 0; |
345 | Motor_Hinten = 0; |
346 | Motor_Vorne = 0; |
346 | Motor_Vorne = 0; |
Line 353... | Line 353... | ||
353 | } |
353 | } |
Line 354... | Line 354... | ||
354 | 354 | ||
355 | DebugOut.Analog[12] = Motor_Vorne; |
355 | DebugOut.Analog[12] = Motor_Vorne; |
356 | DebugOut.Analog[13] = Motor_Hinten; |
356 | DebugOut.Analog[13] = Motor_Hinten; |
357 | DebugOut.Analog[14] = Motor_Links; |
357 | DebugOut.Analog[14] = Motor_Links; |
Line 358... | Line 358... | ||
358 | DebugOut.Analog[15] = Motor_Rechts; |
358 | DebugOut.Analog[15] = Motor_Rechts; |
359 | 359 | ||
360 | //Start I2C Interrupt Mode |
360 | //Start I2C Interrupt Mode |
361 | twi_state = 0; |
361 | twi_state = 0; |
362 | motor = 0; |
362 | motor = 0; |
Line 363... | Line 363... | ||
363 | i2c_start(); |
363 | i2c_start(); |
364 | } |
364 | } |
365 | 365 | ||
366 | 366 | ||
367 | 367 | ||
Line 368... | Line 368... | ||
368 | //############################################################################ |
368 | //############################################################################ |
369 | // Trägt ggf. das Poti als Parameter ein |
369 | // Trägt ggf. das Poti als Parameter ein |
Line 377... | Line 377... | ||
377 | CHK_POTI(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100); |
377 | CHK_POTI(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100); |
378 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255); |
378 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255); |
379 | CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255); |
379 | CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255); |
380 | CHK_POTI(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255); |
380 | CHK_POTI(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255); |
381 | CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255); |
381 | CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255); |
382 | CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255); |
382 | CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255); |
383 | CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255); |
383 | CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255); |
384 | CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255); |
384 | CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255); |
385 | CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255); |
385 | CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255); |
386 | CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255); |
386 | CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255); |
387 | CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255); |
387 | CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255); |
388 | CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255); |
388 | CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255); |
389 | CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255); |
389 | CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255); |
390 | CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255); |
390 | CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255); |
391 | CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255); |
391 | CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255); |
392 | CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255); |
392 | CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255); |
393 | CHK_POTI(Parameter_AchsKopplung1, EE_Parameter.AchsKopplung1,0,255); |
393 | CHK_POTI(Parameter_AchsKopplung1, EE_Parameter.AchsKopplung1,0,255); |
394 | CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255); |
394 | CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255); |
395 | CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255); |
395 | CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255); |
Line 417... | Line 417... | ||
417 | static unsigned int modell_fliegt = 0; |
417 | static unsigned int modell_fliegt = 0; |
418 | static int hoehenregler = 0; |
418 | static int hoehenregler = 0; |
419 | static char TimerWerteausgabe = 0; |
419 | static char TimerWerteausgabe = 0; |
420 | static char NeueKompassRichtungMerken = 0; |
420 | static char NeueKompassRichtungMerken = 0; |
421 | static long ausgleichNick, ausgleichRoll; |
421 | static long ausgleichNick, ausgleichRoll; |
422 | 422 | ||
423 | Mittelwert(); |
423 | Mittelwert(); |
Line 424... | Line 424... | ||
424 | 424 | ||
425 | GRN_ON; |
425 | GRN_ON; |
426 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
426 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
427 | // Gaswert ermitteln |
427 | // Gaswert ermitteln |
428 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
428 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
429 | GasMischanteil = StickGas; |
429 | GasMischanteil = StickGas; |
430 | if(GasMischanteil < 0) GasMischanteil = 0; |
430 | if(GasMischanteil < 0) GasMischanteil = 0; |
431 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
431 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
432 | // Emfang schlecht |
432 | // Emfang schlecht |
433 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
433 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
434 | if(SenderOkay < 100) |
434 | if(SenderOkay < 100) |
435 | { |
435 | { |
436 | if(!PcZugriff) |
436 | if(!PcZugriff) |
437 | { |
437 | { |
438 | if(BeepMuster == 0xffff) |
438 | if(BeepModulation == 0xFFFF) |
439 | { |
439 | { |
440 | beeptime = 15000; |
440 | BeepTime = 15000; // 1.5 seconds |
441 | BeepMuster = 0x0c00; |
441 | BeepModulation = 0x0C00; |
442 | } |
442 | } |
443 | } |
443 | } |
444 | if(RcLostTimer) RcLostTimer--; |
444 | if(RcLostTimer) RcLostTimer--; |
445 | else |
445 | else |
446 | { |
446 | { |
447 | MotorenEin = 0; |
447 | MotorenEin = 0; |
448 | Notlandung = 0; |
448 | Notlandung = 0; |
449 | } |
449 | } |
450 | ROT_ON; |
450 | ROT_ON; |
451 | if(modell_fliegt > 2000) // wahrscheinlich in der Luft --> langsam absenken |
451 | if(modell_fliegt > 2000) // wahrscheinlich in der Luft --> langsam absenken |
452 | { |
452 | { |
453 | GasMischanteil = EE_Parameter.NotGas; |
453 | GasMischanteil = EE_Parameter.NotGas; |
Line 456... | Line 456... | ||
456 | PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
456 | PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
457 | PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0; |
457 | PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0; |
458 | } |
458 | } |
459 | else MotorenEin = 0; |
459 | else MotorenEin = 0; |
460 | } |
460 | } |
461 | else |
461 | else |
462 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
462 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
463 | // Emfang gut |
463 | // Emfang gut |
464 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
464 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
465 | if(SenderOkay > 140) |
465 | if(SenderOkay > 140) |
466 | { |
466 | { |
467 | Notlandung = 0; |
467 | Notlandung = 0; |
468 | RcLostTimer = EE_Parameter.NotGasZeit * 50; |
468 | RcLostTimer = EE_Parameter.NotGasZeit * 50; |
469 | if(GasMischanteil > 40) |
469 | if(GasMischanteil > 40) |
Line 472... | Line 472... | ||
472 | } |
472 | } |
473 | if((modell_fliegt < 200) || (GasMischanteil < 40)) |
473 | if((modell_fliegt < 200) || (GasMischanteil < 40)) |
474 | { |
474 | { |
475 | SummeNick = 0; |
475 | SummeNick = 0; |
476 | SummeRoll = 0; |
476 | SummeRoll = 0; |
477 | Mess_Integral_Gier = 0; |
477 | Mess_Integral_Gier = 0; |
478 | Mess_Integral_Gier2 = 0; |
478 | Mess_Integral_Gier2 = 0; |
479 | } |
479 | } |
480 | if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) |
480 | if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) |
481 | { |
481 | { |
482 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
482 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
483 | // auf Nullwerte kalibrieren |
483 | // auf Nullwerte kalibrieren |
484 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
484 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
485 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) // Neutralwerte |
485 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) // Neutralwerte |
486 | { |
486 | { |
487 | if(++delay_neutral > 200) // nicht sofort |
487 | if(++delay_neutral > 200) // nicht sofort |
488 | { |
488 | { |
489 | GRN_OFF; |
489 | GRN_OFF; |
Line 501... | Line 501... | ||
501 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], setting); // aktiven Datensatz merken |
501 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], setting); // aktiven Datensatz merken |
502 | } |
502 | } |
503 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
503 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
504 | { |
504 | { |
505 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
505 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
506 | } |
506 | } |
507 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
507 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
508 | SetNeutral(); |
508 | SetNeutral(); |
509 | Piep(GetActiveParamSetNumber()); |
509 | Piep(GetActiveParamSetNumber()); |
510 | } |
510 | } |
511 | } |
511 | } |
512 | else |
512 | else |
513 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern |
513 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) // ACC Neutralwerte speichern |
514 | { |
514 | { |
515 | if(++delay_neutral > 200) // nicht sofort |
515 | if(++delay_neutral > 200) // nicht sofort |
516 | { |
516 | { |
517 | GRN_OFF; |
517 | GRN_OFF; |
Line 525... | Line 525... | ||
525 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL],NeutralAccY / 256); |
525 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL],NeutralAccY / 256); |
526 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256); |
526 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256); |
527 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256); |
527 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256); |
528 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256); |
528 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256); |
529 | Piep(GetActiveParamSetNumber()); |
529 | Piep(GetActiveParamSetNumber()); |
530 | } |
530 | } |
531 | } |
531 | } |
532 | else delay_neutral = 0; |
532 | else delay_neutral = 0; |
533 | } |
533 | } |
534 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
534 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
535 | // Gas ist unten |
535 | // Gas ist unten |
536 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
536 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
537 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120) |
537 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120) |
538 | { |
538 | { |
539 | // Starten |
539 | // Starten |
540 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) |
540 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) |
541 | { |
541 | { |
542 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
542 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
543 | // Einschalten |
543 | // Einschalten |
544 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
544 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
545 | if(++delay_einschalten > 200) |
545 | if(++delay_einschalten > 200) |
546 | { |
546 | { |
547 | delay_einschalten = 200; |
547 | delay_einschalten = 200; |
548 | modell_fliegt = 1; |
548 | modell_fliegt = 1; |
549 | MotorenEin = 1; |
549 | MotorenEin = 1; |
550 | sollGier = 0; |
550 | sollGier = 0; |
551 | Mess_Integral_Gier = 0; |
551 | Mess_Integral_Gier = 0; |
552 | Mess_Integral_Gier2 = 0; |
552 | Mess_Integral_Gier2 = 0; |
553 | Mess_IntegralNick = 0; |
553 | Mess_IntegralNick = 0; |
554 | Mess_IntegralRoll = 0; |
554 | Mess_IntegralRoll = 0; |
555 | Mess_IntegralNick2 = IntegralNick; |
555 | Mess_IntegralNick2 = IntegralNick; |
556 | Mess_IntegralRoll2 = IntegralRoll; |
556 | Mess_IntegralRoll2 = IntegralRoll; |
557 | SummeNick = 0; |
557 | SummeNick = 0; |
558 | SummeRoll = 0; |
558 | SummeRoll = 0; |
559 | } |
559 | } |
560 | } |
560 | } |
561 | else delay_einschalten = 0; |
561 | else delay_einschalten = 0; |
562 | //Auf Neutralwerte setzen |
562 | //Auf Neutralwerte setzen |
563 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
563 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
564 | // Auschalten |
564 | // Auschalten |
565 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
565 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
566 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) |
566 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) |
567 | { |
567 | { |
568 | if(++delay_ausschalten > 200) // nicht sofort |
568 | if(++delay_ausschalten > 200) // nicht sofort |
569 | { |
569 | { |
570 | MotorenEin = 0; |
570 | MotorenEin = 0; |
571 | delay_ausschalten = 200; |
571 | delay_ausschalten = 200; |
572 | modell_fliegt = 0; |
572 | modell_fliegt = 0; |
573 | } |
573 | } |
574 | } |
574 | } |
575 | else delay_ausschalten = 0; |
575 | else delay_ausschalten = 0; |
576 | } |
576 | } |
577 | } |
577 | } |
Line 578... | Line 578... | ||
578 | 578 | ||
579 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
579 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
580 | // neue Werte von der Funke |
580 | // neue Werte von der Funke |
581 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
581 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
582 | if(!NewPpmData-- || Notlandung) |
582 | if(!NewPpmData-- || Notlandung) |
583 | { |
583 | { |
584 | int tmp_int; |
584 | int tmp_int; |
585 | static int stick_nick,stick_roll; |
585 | static int stick_nick,stick_roll; |
586 | ParameterZuordnung(); |
586 | ParameterZuordnung(); |
587 | StickNick = (StickNick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4; |
587 | StickNick = (StickNick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4; |
588 | StickNick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D; |
588 | StickNick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D; |
589 | StickRoll = (StickRoll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4; |
589 | StickRoll = (StickRoll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4; |
Line 590... | Line 590... | ||
590 | StickRoll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
590 | StickRoll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D; |
591 | 591 | ||
Line 592... | Line 592... | ||
592 | StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; |
592 | StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; |
593 | StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120; |
593 | StickGas = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120; |
594 | 594 | ||
595 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick) |
595 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick) |
596 | MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--; |
596 | MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--; |
Line 597... | Line 597... | ||
597 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll) |
597 | if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll) |
598 | MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--; |
598 | MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--; |
Line 599... | Line 599... | ||
599 | if(Notlandung) {MaxStickNick = 0; MaxStickRoll = 0;} |
599 | if(Notlandung) {MaxStickNick = 0; MaxStickRoll = 0;} |
600 | 600 | ||
601 | GyroFaktor = ((float)Parameter_Gyro_P + 10.0) / 256.0; |
601 | GyroFaktor = ((float)Parameter_Gyro_P + 10.0) / 256.0; |
602 | IntegralFaktor = ((float) Parameter_Gyro_I) / 44000; |
602 | IntegralFaktor = ((float) Parameter_Gyro_I) / 44000; |
603 | 603 | ||
604 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
604 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
605 | //+ Digitale Steuerung per DubWise |
605 | //+ Digitale Steuerung per DubWise |
606 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
606 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
607 | #define KEY_VALUE (Parameter_UserParam1 * 4) //(Poti3 * 8) |
607 | #define KEY_VALUE (Parameter_UserParam1 * 4) //(Poti3 * 8) |
608 | if(DubWiseKeys[1]) beeptime = 10; |
608 | if(DubWiseKeys[1]) BeepTime = 10; |
Line 634... | Line 634... | ||
634 | } |
634 | } |
Line 635... | Line 635... | ||
635 | 635 | ||
636 | if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0; |
636 | if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0; |
637 | if(GyroFaktor < 0) GyroFaktor = 0; |
637 | if(GyroFaktor < 0) GyroFaktor = 0; |
638 | if(IntegralFaktor < 0) IntegralFaktor = 0; |
638 | if(IntegralFaktor < 0) IntegralFaktor = 0; |
639 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
639 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
640 | // Looping? |
640 | // Looping? |
641 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
641 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
642 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_LINKS) Looping_Links = 1; |
642 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_LINKS) Looping_Links = 1; |
643 | else |
643 | else |
644 | { |
644 | { |
645 | { |
645 | { |
646 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0; |
646 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0; |
647 | } |
647 | } |
648 | } |
648 | } |
649 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1; |
649 | if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1; |
650 | else |
650 | else |
651 | { |
651 | { |
652 | if(Looping_Rechts) // Hysterese |
652 | if(Looping_Rechts) // Hysterese |
653 | { |
653 | { |
654 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0; |
654 | if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0; |
655 | } |
655 | } |
Line 656... | Line 656... | ||
656 | } |
656 | } |
657 | 657 | ||
658 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_OBEN) Looping_Oben = 1; |
658 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_OBEN) Looping_Oben = 1; |
659 | else |
659 | else |
660 | { |
660 | { |
661 | if(Looping_Oben) // Hysterese |
661 | if(Looping_Oben) // Hysterese |
662 | { |
662 | { |
663 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0; |
663 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0; |
664 | } |
664 | } |
665 | } |
665 | } |
666 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_UNTEN) Looping_Unten = 1; |
666 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_UNTEN) Looping_Unten = 1; |
667 | else |
667 | else |
668 | { |
668 | { |
669 | if(Looping_Unten) // Hysterese |
669 | if(Looping_Unten) // Hysterese |
670 | { |
670 | { |
671 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0; |
671 | if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0; |
Line 672... | Line 672... | ||
672 | } |
672 | } |
673 | } |
673 | } |
674 | 674 | ||
Line 675... | Line 675... | ||
675 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
675 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
676 | if(Looping_Oben || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
676 | if(Looping_Oben || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
677 | } // Ende neue Funken-Werte |
677 | } // Ende neue Funken-Werte |
678 | 678 | ||
679 | if(Looping_Roll) beeptime = 100; |
679 | if(Looping_Roll) BeepTime = 100; |
680 | if(Looping_Roll || Looping_Nick) |
- | |
Line -... | Line 680... | ||
- | 680 | if(Looping_Roll || Looping_Nick) |
|
681 | { |
681 | { |
682 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
682 | if(GasMischanteil > EE_Parameter.LoopGasLimit) GasMischanteil = EE_Parameter.LoopGasLimit; |
683 | } |
683 | } |
684 | 684 | ||
685 | 685 | ||
686 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
686 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
687 | // Bei Empfangsausfall im Flug |
687 | // Bei Empfangsausfall im Flug |
688 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
688 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
689 | if(Notlandung) |
689 | if(Notlandung) |
690 | { |
690 | { |
691 | StickGier = 0; |
691 | StickGier = 0; |
692 | StickNick = 0; |
692 | StickNick = 0; |
693 | StickRoll = 0; |
693 | StickRoll = 0; |
Line 694... | Line 694... | ||
694 | GyroFaktor = 0.1; |
694 | GyroFaktor = 0.1; |
695 | IntegralFaktor = 0.005; |
695 | IntegralFaktor = 0.005; |
696 | Looping_Roll = 0; |
696 | Looping_Roll = 0; |
697 | Looping_Nick = 0; |
697 | Looping_Nick = 0; |
Line 698... | Line 698... | ||
698 | } |
698 | } |
699 | 699 | ||
700 | 700 | ||
Line 721... | Line 721... | ||
721 | ZaehlMessungen = 0; |
721 | ZaehlMessungen = 0; |
722 | LageKorrekturNick = 0; |
722 | LageKorrekturNick = 0; |
723 | LageKorrekturRoll = 0; |
723 | LageKorrekturRoll = 0; |
724 | } |
724 | } |
Line 725... | Line 725... | ||
725 | 725 | ||
726 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
726 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
727 | if(!Looping_Nick && !Looping_Roll) |
727 | if(!Looping_Nick && !Looping_Roll) |
728 | { |
728 | { |
729 | long tmp_long, tmp_long2; |
729 | long tmp_long, tmp_long2; |
730 | tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick); |
730 | tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick); |
731 | tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll); |
731 | tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll); |
732 | tmp_long /= 16; |
732 | tmp_long /= 16; |
733 | tmp_long2 /= 16; |
733 | tmp_long2 /= 16; |
734 | if((MaxStickNick > 15) || (MaxStickRoll > 15)) |
734 | if((MaxStickNick > 15) || (MaxStickRoll > 15)) |
735 | { |
735 | { |
Line 749... | Line 749... | ||
749 | if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH; |
749 | if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH; |
Line 750... | Line 750... | ||
750 | 750 | ||
751 | Mess_IntegralNick -= tmp_long; |
751 | Mess_IntegralNick -= tmp_long; |
752 | Mess_IntegralRoll -= tmp_long2; |
752 | Mess_IntegralRoll -= tmp_long2; |
753 | } |
753 | } |
Line 754... | Line 754... | ||
754 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
754 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
755 | 755 | ||
756 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
756 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
757 | { |
757 | { |
Line 767... | Line 767... | ||
767 | IntegralAccZ = IntegralAccZ / ABGLEICH_ANZAHL; |
767 | IntegralAccZ = IntegralAccZ / ABGLEICH_ANZAHL; |
768 | #define MAX_I 0//(Poti2/10) |
768 | #define MAX_I 0//(Poti2/10) |
769 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
769 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
770 | IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick); |
770 | IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick); |
771 | ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich; |
771 | ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich; |
772 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
772 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
773 | IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll); |
773 | IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll); |
774 | ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich; |
774 | ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich; |
Line 775... | Line 775... | ||
775 | 775 | ||
776 | LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL; |
776 | LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL; |
Line 780... | Line 780... | ||
780 | { |
780 | { |
781 | LageKorrekturNick /= 2; |
781 | LageKorrekturNick /= 2; |
782 | LageKorrekturNick /= 2; |
782 | LageKorrekturNick /= 2; |
783 | } |
783 | } |
Line 784... | Line 784... | ||
784 | 784 | ||
785 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
785 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
786 | // Gyro-Drift ermitteln |
786 | // Gyro-Drift ermitteln |
787 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
787 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
788 | MittelIntegralNick2 /= ABGLEICH_ANZAHL; |
788 | MittelIntegralNick2 /= ABGLEICH_ANZAHL; |
789 | MittelIntegralRoll2 /= ABGLEICH_ANZAHL; |
789 | MittelIntegralRoll2 /= ABGLEICH_ANZAHL; |
790 | tmp_long = IntegralNick2 - IntegralNick; |
790 | tmp_long = IntegralNick2 - IntegralNick; |
791 | tmp_long2 = IntegralRoll2 - IntegralRoll; |
791 | tmp_long2 = IntegralRoll2 - IntegralRoll; |
Line 792... | Line 792... | ||
792 | //DebugOut.Analog[25] = MittelIntegralRoll2 / 26; |
792 | //DebugOut.Analog[25] = MittelIntegralRoll2 / 26; |
793 | 793 | ||
794 | IntegralFehlerNick = tmp_long; |
794 | IntegralFehlerNick = tmp_long; |
Line 815... | Line 815... | ||
815 | #define BEWEGUNGS_LIMIT 20000 |
815 | #define BEWEGUNGS_LIMIT 20000 |
816 | // Nick +++++++++++++++++++++++++++++++++++++++++++++++++ |
816 | // Nick +++++++++++++++++++++++++++++++++++++++++++++++++ |
817 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
817 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
818 | if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT) |
818 | if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT) |
819 | { |
819 | { |
820 | if(IntegralFehlerNick > FEHLER_LIMIT2) |
820 | if(IntegralFehlerNick > FEHLER_LIMIT2) |
821 | { |
821 | { |
822 | if(last_n_p) |
822 | if(last_n_p) |
823 | { |
823 | { |
824 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
824 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
825 | ausgleichNick = IntegralFehlerNick / 8; |
825 | ausgleichNick = IntegralFehlerNick / 8; |
826 | if(ausgleichNick > 5000) ausgleichNick = 5000; |
826 | if(ausgleichNick > 5000) ausgleichNick = 5000; |
827 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
827 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
828 | } |
828 | } |
829 | else last_n_p = 1; |
829 | else last_n_p = 1; |
830 | } else last_n_p = 0; |
830 | } else last_n_p = 0; |
831 | if(IntegralFehlerNick < -FEHLER_LIMIT2) |
831 | if(IntegralFehlerNick < -FEHLER_LIMIT2) |
832 | { |
832 | { |
833 | if(last_n_n) |
833 | if(last_n_n) |
834 | { |
834 | { |
835 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
835 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
836 | ausgleichNick = IntegralFehlerNick / 8; |
836 | ausgleichNick = IntegralFehlerNick / 8; |
837 | if(ausgleichNick < -5000) ausgleichNick = -5000; |
837 | if(ausgleichNick < -5000) ausgleichNick = -5000; |
838 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
838 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
839 | } |
839 | } |
840 | else last_n_n = 1; |
840 | else last_n_n = 1; |
841 | } else last_n_n = 0; |
841 | } else last_n_n = 0; |
842 | } else cnt = 0; |
842 | } else cnt = 0; |
843 | if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
843 | if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
844 | if(IntegralFehlerNick > FEHLER_LIMIT) AdNeutralNick += cnt; |
844 | if(IntegralFehlerNick > FEHLER_LIMIT) AdNeutralNick += cnt; |
Line 848... | Line 848... | ||
848 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
848 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
Line 849... | Line 849... | ||
849 | 849 | ||
850 | ausgleichRoll = 0; |
850 | ausgleichRoll = 0; |
851 | if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT) |
851 | if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT) |
852 | { |
852 | { |
853 | if(IntegralFehlerRoll > FEHLER_LIMIT2) |
853 | if(IntegralFehlerRoll > FEHLER_LIMIT2) |
854 | { |
854 | { |
855 | if(last_r_p) |
855 | if(last_r_p) |
856 | { |
856 | { |
857 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
857 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
858 | ausgleichRoll = IntegralFehlerRoll / 8; |
858 | ausgleichRoll = IntegralFehlerRoll / 8; |
859 | if(ausgleichRoll > 5000) ausgleichRoll = 5000; |
859 | if(ausgleichRoll > 5000) ausgleichRoll = 5000; |
860 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
860 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
861 | } |
861 | } |
862 | else last_r_p = 1; |
862 | else last_r_p = 1; |
863 | } else last_r_p = 0; |
863 | } else last_r_p = 0; |
864 | if(IntegralFehlerRoll < -FEHLER_LIMIT2) |
864 | if(IntegralFehlerRoll < -FEHLER_LIMIT2) |
865 | { |
865 | { |
866 | if(last_r_n) |
866 | if(last_r_n) |
867 | { |
867 | { |
868 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
868 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
869 | ausgleichRoll = IntegralFehlerRoll / 8; |
869 | ausgleichRoll = IntegralFehlerRoll / 8; |
870 | if(ausgleichRoll < -5000) ausgleichRoll = -5000; |
870 | if(ausgleichRoll < -5000) ausgleichRoll = -5000; |
871 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
871 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
872 | } |
872 | } |
873 | else last_r_n = 1; |
873 | else last_r_n = 1; |
874 | } else last_r_n = 0; |
874 | } else last_r_n = 0; |
875 | } else |
875 | } else |
876 | { |
876 | { |
877 | cnt = 0; |
877 | cnt = 0; |
Line 878... | Line 878... | ||
878 | } |
878 | } |
879 | 879 | ||
880 | if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
880 | if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp; |
881 | if(IntegralFehlerRoll > FEHLER_LIMIT) AdNeutralRoll += cnt; |
881 | if(IntegralFehlerRoll > FEHLER_LIMIT) AdNeutralRoll += cnt; |
882 | if(IntegralFehlerRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt; |
882 | if(IntegralFehlerRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt; |
883 | DebugOut.Analog[27] = ausgleichRoll; |
883 | DebugOut.Analog[27] = ausgleichRoll; |
884 | DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick); |
884 | DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick); |
885 | DebugOut.Analog[24] = 10*(AdNeutralRoll - StartNeutralRoll); |
885 | DebugOut.Analog[24] = 10*(AdNeutralRoll - StartNeutralRoll); |
886 | } |
886 | } |
887 | else |
887 | else |
888 | { |
888 | { |
889 | LageKorrekturRoll = 0; |
889 | LageKorrekturRoll = 0; |
Line 890... | Line 890... | ||
890 | LageKorrekturNick = 0; |
890 | LageKorrekturNick = 0; |
891 | } |
891 | } |
892 | 892 | ||
893 | if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH |
893 | if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH |
894 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
894 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
895 | MittelIntegralNick_Alt = MittelIntegralNick; |
895 | MittelIntegralNick_Alt = MittelIntegralNick; |
896 | MittelIntegralRoll_Alt = MittelIntegralRoll; |
896 | MittelIntegralRoll_Alt = MittelIntegralRoll; |
897 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
897 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
898 | IntegralAccNick = 0; |
898 | IntegralAccNick = 0; |
899 | IntegralAccRoll = 0; |
899 | IntegralAccRoll = 0; |
Line 904... | Line 904... | ||
904 | MittelIntegralRoll2 = 0; |
904 | MittelIntegralRoll2 = 0; |
905 | ZaehlMessungen = 0; |
905 | ZaehlMessungen = 0; |
906 | } |
906 | } |
907 | //DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor); |
907 | //DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor); |
Line 908... | Line 908... | ||
908 | 908 | ||
909 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
909 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
910 | // Gieren |
910 | // Gieren |
911 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
911 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
912 | if(abs(StickGier) > 20) // war 35 |
912 | if(abs(StickGier) > 20) // war 35 |
913 | { |
913 | { |
914 | if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) NeueKompassRichtungMerken = 1; |
914 | if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) NeueKompassRichtungMerken = 1; |
915 | } |
915 | } |
916 | tmp_int = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
916 | tmp_int = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
917 | tmp_int += (EE_Parameter.Gier_P * StickGier) / 4; |
917 | tmp_int += (EE_Parameter.Gier_P * StickGier) / 4; |
918 | sollGier = tmp_int; |
918 | sollGier = tmp_int; |
919 | Mess_Integral_Gier -= tmp_int; |
919 | Mess_Integral_Gier -= tmp_int; |
920 | if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen |
920 | if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen |
921 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
921 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
922 | 922 | ||
923 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
923 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
924 | // Kompass |
924 | // Kompass |
925 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
925 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
926 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
926 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
927 | { |
927 | { |
928 | int w,v; |
928 | int w,v; |
929 | static int SignalSchlecht = 0; |
929 | static int SignalSchlecht = 0; |
930 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
930 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
931 | v = abs(IntegralRoll /512); |
931 | v = abs(IntegralRoll /512); |
932 | if(v > w) w = v; // grösste Neigung ermitteln |
932 | if(v > w) w = v; // grösste Neigung ermitteln |
933 | if(w < 25 && NeueKompassRichtungMerken && !SignalSchlecht) |
933 | if(w < 25 && NeueKompassRichtungMerken && !SignalSchlecht) |
934 | { |
934 | { |
935 | KompassStartwert = KompassValue; |
935 | KompassStartwert = KompassValue; |
936 | NeueKompassRichtungMerken = 0; |
936 | NeueKompassRichtungMerken = 0; |
937 | } |
937 | } |
938 | w = (w * Parameter_KompassWirkung) / 64; // auf die Wirkung normieren |
938 | w = (w * Parameter_KompassWirkung) / 64; // auf die Wirkung normieren |
939 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
939 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
940 | if(w > 0) |
940 | if(w > 0) |
941 | { |
941 | { |
942 | if(!SignalSchlecht) Mess_Integral_Gier += (KompassRichtung * w) / 32; // nach Kompass ausrichten |
942 | if(!SignalSchlecht) Mess_Integral_Gier += (KompassRichtung * w) / 32; // nach Kompass ausrichten |
943 | if(SignalSchlecht) SignalSchlecht--; |
943 | if(SignalSchlecht) SignalSchlecht--; |
944 | } |
944 | } |
945 | else SignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek |
945 | else SignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek |
946 | } |
946 | } |
Line 947... | Line 947... | ||
947 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
947 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
948 | 948 | ||
949 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
949 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
950 | // Debugwerte zuordnen |
950 | // Debugwerte zuordnen |
951 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
951 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
952 | if(!TimerWerteausgabe--) |
952 | if(!TimerWerteausgabe--) |
953 | { |
953 | { |
954 | TimerWerteausgabe = 24; |
954 | TimerWerteausgabe = 24; |
Line 978... | Line 978... | ||
978 | */ |
978 | */ |
979 | // DebugOut.Analog[9] = MesswertNick; |
979 | // DebugOut.Analog[9] = MesswertNick; |
980 | // DebugOut.Analog[9] = SollHoehe; |
980 | // DebugOut.Analog[9] = SollHoehe; |
981 | // DebugOut.Analog[10] = Mess_Integral_Gier / 128; |
981 | // DebugOut.Analog[10] = Mess_Integral_Gier / 128; |
982 | // DebugOut.Analog[11] = KompassStartwert; |
982 | // DebugOut.Analog[11] = KompassStartwert; |
983 | // DebugOut.Analog[10] = Parameter_Gyro_I; |
983 | // DebugOut.Analog[10] = Parameter_Gyro_I; |
984 | // DebugOut.Analog[10] = EE_Parameter.Gyro_I; |
984 | // DebugOut.Analog[10] = EE_Parameter.Gyro_I; |
985 | // DebugOut.Analog[9] = KompassRichtung; |
985 | // DebugOut.Analog[9] = KompassRichtung; |
986 | // DebugOut.Analog[10] = GasMischanteil; |
986 | // DebugOut.Analog[10] = GasMischanteil; |
987 | // DebugOut.Analog[3] = HoeheD * 32; |
987 | // DebugOut.Analog[3] = HoeheD * 32; |
988 | // DebugOut.Analog[4] = hoehenregler; |
988 | // DebugOut.Analog[4] = hoehenregler; |
989 | } |
989 | } |
Line 990... | Line 990... | ||
990 | 990 | ||
991 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
991 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
992 | // Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen |
992 | // Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen |
993 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
993 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
994 | //DebugOut.Analog[26] = MesswertNick; |
994 | //DebugOut.Analog[26] = MesswertNick; |
Line 995... | Line 995... | ||
995 | //DebugOut.Analog[28] = MesswertRoll; |
995 | //DebugOut.Analog[28] = MesswertRoll; |
996 | 996 | ||
Line 1011... | Line 1011... | ||
1011 | if(MesswertRoll > MAX_SENSOR) MesswertRoll = MAX_SENSOR; |
1011 | if(MesswertRoll > MAX_SENSOR) MesswertRoll = MAX_SENSOR; |
1012 | if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR; |
1012 | if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR; |
1013 | if(MesswertGier > MAX_SENSOR) MesswertGier = MAX_SENSOR; |
1013 | if(MesswertGier > MAX_SENSOR) MesswertGier = MAX_SENSOR; |
1014 | if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR; |
1014 | if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR; |
Line 1015... | Line 1015... | ||
1015 | 1015 | ||
1016 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1016 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1017 | // Höhenregelung |
1017 | // Höhenregelung |
1018 | // Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht |
1018 | // Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht |
1019 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1019 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1020 | //OCR0B = 180 - (Poti1 + 120) / 4; |
1020 | //OCR0B = 180 - (Poti1 + 120) / 4; |
1021 | //DruckOffsetSetting = OCR0B; |
1021 | //DruckOffsetSetting = OCR0B; |
1022 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung |
1022 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung |
1023 | { |
1023 | { |
1024 | int tmp_int; |
1024 | int tmp_int; |
1025 | if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER) // Regler wird über Schalter gesteuert |
1025 | if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER) // Regler wird über Schalter gesteuert |
1026 | { |
1026 | { |
1027 | if(Parameter_MaxHoehe < 50) |
1027 | if(Parameter_MaxHoehe < 50) |
1028 | { |
1028 | { |
1029 | SollHoehe = HoehenWert - 20; // Parameter_MaxHoehe ist der PPM-Wert des Schalters |
1029 | SollHoehe = HoehenWert - 20; // Parameter_MaxHoehe ist der PPM-Wert des Schalters |
1030 | HoehenReglerAktiv = 0; |
1030 | HoehenReglerAktiv = 0; |
1031 | } |
1031 | } |
1032 | else |
1032 | else |
1033 | HoehenReglerAktiv = 1; |
1033 | HoehenReglerAktiv = 1; |
1034 | } |
1034 | } |
1035 | else |
1035 | else |
1036 | { |
1036 | { |
1037 | SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20; |
1037 | SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20; |
1038 | HoehenReglerAktiv = 1; |
1038 | HoehenReglerAktiv = 1; |
Line 1046... | Line 1046... | ||
1046 | h -= (HoeheD * Parameter_Luftdruck_D)/8; // D-Anteil |
1046 | h -= (HoeheD * Parameter_Luftdruck_D)/8; // D-Anteil |
1047 | tmp_int = ((Mess_Integral_Hoch / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32; |
1047 | tmp_int = ((Mess_Integral_Hoch / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32; |
1048 | if(tmp_int > 50) tmp_int = 50; |
1048 | if(tmp_int > 50) tmp_int = 50; |
1049 | else if(tmp_int < -50) tmp_int = -50; |
1049 | else if(tmp_int < -50) tmp_int = -50; |
1050 | h -= tmp_int; |
1050 | h -= tmp_int; |
1051 | hoehenregler = (hoehenregler*15 + h) / 16; |
1051 | hoehenregler = (hoehenregler*15 + h) / 16; |
1052 | if(hoehenregler < EE_Parameter.Hoehe_MinGas) // nicht unter MIN |
1052 | if(hoehenregler < EE_Parameter.Hoehe_MinGas) // nicht unter MIN |
1053 | { |
1053 | { |
1054 | if(GasMischanteil >= EE_Parameter.Hoehe_MinGas) hoehenregler = EE_Parameter.Hoehe_MinGas; |
1054 | if(GasMischanteil >= EE_Parameter.Hoehe_MinGas) hoehenregler = EE_Parameter.Hoehe_MinGas; |
1055 | if(GasMischanteil < EE_Parameter.Hoehe_MinGas) hoehenregler = GasMischanteil; |
1055 | if(GasMischanteil < EE_Parameter.Hoehe_MinGas) hoehenregler = GasMischanteil; |
1056 | } |
1056 | } |
1057 | if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas |
1057 | if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas |
1058 | GasMischanteil = hoehenregler; |
1058 | GasMischanteil = hoehenregler; |
1059 | } |
1059 | } |
1060 | } |
1060 | } |
1061 | if(GasMischanteil > MAX_GAS - 20) GasMischanteil = MAX_GAS - 20; |
1061 | if(GasMischanteil > MAX_GAS - 20) GasMischanteil = MAX_GAS - 20; |
1062 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1062 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1063 | // + Mischer und PI-Regler |
1063 | // + Mischer und PI-Regler |
1064 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1064 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1065 | DebugOut.Analog[7] = GasMischanteil; |
1065 | DebugOut.Analog[7] = GasMischanteil; |
1066 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1066 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1067 | // Gier-Anteil |
1067 | // Gier-Anteil |
1068 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1068 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1069 | #define MUL_G 1.0 |
1069 | #define MUL_G 1.0 |
1070 | GierMischanteil = MesswertGier - sollGier; // Regler für Gier |
1070 | GierMischanteil = MesswertGier - sollGier; // Regler für Gier |
1071 | // GierMischanteil = 0; |
1071 | // GierMischanteil = 0; |
Line 1072... | Line 1072... | ||
1072 | 1072 | ||
1073 | if(GierMischanteil > (GasMischanteil / 2)) GierMischanteil = GasMischanteil / 2; |
1073 | if(GierMischanteil > (GasMischanteil / 2)) GierMischanteil = GasMischanteil / 2; |
1074 | if(GierMischanteil < -(GasMischanteil / 2)) GierMischanteil = -(GasMischanteil / 2); |
1074 | if(GierMischanteil < -(GasMischanteil / 2)) GierMischanteil = -(GasMischanteil / 2); |
1075 | if(GierMischanteil > ((MAX_GAS - GasMischanteil))) GierMischanteil = ((MAX_GAS - GasMischanteil)); |
1075 | if(GierMischanteil > ((MAX_GAS - GasMischanteil))) GierMischanteil = ((MAX_GAS - GasMischanteil)); |
Line 1076... | Line 1076... | ||
1076 | if(GierMischanteil < -((MAX_GAS - GasMischanteil))) GierMischanteil = -((MAX_GAS - GasMischanteil)); |
1076 | if(GierMischanteil < -((MAX_GAS - GasMischanteil))) GierMischanteil = -((MAX_GAS - GasMischanteil)); |
1077 | 1077 | ||
1078 | if(GasMischanteil < 20) GierMischanteil = 0; |
1078 | if(GasMischanteil < 20) GierMischanteil = 0; |
1079 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1079 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1080 | // Nick-Achse |
1080 | // Nick-Achse |
1081 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1081 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1082 | DiffNick = MesswertNick - (StickNick - GPS_Nick); // Differenz bestimmen |
1082 | DiffNick = MesswertNick - (StickNick - GPS_Nick); // Differenz bestimmen |
1083 | if(IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - (StickNick - GPS_Nick); // I-Anteil bei Winkelregelung |
1083 | if(IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - (StickNick - GPS_Nick); // I-Anteil bei Winkelregelung |
1084 | else SummeNick += DiffNick; // I-Anteil bei HH |
1084 | else SummeNick += DiffNick; // I-Anteil bei HH |
1085 | if(SummeNick > 16000) SummeNick = 16000; |
1085 | if(SummeNick > 16000) SummeNick = 16000; |
1086 | if(SummeNick < -16000) SummeNick = -16000; |
1086 | if(SummeNick < -16000) SummeNick = -16000; |
1087 | pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick |
1087 | pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick |
1088 | // Motor Vorn |
1088 | // Motor Vorn |
1089 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1089 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
Line 1090... | Line 1090... | ||
1090 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1090 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1091 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1091 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1092 | 1092 | ||
1093 | motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; // Mischer |
1093 | motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; // Mischer |
1094 | if ((motorwert < 0)) motorwert = 0; |
1094 | if ((motorwert < 0)) motorwert = 0; |
1095 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1095 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1096 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1096 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1097 | Motor_Vorne = motorwert; |
1097 | Motor_Vorne = motorwert; |
1098 | // Motor Heck |
1098 | // Motor Heck |
1099 | motorwert = GasMischanteil - pd_ergebnis + GierMischanteil; |
1099 | motorwert = GasMischanteil - pd_ergebnis + GierMischanteil; |
1100 | if ((motorwert < 0)) motorwert = 0; |
1100 | if ((motorwert < 0)) motorwert = 0; |
1101 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1101 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1102 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1102 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1103 | Motor_Hinten = motorwert; |
1103 | Motor_Hinten = motorwert; |
1104 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1104 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1105 | // Roll-Achse |
1105 | // Roll-Achse |
1106 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1106 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1107 | DiffRoll = MesswertRoll - (StickRoll - GPS_Roll); // Differenz bestimmen |
1107 | DiffRoll = MesswertRoll - (StickRoll - GPS_Roll); // Differenz bestimmen |
1108 | if(IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - (StickRoll - GPS_Roll);// I-Anteil bei Winkelregelung |
1108 | if(IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - (StickRoll - GPS_Roll);// I-Anteil bei Winkelregelung |
1109 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
1109 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
1110 | if(SummeRoll > 16000) SummeRoll = 16000; |
1110 | if(SummeRoll > 16000) SummeRoll = 16000; |
1111 | if(SummeRoll < -16000) SummeRoll = -16000; |
1111 | if(SummeRoll < -16000) SummeRoll = -16000; |
1112 | pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll |
1112 | pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll |
1113 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1113 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1114 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1114 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1115 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1115 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
Line 1116... | Line 1116... | ||
1116 | // Motor Links |
1116 | // Motor Links |
1117 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; |
1117 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; |
1118 | #define GRENZE Poti1 |
1118 | #define GRENZE Poti1 |
1119 | 1119 | ||
1120 | if ((motorwert < 0)) motorwert = 0; |
1120 | if ((motorwert < 0)) motorwert = 0; |
1121 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1121 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
Line 1122... | Line 1122... | ||
1122 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1122 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1123 | Motor_Links = motorwert; |
1123 | Motor_Links = motorwert; |
1124 | // Motor Rechts |
1124 | // Motor Rechts |
1125 | motorwert = GasMischanteil - pd_ergebnis - GierMischanteil; |
1125 | motorwert = GasMischanteil - pd_ergebnis - GierMischanteil; |
1126 | 1126 | ||
1127 | if ((motorwert < 0)) motorwert = 0; |
1127 | if ((motorwert < 0)) motorwert = 0; |