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