Rev 700 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 700 | Rev 701 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | #include "twimaster.h" |
66 | #include "twimaster.h" |
67 | #include "mm3.h" |
67 | #include "mm3.h" |
Line 68... | Line 68... | ||
68 | 68 | ||
69 | unsigned char h,m,s; |
69 | unsigned char h,m,s; |
70 | volatile unsigned int I2CTimeout = 100; |
70 | volatile unsigned int I2CTimeout = 100; |
71 | volatile int MesswertNick,MesswertRoll,MesswertGier; |
71 | volatile int ReadingPitch, ReadingRoll, ReadingYaw; |
72 | volatile int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0; |
72 | volatile int AdNeutralPitch = 0,AdNeutralRoll = 0,AdNeutralYaw = 0, StartNeutralRoll = 0, StartNeutralPitch = 0; |
73 | volatile int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0; |
73 | volatile int Mean_AccPitch, Mean_AccRoll, Mean_AccTop, NeutralAccX=0, NeutralAccY=0; |
74 | volatile float NeutralAccZ = 0; |
74 | volatile float NeutralAccZ = 0; |
75 | volatile long IntegralNick = 0,IntegralNick2 = 0; |
75 | volatile long IntegralPitch = 0,IntegralPitch2 = 0; |
76 | volatile long IntegralRoll = 0,IntegralRoll2 = 0; |
76 | volatile long IntegralRoll = 0,IntegralRoll2 = 0; |
77 | volatile long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0; |
77 | volatile long IntegralAccPitch = 0,IntegralAccRoll = 0,IntegralAccZ = 0; |
78 | volatile long Integral_Gier = 0; |
78 | volatile long Integral_Yaw = 0; |
79 | volatile long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0; |
79 | volatile long Reading_IntegralPitch = 0,Reading_IntegralPitch2 = 0; |
80 | volatile long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0; |
80 | volatile long Reading_IntegralRoll = 0,Reading_IntegralRoll2 = 0; |
81 | volatile long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0; |
81 | volatile long Reading_Integral_Yaw = 0,Reading_Integral_Yaw2 = 0; |
82 | volatile long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2; |
82 | volatile long MeanIntegralPitch, MeanIntegralRoll, MeanIntegralPitch2, MeanIntegralRoll2; |
83 | volatile long Mess_Integral_Hoch = 0; |
83 | volatile long Reading_Integral_Top = 0; |
84 | volatile int KompassValue = 0; |
84 | volatile int CompassHeading = 0; |
85 | volatile int KompassStartwert = 0; |
85 | volatile int CompassCourse = 0; |
86 | volatile int KompassRichtung = 0; |
86 | volatile int CompassOffCourse = 0; |
87 | unsigned char MAX_GAS,MIN_GAS; |
87 | unsigned char MAX_GAS,MIN_GAS; |
88 | unsigned char Notlandung = 0; |
88 | unsigned char EmergencyLanding = 0; |
89 | unsigned char HoehenReglerAktiv = 0; |
89 | unsigned char HightControlActive = 0; |
90 | long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L; |
90 | long TurnOver180Pitch = 250000L, TurnOver180Roll = 250000L; |
91 | 91 | ||
92 | float GyroFaktor; |
92 | float GyroFactor; |
93 | float IntegralFaktor; |
93 | float IntegralFactor; |
94 | volatile int DiffNick,DiffRoll; |
94 | volatile int DiffPitch,DiffRoll; |
95 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
95 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
96 | volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count; |
96 | volatile unsigned char Motor_Front, Motor_Rear, Motor_Right, Motor_Left, Count; |
97 | unsigned char MotorWert[5]; |
97 | unsigned char MotorValue[5]; |
98 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
98 | int16_t StickPitch = 0, StickRoll = 0, StickYaw = 0, StickGas = 0; |
99 | char MotorenEin = 0; |
99 | char MotorsOn = 0; |
100 | int HoehenWert = 0; |
100 | int ReadingHight = 0; |
101 | int SollHoehe = 0; |
101 | int SetPointHight = 0; |
102 | int LageKorrekturRoll = 0,LageKorrekturNick = 0; |
102 | int AttitudeCorrectionRoll = 0, AttitudeCorrectionPitch = 0; |
103 | float Ki = FAKTOR_I; |
103 | float Ki = FAKTOR_I; |
104 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
104 | unsigned char Looping_Pitch = 0, Looping_Roll = 0; |
Line 105... | Line 105... | ||
105 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
105 | unsigned char Looping_Left = 0, Looping_Right = 0, Looping_Down = 0, Looping_Top = 0; |
106 | 106 | ||
107 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
107 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
108 | unsigned char Parameter_MaxHoehe = 251; // Wert : 0-250 |
108 | unsigned char Parameter_MaxHoehe = 251; // Wert : 0-250 |
109 | unsigned char Parameter_Hoehe_P = 16; // Wert : 0-32 |
109 | unsigned char Parameter_Hoehe_P = 16; // Wert : 0-32 |
110 | unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250 |
110 | unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250 |
111 | unsigned char Parameter_KompassWirkung = 64; // Wert : 0-250 |
111 | unsigned char Parameter_CompassYawEffect = 64; // Wert : 0-250 |
112 | unsigned char Parameter_Gyro_P = 150; // Wert : 10-250 |
112 | unsigned char Parameter_Gyro_P = 150; // Wert : 10-250 |
113 | unsigned char Parameter_Gyro_I = 150; // Wert : 0-250 |
113 | unsigned char Parameter_Gyro_I = 150; // Wert : 0-250 |
114 | unsigned char Parameter_Gier_P = 2; // Wert : 1-20 |
114 | unsigned char Parameter_Gier_P = 2; // Wert : 1-20 |
Line 119... | Line 119... | ||
119 | unsigned char Parameter_UserParam4 = 0; |
119 | unsigned char Parameter_UserParam4 = 0; |
120 | unsigned char Parameter_UserParam5 = 0; |
120 | unsigned char Parameter_UserParam5 = 0; |
121 | unsigned char Parameter_UserParam6 = 0; |
121 | unsigned char Parameter_UserParam6 = 0; |
122 | unsigned char Parameter_UserParam7 = 0; |
122 | unsigned char Parameter_UserParam7 = 0; |
123 | unsigned char Parameter_UserParam8 = 0; |
123 | unsigned char Parameter_UserParam8 = 0; |
124 | unsigned char Parameter_ServoNickControl = 100; |
124 | unsigned char Parameter_ServoPitchControl = 100; |
125 | unsigned char Parameter_LoopGasLimit = 70; |
125 | unsigned char Parameter_LoopGasLimit = 70; |
126 | unsigned char Parameter_AchsKopplung1 = 0; |
126 | unsigned char Parameter_AchsKopplung1 = 0; |
127 | unsigned char Parameter_AchsGegenKopplung1 = 0; |
127 | unsigned char Parameter_AchsGegenKopplung1 = 0; |
128 | unsigned char Parameter_DynamicStability = 100; |
128 | unsigned char Parameter_DynamicStability = 100; |
Line 129... | Line 129... | ||
129 | 129 | ||
130 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
130 | signed int ExternStickPitch = 0, ExternStickRoll = 0,ExternStickYaw = 0, ExternHightValue = -20; |
Line 131... | Line 131... | ||
131 | int MaxStickNick = 0,MaxStickRoll = 0; |
131 | int MaxStickPitch = 0, MaxStickRoll = 0; |
132 | 132 | ||
133 | void Piep(unsigned char Anzahl) |
133 | void Piep(unsigned char Anzahl) |
134 | { |
134 | { |
135 | while(Anzahl--) |
135 | while(Anzahl--) |
136 | { |
136 | { |
137 | if(MotorenEin) return; //auf keinen Fall im Flug! |
137 | if(MotorsOn) return; //auf keinen Fall im Flug! |
138 | BeepTime = 100; |
138 | BeepTime = 100; |
139 | Delay_ms(250); |
139 | Delay_ms(250); |
Line 146... | Line 146... | ||
146 | //############################################################################ |
146 | //############################################################################ |
147 | { |
147 | { |
148 | NeutralAccX = 0; |
148 | NeutralAccX = 0; |
149 | NeutralAccY = 0; |
149 | NeutralAccY = 0; |
150 | NeutralAccZ = 0; |
150 | NeutralAccZ = 0; |
151 | AdNeutralNick = 0; |
151 | AdNeutralPitch = 0; |
152 | AdNeutralRoll = 0; |
152 | AdNeutralRoll = 0; |
153 | AdNeutralGier = 0; |
153 | AdNeutralYaw = 0; |
154 | Parameter_AchsKopplung1 = 0; |
154 | Parameter_AchsKopplung1 = 0; |
155 | Parameter_AchsGegenKopplung1 = 0; |
155 | Parameter_AchsGegenKopplung1 = 0; |
156 | CalibrierMittelwert(); |
156 | CalibMean(); |
157 | Delay_ms_Mess(100); |
157 | Delay_ms_Mess(100); |
158 | CalibrierMittelwert(); |
158 | CalibMean(); |
159 | if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL)) // Höhenregelung aktiviert? |
159 | if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL)) // Höhenregelung aktiviert? |
160 | { |
160 | { |
161 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
161 | if((ReadingAirPressure > 950) || (ReadingAirPressure < 750)) SearchAirPressureOffset(); |
162 | } |
162 | } |
Line 163... | Line 163... | ||
163 | 163 | ||
164 | AdNeutralNick= AdValueGyrNick; |
164 | AdNeutralPitch= AdValueGyrPitch; |
165 | AdNeutralRoll= AdValueGyrRoll; |
165 | AdNeutralRoll= AdValueGyrRoll; |
166 | AdNeutralGier= AdValueGyrGier; |
166 | AdNeutralYaw= AdValueGyrYaw; |
167 | StartNeutralRoll = AdNeutralRoll; |
167 | StartNeutralRoll = AdNeutralRoll; |
168 | StartNeutralNick = AdNeutralNick; |
168 | StartNeutralPitch = AdNeutralPitch; |
169 | if(GetParamByte(PID_ACC_NICK) > 4) |
169 | if(GetParamByte(PID_ACC_PITCH) > 4) |
170 | { |
170 | { |
171 | NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY; |
171 | NeutralAccY = abs(Mean_AccRoll) / ACC_AMPLIFY; |
172 | NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY; |
172 | NeutralAccX = abs(Mean_AccPitch) / ACC_AMPLIFY; |
173 | NeutralAccZ = Current_AccZ; |
173 | NeutralAccZ = Current_AccZ; |
174 | } |
174 | } |
175 | else |
175 | else |
176 | { |
176 | { // why not GetParamWord()? |
177 | NeutralAccX = (int)GetParamByte(PID_ACC_NICK) * 256 + (int)GetParamByte(PID_ACC_NICK+1); |
177 | NeutralAccX = (int)GetParamByte(PID_ACC_PITCH) * 256 + (int)GetParamByte(PID_ACC_PITCH+1); |
178 | NeutralAccY = (int)GetParamByte(PID_ACC_ROLL) * 256 + (int)GetParamByte(PID_ACC_ROLL+1); |
178 | NeutralAccY = (int)GetParamByte(PID_ACC_ROLL) * 256 + (int)GetParamByte(PID_ACC_ROLL+1); |
179 | NeutralAccZ = (int)GetParamByte(PID_ACC_Z) * 256 + (int)GetParamByte(PID_ACC_Z+1); |
179 | NeutralAccZ = (int)GetParamByte(PID_ACC_Z) * 256 + (int)GetParamByte(PID_ACC_Z+1); |
Line 180... | Line 180... | ||
180 | } |
180 | } |
181 | 181 | ||
182 | Mess_IntegralNick = 0; |
182 | Reading_IntegralPitch = 0; |
183 | Mess_IntegralNick2 = 0; |
183 | Reading_IntegralPitch2 = 0; |
184 | Mess_IntegralRoll = 0; |
184 | Reading_IntegralRoll = 0; |
185 | Mess_IntegralRoll2 = 0; |
185 | Reading_IntegralRoll2 = 0; |
186 | Mess_Integral_Gier = 0; |
186 | Reading_Integral_Yaw = 0; |
187 | MesswertNick = 0; |
187 | ReadingPitch = 0; |
188 | MesswertRoll = 0; |
188 | ReadingRoll = 0; |
189 | MesswertGier = 0; |
189 | ReadingYaw = 0; |
190 | StartLuftdruck = Luftdruck; |
190 | StartAirPressure = AirPressure; |
191 | HoeheD = 0; |
191 | HoeheD = 0; |
192 | Mess_Integral_Hoch = 0; |
192 | Reading_Integral_Top = 0; |
193 | KompassStartwert = KompassValue; |
193 | CompassCourse = CompassHeading; |
194 | GPS_Neutral(); |
194 | GPS_Neutral(); |
195 | BeepTime = 50; |
195 | BeepTime = 50; |
196 | Umschlag180Nick = (long) ParamSet.WinkelUmschlagNick * 2500L; |
196 | TurnOver180Pitch = (long) ParamSet.AngleTurnOverPitch * 2500L; |
197 | Umschlag180Roll = (long) ParamSet.WinkelUmschlagRoll * 2500L; |
197 | TurnOver180Roll = (long) ParamSet.AngleTurnOverRoll * 2500L; |
Line 198... | Line 198... | ||
198 | ExternHoehenValue = 0; |
198 | ExternHightValue = 0; |
199 | } |
199 | } |
200 | 200 | ||
201 | //############################################################################ |
201 | //############################################################################ |
202 | // Bearbeitet die Messwerte |
202 | // Bearbeitet die Messwerte |
203 | void Mittelwert(void) |
203 | void Mean(void) |
204 | //############################################################################ |
204 | //############################################################################ |
205 | { |
205 | { |
206 | static signed long tmpl,tmpl2; |
206 | static int32_t tmpl,tmpl2; |
Line 207... | Line 207... | ||
207 | MesswertGier = (signed int) AdNeutralGier - AdValueGyrGier; |
207 | ReadingYaw = (int16_t) AdNeutralYaw - AdValueGyrYaw; |
208 | MesswertRoll = (signed int) AdValueGyrRoll - AdNeutralRoll; |
208 | ReadingRoll = (int16_t) AdValueGyrRoll - AdNeutralRoll; |
Line 209... | Line 209... | ||
209 | MesswertNick = (signed int) AdValueGyrNick - AdNeutralNick; |
209 | ReadingPitch = (int16_t) AdValueGyrPitch - AdNeutralPitch; |
210 | 210 | ||
211 | //DebugOut.Analog[26] = MesswertNick; |
211 | //DebugOut.Analog[26] = ReadingPitch; |
212 | DebugOut.Analog[28] = MesswertRoll; |
212 | DebugOut.Analog[28] = ReadingRoll; |
213 | 213 | ||
214 | // Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++ |
214 | // Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++ |
215 | Mittelwert_AccNick = ((long)Mittelwert_AccNick * 1 + ((ACC_AMPLIFY * (long)AdValueAccNick))) / 2L; |
215 | Mean_AccPitch = ((long)Mean_AccPitch * 1 + ((ACC_AMPLIFY * (long)AdValueAccPitch))) / 2L; |
216 | Mittelwert_AccRoll = ((long)Mittelwert_AccRoll * 1 + ((ACC_AMPLIFY * (long)AdValueAccRoll))) / 2L; |
216 | Mean_AccRoll = ((long)Mean_AccRoll * 1 + ((ACC_AMPLIFY * (long)AdValueAccRoll))) / 2L; |
217 | Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdValueAccTop)) / 2L; |
217 | Mean_AccTop = ((long)Mean_AccTop * 1 + ((long)AdValueAccTop)) / 2L; |
218 | IntegralAccNick += ACC_AMPLIFY * AdValueAccNick; |
218 | IntegralAccPitch += ACC_AMPLIFY * AdValueAccPitch; |
219 | IntegralAccRoll += ACC_AMPLIFY * AdValueAccRoll; |
219 | IntegralAccRoll += ACC_AMPLIFY * AdValueAccRoll; |
220 | IntegralAccZ += Current_AccZ - NeutralAccZ; |
220 | IntegralAccZ += Current_AccZ - NeutralAccZ; |
221 | // Gier ++++++++++++++++++++++++++++++++++++++++++++++++ |
221 | // Yaw ++++++++++++++++++++++++++++++++++++++++++++++++ |
222 | Mess_Integral_Gier += MesswertGier; |
222 | Reading_Integral_Yaw += ReadingYaw; |
223 | Mess_Integral_Gier2 += MesswertGier; |
223 | Reading_Integral_Yaw2 += ReadingYaw; |
224 | // Kopplungsanteil +++++++++++++++++++++++++++++++++++++ |
224 | // Kopplungsanteil +++++++++++++++++++++++++++++++++++++ |
225 | if(!Looping_Nick && !Looping_Roll && (ParamSet.GlobalConfig & CFG_AXIS_COUPLING_ACTIVE)) |
225 | if(!Looping_Pitch && !Looping_Roll && (ParamSet.GlobalConfig & CFG_AXIS_COUPLING_ACTIVE)) |
226 | { |
226 | { |
227 | tmpl = Mess_IntegralNick / 4096L; |
227 | tmpl = Reading_IntegralPitch / 4096L; |
228 | tmpl *= MesswertGier; |
228 | tmpl *= ReadingYaw; |
229 | tmpl *= Parameter_AchsKopplung1; //125 |
229 | tmpl *= Parameter_AchsKopplung1; //125 |
230 | tmpl /= 2048L; |
230 | tmpl /= 2048L; |
231 | tmpl2 = Mess_IntegralRoll / 4096L; |
231 | tmpl2 = Reading_IntegralRoll / 4096L; |
232 | tmpl2 *= MesswertGier; |
232 | tmpl2 *= ReadingYaw; |
233 | tmpl2 *= Parameter_AchsKopplung1; |
233 | tmpl2 *= Parameter_AchsKopplung1; |
234 | tmpl2 /= 2048L; |
234 | tmpl2 /= 2048L; |
235 | } |
235 | } |
236 | else tmpl = tmpl2 = 0; |
236 | else tmpl = tmpl2 = 0; |
237 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
237 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
238 | MesswertRoll += tmpl; |
238 | ReadingRoll += tmpl; |
239 | MesswertRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109 |
239 | ReadingRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109 |
240 | Mess_IntegralRoll2 += MesswertRoll; |
240 | Reading_IntegralRoll2 += ReadingRoll; |
241 | Mess_IntegralRoll += MesswertRoll - LageKorrekturRoll; |
241 | Reading_IntegralRoll += ReadingRoll - AttitudeCorrectionRoll; |
242 | if(Mess_IntegralRoll > Umschlag180Roll) |
242 | if(Reading_IntegralRoll > TurnOver180Roll) |
243 | { |
243 | { |
244 | Mess_IntegralRoll = -(Umschlag180Roll - 10000L); |
244 | Reading_IntegralRoll = -(TurnOver180Roll - 10000L); |
245 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
245 | Reading_IntegralRoll2 = Reading_IntegralRoll; |
246 | } |
246 | } |
247 | if(Mess_IntegralRoll <-Umschlag180Roll) |
247 | if(Reading_IntegralRoll <-TurnOver180Roll) |
248 | { |
248 | { |
249 | Mess_IntegralRoll = (Umschlag180Roll - 10000L); |
249 | Reading_IntegralRoll = (TurnOver180Roll - 10000L); |
250 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
250 | Reading_IntegralRoll2 = Reading_IntegralRoll; |
251 | } |
251 | } |
252 | if(AdValueGyrRoll < 15) MesswertRoll = -1000; |
252 | if(AdValueGyrRoll < 15) ReadingRoll = -1000; |
253 | if(AdValueGyrRoll < 7) MesswertRoll = -2000; |
253 | if(AdValueGyrRoll < 7) ReadingRoll = -2000; |
254 | if(BoardRelease == 10) |
254 | if(BoardRelease == 10) |
255 | { |
255 | { |
256 | if(AdValueGyrRoll > 1010) MesswertRoll = +1000; |
256 | if(AdValueGyrRoll > 1010) ReadingRoll = +1000; |
257 | if(AdValueGyrRoll > 1017) MesswertRoll = +2000; |
257 | if(AdValueGyrRoll > 1017) ReadingRoll = +2000; |
258 | } |
258 | } |
259 | else |
259 | else |
260 | { |
260 | { |
261 | if(AdValueGyrRoll > 2020) MesswertRoll = +1000; |
261 | if(AdValueGyrRoll > 2020) ReadingRoll = +1000; |
262 | if(AdValueGyrRoll > 2034) MesswertRoll = +2000; |
262 | if(AdValueGyrRoll > 2034) ReadingRoll = +2000; |
263 | } |
263 | } |
264 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
264 | // Pitch ++++++++++++++++++++++++++++++++++++++++++++++++ |
265 | MesswertNick -= tmpl2; |
265 | ReadingPitch -= tmpl2; |
266 | MesswertNick -= (tmpl*Parameter_AchsGegenKopplung1)/512L; |
266 | ReadingPitch -= (tmpl*Parameter_AchsGegenKopplung1)/512L; |
267 | Mess_IntegralNick2 += MesswertNick; |
267 | Reading_IntegralPitch2 += ReadingPitch; |
268 | Mess_IntegralNick += MesswertNick - LageKorrekturNick; |
268 | Reading_IntegralPitch += ReadingPitch - AttitudeCorrectionPitch; |
269 | if(Mess_IntegralNick > Umschlag180Nick) |
269 | if(Reading_IntegralPitch > TurnOver180Pitch) |
270 | { |
270 | { |
271 | Mess_IntegralNick = -(Umschlag180Nick - 10000L); |
271 | Reading_IntegralPitch = -(TurnOver180Pitch - 10000L); |
272 | Mess_IntegralNick2 = Mess_IntegralNick; |
272 | Reading_IntegralPitch2 = Reading_IntegralPitch; |
273 | } |
273 | } |
274 | if(Mess_IntegralNick <-Umschlag180Nick) |
274 | if(Reading_IntegralPitch <-TurnOver180Pitch) |
275 | { |
275 | { |
276 | Mess_IntegralNick = (Umschlag180Nick - 10000L); |
276 | Reading_IntegralPitch = (TurnOver180Pitch - 10000L); |
277 | Mess_IntegralNick2 = Mess_IntegralNick; |
277 | Reading_IntegralPitch2 = Reading_IntegralPitch; |
278 | } |
278 | } |
279 | if(AdValueGyrNick < 15) MesswertNick = -1000; |
279 | if(AdValueGyrPitch < 15) ReadingPitch = -1000; |
280 | if(AdValueGyrNick < 7) MesswertNick = -2000; |
280 | if(AdValueGyrPitch < 7) ReadingPitch = -2000; |
281 | if(BoardRelease == 10) |
281 | if(BoardRelease == 10) |
282 | { |
282 | { |
283 | if(AdValueGyrNick > 1010) MesswertNick = +1000; |
283 | if(AdValueGyrPitch > 1010) ReadingPitch = +1000; |
284 | if(AdValueGyrNick > 1017) MesswertNick = +2000; |
284 | if(AdValueGyrPitch > 1017) ReadingPitch = +2000; |
285 | } |
285 | } |
286 | else |
286 | else |
287 | { |
287 | { |
288 | if(AdValueGyrNick > 2020) MesswertNick = +1000; |
288 | if(AdValueGyrPitch > 2020) ReadingPitch = +1000; |
289 | if(AdValueGyrNick > 2034) MesswertNick = +2000; |
289 | if(AdValueGyrPitch > 2034) ReadingPitch = +2000; |
Line 290... | Line 290... | ||
290 | } |
290 | } |
291 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
291 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
292 | // ADC einschalten |
292 | // ADC einschalten |
293 | ADC_Enable(); |
293 | ADC_Enable(); |
294 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
294 | //++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 295... | Line 295... | ||
295 | 295 | ||
296 | Integral_Gier = Mess_Integral_Gier; |
296 | Integral_Yaw = Reading_Integral_Yaw; |
297 | IntegralNick = Mess_IntegralNick; |
297 | IntegralPitch = Reading_IntegralPitch; |
298 | IntegralRoll = Mess_IntegralRoll; |
298 | IntegralRoll = Reading_IntegralRoll; |
299 | IntegralNick2 = Mess_IntegralNick2; |
299 | IntegralPitch2 = Reading_IntegralPitch2; |
300 | IntegralRoll2 = Mess_IntegralRoll2; |
300 | IntegralRoll2 = Reading_IntegralRoll2; |
301 | 301 | ||
302 | if(ParamSet.GlobalConfig & CFG_ROTARY_RATE_LIMITER && !Looping_Nick && !Looping_Roll) |
302 | if(ParamSet.GlobalConfig & CFG_ROTARY_RATE_LIMITER && !Looping_Pitch && !Looping_Roll) |
303 | { |
303 | { |
304 | if(MesswertNick > 200) MesswertNick += 4 * (MesswertNick - 200); |
304 | if(ReadingPitch > 200) ReadingPitch += 4 * (ReadingPitch - 200); |
305 | else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200); |
305 | else if(ReadingPitch < -200) ReadingPitch += 4 * (ReadingPitch + 200); |
Line 316... | Line 316... | ||
316 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
316 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
317 | } |
317 | } |
Line 318... | Line 318... | ||
318 | 318 | ||
319 | //############################################################################ |
319 | //############################################################################ |
320 | // Messwerte beim Ermitteln der Nullage |
320 | // Messwerte beim Ermitteln der Nullage |
321 | void CalibrierMittelwert(void) |
321 | void CalibMean(void) |
322 | //############################################################################ |
322 | //############################################################################ |
323 | { |
323 | { |
324 | // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern |
324 | // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern |
325 | ADC_Disable(); |
325 | ADC_Disable(); |
326 | MesswertNick = AdValueGyrNick; |
326 | ReadingPitch = AdValueGyrPitch; |
327 | MesswertRoll = AdValueGyrRoll; |
327 | ReadingRoll = AdValueGyrRoll; |
328 | MesswertGier = AdValueGyrGier; |
328 | ReadingYaw = AdValueGyrYaw; |
329 | Mittelwert_AccNick = ACC_AMPLIFY * (long)AdValueAccNick; |
329 | Mean_AccPitch = ACC_AMPLIFY * (long)AdValueAccPitch; |
330 | Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdValueAccRoll; |
330 | Mean_AccRoll = ACC_AMPLIFY * (long)AdValueAccRoll; |
331 | Mittelwert_AccHoch = (long)AdValueAccTop; |
331 | Mean_AccTop = (long)AdValueAccTop; |
332 | // ADC einschalten |
332 | // ADC einschalten |
333 | ADC_Enable(); |
333 | ADC_Enable(); |
334 | if(Poti1 < PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110 && Poti1) Poti1--; |
334 | if(Poti1 < PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110 && Poti1) Poti1--; |
335 | if(Poti2 < PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110 && Poti2) Poti2--; |
335 | if(Poti2 < PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110 && Poti2) Poti2--; |
Line 338... | Line 338... | ||
338 | if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255; |
338 | if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255; |
339 | if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255; |
339 | if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255; |
340 | if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255; |
340 | if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255; |
341 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
341 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
Line 342... | Line 342... | ||
342 | 342 | ||
343 | Umschlag180Nick = (long) ParamSet.WinkelUmschlagNick * 2500L; |
343 | TurnOver180Pitch = (long) ParamSet.AngleTurnOverPitch * 2500L; |
344 | Umschlag180Roll = (long) ParamSet.WinkelUmschlagNick * 2500L; |
344 | TurnOver180Roll = (long) ParamSet.AngleTurnOverRoll * 2500L; |
Line 345... | Line 345... | ||
345 | } |
345 | } |
346 | 346 | ||
347 | //############################################################################ |
347 | //############################################################################ |
348 | // Senden der Motorwerte per I2C-Bus |
348 | // Senden der Motorwerte per I2C-Bus |
349 | void SendMotorData(void) |
349 | void SendMotorData(void) |
350 | //############################################################################ |
350 | //############################################################################ |
351 | { |
351 | { |
352 | if(MOTOR_OFF || !MotorenEin) |
352 | if(MOTOR_OFF || !MotorsOn) |
353 | { |
353 | { |
354 | Motor_Hinten = 0; |
354 | Motor_Rear = 0; |
355 | Motor_Vorne = 0; |
355 | Motor_Front = 0; |
356 | Motor_Rechts = 0; |
356 | Motor_Right = 0; |
357 | Motor_Links = 0; |
357 | Motor_Left = 0; |
358 | if(MotorTest[0]) Motor_Vorne = MotorTest[0]; |
358 | if(MotorTest[0]) Motor_Front = MotorTest[0]; |
359 | if(MotorTest[1]) Motor_Hinten = MotorTest[1]; |
359 | if(MotorTest[1]) Motor_Rear = MotorTest[1]; |
360 | if(MotorTest[2]) Motor_Links = MotorTest[2]; |
360 | if(MotorTest[2]) Motor_Left = MotorTest[2]; |
Line 361... | Line 361... | ||
361 | if(MotorTest[3]) Motor_Rechts = MotorTest[3]; |
361 | if(MotorTest[3]) Motor_Right = MotorTest[3]; |
362 | } |
362 | } |
363 | 363 | ||
364 | DebugOut.Analog[12] = Motor_Vorne; |
364 | DebugOut.Analog[12] = Motor_Front; |
Line 365... | Line 365... | ||
365 | DebugOut.Analog[13] = Motor_Hinten; |
365 | DebugOut.Analog[13] = Motor_Rear; |
366 | DebugOut.Analog[14] = Motor_Links; |
366 | DebugOut.Analog[14] = Motor_Left; |
367 | DebugOut.Analog[15] = Motor_Rechts; |
367 | DebugOut.Analog[15] = Motor_Right; |
368 | 368 | ||
Line 379... | Line 379... | ||
379 | void ParameterZuordnung(void) |
379 | void ParameterZuordnung(void) |
380 | //############################################################################ |
380 | //############################################################################ |
381 | { |
381 | { |
Line 382... | Line 382... | ||
382 | 382 | ||
383 | #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;} |
383 | #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;} |
384 | CHK_POTI(Parameter_MaxHoehe,ParamSet.MaxHoehe,0,255); |
384 | CHK_POTI(Parameter_MaxHoehe,ParamSet.MaxHight,0,255); |
385 | CHK_POTI(Parameter_Luftdruck_D,ParamSet.Luftdruck_D,0,100); |
385 | CHK_POTI(Parameter_Luftdruck_D,ParamSet.AirPressure_D,0,100); |
386 | CHK_POTI(Parameter_Hoehe_P,ParamSet.Hoehe_P,0,100); |
386 | CHK_POTI(Parameter_Hoehe_P,ParamSet.Hight_P,0,100); |
387 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,ParamSet.Hoehe_ACC_Wirkung,0,255); |
387 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,ParamSet.Hight_ACC_Effect,0,255); |
388 | CHK_POTI(Parameter_KompassWirkung,ParamSet.KompassWirkung,0,255); |
388 | CHK_POTI(Parameter_CompassYawEffect,ParamSet.CompassYawEffect,0,255); |
389 | CHK_POTI(Parameter_Gyro_P,ParamSet.Gyro_P,10,255); |
389 | CHK_POTI(Parameter_Gyro_P,ParamSet.Gyro_P,10,255); |
390 | CHK_POTI(Parameter_Gyro_I,ParamSet.Gyro_I,0,255); |
390 | CHK_POTI(Parameter_Gyro_I,ParamSet.Gyro_I,0,255); |
391 | CHK_POTI(Parameter_I_Factor,ParamSet.I_Factor,0,255); |
391 | CHK_POTI(Parameter_I_Factor,ParamSet.I_Factor,0,255); |
392 | CHK_POTI(Parameter_UserParam1,ParamSet.UserParam1,0,255); |
392 | CHK_POTI(Parameter_UserParam1,ParamSet.UserParam1,0,255); |
Line 395... | Line 395... | ||
395 | CHK_POTI(Parameter_UserParam4,ParamSet.UserParam4,0,255); |
395 | CHK_POTI(Parameter_UserParam4,ParamSet.UserParam4,0,255); |
396 | CHK_POTI(Parameter_UserParam5,ParamSet.UserParam5,0,255); |
396 | CHK_POTI(Parameter_UserParam5,ParamSet.UserParam5,0,255); |
397 | CHK_POTI(Parameter_UserParam6,ParamSet.UserParam6,0,255); |
397 | CHK_POTI(Parameter_UserParam6,ParamSet.UserParam6,0,255); |
398 | CHK_POTI(Parameter_UserParam7,ParamSet.UserParam7,0,255); |
398 | CHK_POTI(Parameter_UserParam7,ParamSet.UserParam7,0,255); |
399 | CHK_POTI(Parameter_UserParam8,ParamSet.UserParam8,0,255); |
399 | CHK_POTI(Parameter_UserParam8,ParamSet.UserParam8,0,255); |
400 | CHK_POTI(Parameter_ServoNickControl,ParamSet.ServoNickControl,0,255); |
400 | CHK_POTI(Parameter_ServoPitchControl,ParamSet.ServoPitchControl,0,255); |
401 | CHK_POTI(Parameter_LoopGasLimit,ParamSet.LoopGasLimit,0,255); |
401 | CHK_POTI(Parameter_LoopGasLimit,ParamSet.LoopGasLimit,0,255); |
402 | CHK_POTI(Parameter_AchsKopplung1, ParamSet.AchsKopplung1,0,255); |
402 | CHK_POTI(Parameter_AchsKopplung1, ParamSet.AchsKopplung1,0,255); |
403 | CHK_POTI(Parameter_AchsGegenKopplung1,ParamSet.AchsGegenKopplung1,0,255); |
403 | CHK_POTI(Parameter_AchsGegenKopplung1,ParamSet.AchsGegenKopplung1,0,255); |
404 | CHK_POTI(Parameter_DynamicStability,ParamSet.DynamicStability,0,255); |
404 | CHK_POTI(Parameter_DynamicStability,ParamSet.DynamicStability,0,255); |
Line 412... | Line 412... | ||
412 | //############################################################################ |
412 | //############################################################################ |
413 | // |
413 | // |
414 | void MotorRegler(void) |
414 | void MotorRegler(void) |
415 | //############################################################################ |
415 | //############################################################################ |
416 | { |
416 | { |
417 | int motorwert,pd_ergebnis,h,tmp_int; |
417 | int MotorValue, pd_ergebnis, h, tmp_int; |
418 | int GierMischanteil,GasMischanteil; |
418 | int YawMixingFraction, GasMixingFraction; |
419 | static long SummeNick=0,SummeRoll=0; |
419 | static long SumPitch = 0, SumRoll = 0; |
420 | static long sollGier = 0,tmp_long,tmp_long2; |
420 | static long SetPointYaw = 0, tmp_long, tmp_long2; |
421 | static long IntegralFehlerNick = 0; |
421 | static long IntegralErrorPitch = 0; |
422 | static long IntegralFehlerRoll = 0; |
422 | static long IntegralErrorRoll = 0; |
423 | static unsigned int RcLostTimer; |
423 | static unsigned int RcLostTimer; |
424 | static unsigned char delay_neutral = 0; |
424 | static unsigned char delay_neutral = 0; |
425 | static unsigned char delay_einschalten = 0,delay_ausschalten = 0; |
425 | static unsigned char delay_einschalten = 0,delay_ausschalten = 0; |
426 | static unsigned int modell_fliegt = 0; |
426 | static unsigned int modell_fliegt = 0; |
427 | static int hoehenregler = 0; |
427 | static int hoehenregler = 0; |
428 | static char TimerWerteausgabe = 0; |
428 | static char TimerDebugOut = 0; |
429 | static char NeueKompassRichtungMerken = 0; |
429 | static char StoreNewCompassCourse = 0; |
430 | static long ausgleichNick, ausgleichRoll; |
430 | static long CorrectionPitch, CorrectionRoll; |
Line 431... | Line 431... | ||
431 | 431 | ||
Line 432... | Line 432... | ||
432 | Mittelwert(); |
432 | Mean(); |
433 | 433 | ||
434 | GRN_ON; |
434 | GRN_ON; |
435 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
435 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
436 | // Gaswert ermitteln |
436 | // Gaswert ermitteln |
437 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
437 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
438 | GasMischanteil = StickGas; |
438 | GasMixingFraction = StickGas; |
439 | if(GasMischanteil < 0) GasMischanteil = 0; |
439 | if(GasMixingFraction < 0) GasMixingFraction = 0; |
440 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
440 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
441 | // Emfang schlecht |
441 | // Emfang schlecht |
442 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
442 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 451... | Line 451... | ||
451 | } |
451 | } |
452 | } |
452 | } |
453 | if(RcLostTimer) RcLostTimer--; |
453 | if(RcLostTimer) RcLostTimer--; |
454 | else |
454 | else |
455 | { |
455 | { |
456 | MotorenEin = 0; |
456 | MotorsOn = 0; |
457 | Notlandung = 0; |
457 | EmergencyLanding = 0; |
458 | } |
458 | } |
459 | ROT_ON; |
459 | ROT_ON; |
460 | if(modell_fliegt > 2000) // wahrscheinlich in der Luft --> langsam absenken |
460 | if(modell_fliegt > 2000) // wahrscheinlich in der Luft --> langsam absenken |
461 | { |
461 | { |
462 | GasMischanteil = ParamSet.EmergencyGas; |
462 | GasMixingFraction = ParamSet.EmergencyGas; |
463 | Notlandung = 1; |
463 | EmergencyLanding = 1; |
464 | PPM_in[ParamSet.ChannelAssignment[CH_NICK]] = 0; |
464 | PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] = 0; |
465 | PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] = 0; |
465 | PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] = 0; |
466 | PPM_in[ParamSet.ChannelAssignment[CH_GIER]] = 0; |
466 | PPM_in[ParamSet.ChannelAssignment[CH_YAW]] = 0; |
467 | } |
467 | } |
468 | else MotorenEin = 0; |
468 | else MotorsOn = 0; |
469 | } |
469 | } |
470 | else |
470 | else |
471 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
471 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
472 | // Emfang gut |
472 | // Emfang gut |
473 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
473 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
474 | if(SenderOkay > 140) |
474 | if(SenderOkay > 140) |
475 | { |
475 | { |
476 | Notlandung = 0; |
476 | EmergencyLanding = 0; |
477 | RcLostTimer = ParamSet.EmergencyGasDuration * 50; |
477 | RcLostTimer = ParamSet.EmergencyGasDuration * 50; |
478 | if(GasMischanteil > 40) |
478 | if(GasMixingFraction > 40) |
479 | { |
479 | { |
480 | if(modell_fliegt < 0xffff) modell_fliegt++; |
480 | if(modell_fliegt < 0xffff) modell_fliegt++; |
481 | } |
481 | } |
482 | if((modell_fliegt < 200) || (GasMischanteil < 40)) |
482 | if((modell_fliegt < 200) || (GasMixingFraction < 40)) |
483 | { |
483 | { |
484 | SummeNick = 0; |
484 | SumPitch = 0; |
485 | SummeRoll = 0; |
485 | SumRoll = 0; |
486 | Mess_Integral_Gier = 0; |
486 | Reading_Integral_Yaw = 0; |
487 | Mess_Integral_Gier2 = 0; |
487 | Reading_Integral_Yaw2 = 0; |
488 | } |
488 | } |
489 | if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && MotorenEin == 0) |
489 | if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && MotorsOn == 0) |
490 | { |
490 | { |
491 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
491 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
492 | // auf Nullwerte kalibrieren |
492 | // auf Nullwerte kalibrieren |
493 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
493 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
494 | if(PPM_in[ParamSet.ChannelAssignment[CH_GIER]] > 75) // Neutralwerte |
494 | if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] > 75) // Neutralwerte |
495 | { |
495 | { |
496 | if(++delay_neutral > 200) // nicht sofort |
496 | if(++delay_neutral > 200) // nicht sofort |
497 | { |
497 | { |
498 | GRN_OFF; |
498 | GRN_OFF; |
499 | MotorenEin = 0; |
499 | MotorsOn = 0; |
500 | delay_neutral = 0; |
500 | delay_neutral = 0; |
501 | modell_fliegt = 0; |
501 | modell_fliegt = 0; |
502 | if(PPM_in[ParamSet.ChannelAssignment[CH_NICK]] > 70 || abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]) > 70) |
502 | if(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] > 70 || abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]) > 70) |
503 | { |
503 | { |
504 | unsigned char setting=1; |
504 | unsigned char setting=1; |
505 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > 70 && PPM_in[ParamSet.ChannelAssignment[CH_NICK]] < 70) setting = 1; |
505 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > 70 && PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] < 70) setting = 1; |
506 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > 70 && PPM_in[ParamSet.ChannelAssignment[CH_NICK]] > 70) setting = 2; |
506 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > 70 && PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] > 70) setting = 2; |
507 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] < 70 && PPM_in[ParamSet.ChannelAssignment[CH_NICK]] > 70) setting = 3; |
507 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] < 70 && PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] > 70) setting = 3; |
508 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] <-70 && PPM_in[ParamSet.ChannelAssignment[CH_NICK]] > 70) setting = 4; |
508 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] <-70 && PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] > 70) setting = 4; |
509 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] <-70 && PPM_in[ParamSet.ChannelAssignment[CH_NICK]] < 70) setting = 5; |
509 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] <-70 && PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] < 70) setting = 5; |
510 | SetActiveParamSet(setting); // aktiven Datensatz merken |
510 | SetActiveParamSet(setting); // aktiven Datensatz merken |
511 | } |
511 | } |
512 | if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL)) // Höhenregelung aktiviert? |
512 | if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL)) // Höhenregelung aktiviert? |
513 | { |
513 | { |
514 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
514 | if((ReadingAirPressure > 950) || (ReadingAirPressure < 750)) SearchAirPressureOffset(); |
515 | } |
515 | } |
516 | ParamSet_ReadFromEEProm(GetActiveParamSet()); |
516 | ParamSet_ReadFromEEProm(GetActiveParamSet()); |
517 | SetNeutral(); |
517 | SetNeutral(); |
518 | Piep(GetActiveParamSet()); |
518 | Piep(GetActiveParamSet()); |
519 | } |
519 | } |
520 | } |
520 | } |
521 | else |
521 | else |
522 | if(PPM_in[ParamSet.ChannelAssignment[CH_GIER]] < -75) // ACC Neutralwerte speichern |
522 | if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] < -75) // ACC Neutralwerte speichern |
523 | { |
523 | { |
524 | if(++delay_neutral > 200) // nicht sofort |
524 | if(++delay_neutral > 200) // nicht sofort |
525 | { |
525 | { |
526 | GRN_OFF; |
526 | GRN_OFF; |
527 | SetParamByte(PID_ACC_NICK,0xFF); // Werte löschen |
527 | SetParamByte(PID_ACC_PITCH,0xFF); // Werte löschen |
528 | MotorenEin = 0; |
528 | MotorsOn = 0; |
529 | delay_neutral = 0; |
529 | delay_neutral = 0; |
530 | modell_fliegt = 0; |
530 | modell_fliegt = 0; |
531 | SetNeutral(); |
531 | SetNeutral(); |
532 | SetParamByte(PID_ACC_NICK, NeutralAccX / 256); // ACC-NeutralWerte speichern |
532 | SetParamByte(PID_ACC_PITCH, NeutralAccX / 256); // ACC-NeutralWerte speichern |
533 | SetParamByte(PID_ACC_NICK+1,NeutralAccX % 256); // ACC-NeutralWerte speichern |
533 | SetParamByte(PID_ACC_PITCH+1,NeutralAccX % 256); // ACC-NeutralWerte speichern |
534 | SetParamByte(PID_ACC_ROLL,NeutralAccY / 256); |
534 | SetParamByte(PID_ACC_ROLL,NeutralAccY / 256); |
535 | SetParamByte(PID_ACC_ROLL+1,NeutralAccY % 256); |
535 | SetParamByte(PID_ACC_ROLL+1,NeutralAccY % 256); |
536 | SetParamByte(PID_ACC_Z,(int)NeutralAccZ / 256); |
536 | SetParamByte(PID_ACC_Z,(int)NeutralAccZ / 256); |
537 | SetParamByte(PID_ACC_Z+1,(int)NeutralAccZ % 256); |
537 | SetParamByte(PID_ACC_Z+1,(int)NeutralAccZ % 256); |
538 | Piep(GetActiveParamSet()); |
538 | Piep(GetActiveParamSet()); |
Line 544... | Line 544... | ||
544 | // Gas ist unten |
544 | // Gas ist unten |
545 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
545 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
546 | if(PPM_in[ParamSet.ChannelAssignment[CH_GAS]] < 35-120) |
546 | if(PPM_in[ParamSet.ChannelAssignment[CH_GAS]] < 35-120) |
547 | { |
547 | { |
548 | // Starten |
548 | // Starten |
549 | if(PPM_in[ParamSet.ChannelAssignment[CH_GIER]] < -75) |
549 | if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] < -75) |
550 | { |
550 | { |
551 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
551 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
552 | // Einschalten |
552 | // Einschalten |
553 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
553 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
554 | if(++delay_einschalten > 200) |
554 | if(++delay_einschalten > 200) |
555 | { |
555 | { |
556 | delay_einschalten = 200; |
556 | delay_einschalten = 200; |
557 | modell_fliegt = 1; |
557 | modell_fliegt = 1; |
558 | MotorenEin = 1; |
558 | MotorsOn = 1; |
559 | sollGier = 0; |
559 | SetPointYaw = 0; |
560 | Mess_Integral_Gier = 0; |
560 | Reading_Integral_Yaw = 0; |
561 | Mess_Integral_Gier2 = 0; |
561 | Reading_Integral_Yaw2 = 0; |
562 | Mess_IntegralNick = 0; |
562 | Reading_IntegralPitch = 0; |
563 | Mess_IntegralRoll = 0; |
563 | Reading_IntegralRoll = 0; |
564 | Mess_IntegralNick2 = IntegralNick; |
564 | Reading_IntegralPitch2 = IntegralPitch; |
565 | Mess_IntegralRoll2 = IntegralRoll; |
565 | Reading_IntegralRoll2 = IntegralRoll; |
566 | SummeNick = 0; |
566 | SumPitch = 0; |
567 | SummeRoll = 0; |
567 | SumRoll = 0; |
568 | } |
568 | } |
569 | } |
569 | } |
570 | else delay_einschalten = 0; |
570 | else delay_einschalten = 0; |
571 | //Auf Neutralwerte setzen |
571 | //Auf Neutralwerte setzen |
572 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
572 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
573 | // Auschalten |
573 | // Auschalten |
574 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
574 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
575 | if(PPM_in[ParamSet.ChannelAssignment[CH_GIER]] > 75) |
575 | if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] > 75) |
576 | { |
576 | { |
577 | if(++delay_ausschalten > 200) // nicht sofort |
577 | if(++delay_ausschalten > 200) // nicht sofort |
578 | { |
578 | { |
579 | MotorenEin = 0; |
579 | MotorsOn = 0; |
580 | delay_ausschalten = 200; |
580 | delay_ausschalten = 200; |
581 | modell_fliegt = 0; |
581 | modell_fliegt = 0; |
582 | } |
582 | } |
583 | } |
583 | } |
584 | else delay_ausschalten = 0; |
584 | else delay_ausschalten = 0; |
Line 586... | Line 586... | ||
586 | } |
586 | } |
Line 587... | Line 587... | ||
587 | 587 | ||
588 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
588 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
589 | // neue Werte von der Funke |
589 | // neue Werte von der Funke |
590 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
590 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
591 | if(!NewPpmData-- || Notlandung) |
591 | if(!NewPpmData-- || EmergencyLanding) |
592 | { |
592 | { |
593 | int tmp_int; |
- | |
594 | static int stick_nick,stick_roll; |
593 | int tmp_int; |
595 | ParameterZuordnung(); |
594 | ParameterZuordnung(); |
596 | StickNick = (StickNick * 3 + PPM_in[ParamSet.ChannelAssignment[CH_NICK]] * ParamSet.Stick_P) / 4; |
595 | StickPitch = (StickPitch * 3 + PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] * ParamSet.Stick_P) / 4; |
597 | StickNick += PPM_diff[ParamSet.ChannelAssignment[CH_NICK]] * ParamSet.Stick_D; |
596 | StickPitch += PPM_diff[ParamSet.ChannelAssignment[CH_PITCH]] * ParamSet.Stick_D; |
598 | StickRoll = (StickRoll * 3 + PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_P) / 4; |
597 | StickRoll = (StickRoll * 3 + PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_P) / 4; |
Line 599... | Line 598... | ||
599 | StickRoll += PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_D; |
598 | StickRoll += PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_D; |
600 | 599 | ||
Line 601... | Line 600... | ||
601 | StickGier = -PPM_in[ParamSet.ChannelAssignment[CH_GIER]]; |
600 | StickYaw = -PPM_in[ParamSet.ChannelAssignment[CH_YAW]]; |
602 | StickGas = PPM_in[ParamSet.ChannelAssignment[CH_GAS]] + 120; |
601 | StickGas = PPM_in[ParamSet.ChannelAssignment[CH_GAS]] + 120; |
603 | 602 | ||
604 | if(abs(PPM_in[ParamSet.ChannelAssignment[CH_NICK]]) > MaxStickNick) |
603 | if(abs(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]]) > MaxStickPitch) |
605 | MaxStickNick = abs(PPM_in[ParamSet.ChannelAssignment[CH_NICK]]); else MaxStickNick--; |
604 | MaxStickPitch = abs(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]]); else MaxStickPitch--; |
Line 606... | Line 605... | ||
606 | if(abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]) > MaxStickRoll) |
605 | if(abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]) > MaxStickRoll) |
607 | MaxStickRoll = abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]); else MaxStickRoll--; |
606 | MaxStickRoll = abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]); else MaxStickRoll--; |
Line 608... | Line 607... | ||
608 | if(Notlandung) {MaxStickNick = 0; MaxStickRoll = 0;} |
607 | if(EmergencyLanding) {MaxStickPitch = 0; MaxStickRoll = 0;} |
609 | 608 | ||
610 | GyroFaktor = ((float)Parameter_Gyro_P + 10.0) / 256.0; |
609 | GyroFactor = ((float)Parameter_Gyro_P + 10.0) / 256.0; |
611 | IntegralFaktor = ((float) Parameter_Gyro_I) / 44000; |
610 | IntegralFactor = ((float) Parameter_Gyro_I) / 44000; |
612 | 611 | ||
613 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
612 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
614 | //+ Digitale Steuerung per DubWise |
613 | //+ Digitale Steuerung per DubWise |
615 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
614 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
616 | #define KEY_VALUE (Parameter_UserParam1 * 4) //(Poti3 * 8) |
615 | #define KEY_VALUE (Parameter_UserParam1 * 4) //(Poti3 * 8) |
617 | if(DubWiseKeys[1]) BeepTime = 10; |
616 | if(DubWiseKeys[1]) BeepTime = 10; |
618 | if(DubWiseKeys[1] & DUB_KEY_UP) tmp_int = KEY_VALUE; else |
617 | if(DubWiseKeys[1] & DUB_KEY_UP) tmp_int = KEY_VALUE; else |
Line 619... | Line 618... | ||
619 | if(DubWiseKeys[1] & DUB_KEY_DOWN) tmp_int = -KEY_VALUE; else tmp_int = 0; |
618 | if(DubWiseKeys[1] & DUB_KEY_DOWN) tmp_int = -KEY_VALUE; else tmp_int = 0; |
620 | ExternStickNick = (ExternStickNick * 7 + tmp_int) / 8; |
619 | ExternStickPitch= (ExternStickPitch* 7 + tmp_int) / 8; |
621 | if(DubWiseKeys[1] & DUB_KEY_LEFT) tmp_int = KEY_VALUE; else |
620 | if(DubWiseKeys[1] & DUB_KEY_LEFT) tmp_int = KEY_VALUE; else |
622 | if(DubWiseKeys[1] & DUB_KEY_RIGHT) tmp_int = -KEY_VALUE; else tmp_int = 0; |
621 | if(DubWiseKeys[1] & DUB_KEY_RIGHT) tmp_int = -KEY_VALUE; else tmp_int = 0; |
Line 623... | Line 622... | ||
623 | ExternStickRoll = (ExternStickRoll * 7 + tmp_int) / 8; |
622 | ExternStickRoll = (ExternStickRoll * 7 + tmp_int) / 8; |
624 | 623 | ||
625 | if(DubWiseKeys[0] & 8) ExternStickGier = 50;else |
624 | if(DubWiseKeys[0] & 8) ExternStickYaw = 50;else |
626 | if(DubWiseKeys[0] & 4) ExternStickGier =-50;else ExternStickGier = 0; |
625 | if(DubWiseKeys[0] & 4) ExternStickYaw =-50;else ExternStickYaw = 0; |
627 | if(DubWiseKeys[0] & 2) ExternHoehenValue++; |
626 | if(DubWiseKeys[0] & 2) ExternHightValue++; |
628 | if(DubWiseKeys[0] & 16) ExternHoehenValue--; |
627 | if(DubWiseKeys[0] & 16) ExternHightValue--; |
629 | 628 | ||
630 | StickNick += ExternStickNick / 8; |
629 | StickPitch += ExternStickPitch/ 8; |
631 | StickRoll += ExternStickRoll / 8; |
630 | StickRoll += ExternStickRoll / 8; |
632 | StickGier += ExternStickGier; |
631 | StickYaw += ExternStickYaw; |
633 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
632 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
634 | //+ Analoge Steuerung per Seriell |
633 | //+ Analoge Steuerung per Seriell |
635 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
634 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
636 | if(ExternControl.Config & 0x01 && Parameter_UserParam1 > 128) |
635 | if(ExternControl.Config & 0x01 && Parameter_UserParam1 > 128) |
Line 637... | Line 636... | ||
637 | { |
636 | { |
638 | StickNick += (int) ExternControl.Nick * (int) ParamSet.Stick_P; |
637 | StickPitch += (int) ExternControl.Pitch * (int) ParamSet.Stick_P; |
639 | StickRoll += (int) ExternControl.Roll * (int) ParamSet.Stick_P; |
638 | StickRoll += (int) ExternControl.Roll * (int) ParamSet.Stick_P; |
640 | StickGier += ExternControl.Gier; |
639 | StickYaw += ExternControl.Yaw; |
641 | ExternHoehenValue = (int) ExternControl.Hight * (int)ParamSet.Hoehe_Verstaerkung; |
640 | ExternHightValue = (int) ExternControl.Hight * (int)ParamSet.Hight_Gain; |
642 | if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas; |
641 | if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas; |
643 | } |
642 | } |
644 | 643 | ||
645 | if(ParamSet.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0; |
644 | if(ParamSet.GlobalConfig & CFG_HEADING_HOLD) IntegralFactor = 0; |
646 | if(GyroFaktor < 0) GyroFaktor = 0; |
645 | if(GyroFactor < 0) GyroFactor = 0; |
647 | if(IntegralFaktor < 0) IntegralFaktor = 0; |
646 | if(IntegralFactor < 0) IntegralFactor = 0; |
648 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
647 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
649 | // Looping? |
648 | // Looping? |
650 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
649 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
651 | if((PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_LEFT) Looping_Links = 1; |
650 | if((PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_LEFT) Looping_Left = 1; |
652 | else |
651 | else |
653 | { |
652 | { |
654 | { |
653 | { |
655 | if((PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] < (ParamSet.LoopThreshold - ParamSet.LoopHysteresis))) Looping_Links = 0; |
654 | if((PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] < (ParamSet.LoopThreshold - ParamSet.LoopHysteresis))) Looping_Left = 0; |
656 | } |
655 | } |
657 | } |
656 | } |
Line 658... | Line 657... | ||
658 | if((PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] < -ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_RIGHT) Looping_Rechts = 1; |
657 | if((PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] < -ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_RIGHT) Looping_Right = 1; |
659 | else |
658 | else |
660 | { |
659 | { |
661 | if(Looping_Rechts) // Hysterese |
660 | if(Looping_Right) // Hysterese |
662 | { |
661 | { |
663 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > -(ParamSet.LoopThreshold - ParamSet.LoopHysteresis)) Looping_Rechts = 0; |
662 | if(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] > -(ParamSet.LoopThreshold - ParamSet.LoopHysteresis)) Looping_Right = 0; |
664 | } |
663 | } |
665 | } |
664 | } |
666 | 665 | ||
667 | if((PPM_in[ParamSet.ChannelAssignment[CH_NICK]] > ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_UP) Looping_Oben = 1; |
666 | if((PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] > ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_UP) Looping_Top = 1; |
668 | else |
667 | else |
669 | { |
668 | { |
670 | if(Looping_Oben) // Hysterese |
669 | if(Looping_Top) // Hysterese |
671 | { |
670 | { |
672 | if((PPM_in[ParamSet.ChannelAssignment[CH_NICK]] < (ParamSet.LoopThreshold - ParamSet.LoopHysteresis))) Looping_Oben = 0; |
671 | if((PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] < (ParamSet.LoopThreshold - ParamSet.LoopHysteresis))) Looping_Top = 0; |
673 | } |
672 | } |
Line 674... | Line 673... | ||
674 | } |
673 | } |
675 | if((PPM_in[ParamSet.ChannelAssignment[CH_NICK]] < -ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_DOWN) Looping_Unten = 1; |
674 | if((PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] < -ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_DOWN) Looping_Down = 1; |
676 | else |
675 | else |
Line 677... | Line 676... | ||
677 | { |
676 | { |
678 | if(Looping_Unten) // Hysterese |
677 | if(Looping_Down) // Hysterese |
679 | { |
678 | { |
680 | if(PPM_in[ParamSet.ChannelAssignment[CH_NICK]] > -(ParamSet.LoopThreshold - ParamSet.LoopHysteresis)) Looping_Unten = 0; |
679 | if(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] > -(ParamSet.LoopThreshold - ParamSet.LoopHysteresis)) Looping_Down = 0; |
681 | } |
680 | } |
Line 682... | Line 681... | ||
682 | } |
681 | } |
683 | 682 | ||
684 | if(Looping_Links || Looping_Rechts) Looping_Roll = 1; else Looping_Roll = 0; |
683 | if(Looping_Left || Looping_Right) Looping_Roll = 1; else Looping_Roll = 0; |
685 | if(Looping_Oben || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0; |
684 | if(Looping_Top || Looping_Down) {Looping_Pitch = 1; Looping_Roll = 0; Looping_Left = 0; Looping_Right = 0;} else Looping_Pitch = 0; |
686 | } // Ende neue Funken-Werte |
685 | } // Ende neue Funken-Werte |
687 | 686 | ||
688 | if(Looping_Roll) BeepTime = 100; |
687 | if(Looping_Roll) BeepTime = 100; |
689 | if(Looping_Roll || Looping_Nick) |
688 | if(Looping_Roll || Looping_Pitch) |
690 | { |
689 | { |
691 | if(GasMischanteil > ParamSet.LoopGasLimit) GasMischanteil = ParamSet.LoopGasLimit; |
690 | if(GasMixingFraction > ParamSet.LoopGasLimit) GasMixingFraction = ParamSet.LoopGasLimit; |
692 | } |
691 | } |
693 | 692 | ||
694 | 693 | ||
Line 695... | Line 694... | ||
695 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
694 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
696 | // Bei Empfangsausfall im Flug |
695 | // Bei Empfangsausfall im Flug |
697 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
696 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
698 | if(Notlandung) |
697 | if(EmergencyLanding) |
Line 699... | Line 698... | ||
699 | { |
698 | { |
700 | StickGier = 0; |
699 | StickYaw = 0; |
701 | StickNick = 0; |
700 | StickPitch = 0; |
702 | StickRoll = 0; |
701 | StickRoll = 0; |
Line 703... | Line 702... | ||
703 | GyroFaktor = 0.5;//Originalwert von Holger 0.1; |
702 | GyroFactor = 0.5;//Originalwert von Holger 0.1; |
704 | IntegralFaktor = 0.003; //Originalwert von Holger 0.005; |
703 | IntegralFactor = 0.003; //Originalwert von Holger 0.005; |
705 | Looping_Roll = 0; |
704 | Looping_Roll = 0; |
706 | Looping_Nick = 0; |
705 | Looping_Pitch = 0; |
707 | } |
706 | } |
708 | 707 | ||
709 | 708 | ||
710 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
709 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
711 | // Integrale auf ACC-Signal abgleichen |
710 | // Integrale auf ACC-Signal abgleichen |
712 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
711 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
713 | #define ABGLEICH_ANZAHL 256L |
712 | #define ABGLEICH_ANZAHL 256L |
714 | 713 | ||
715 | MittelIntegralNick += IntegralNick; // Für die Mittelwertbildung aufsummieren |
714 | MeanIntegralPitch += IntegralPitch; // Für die Mittelwertbildung aufsummieren |
716 | MittelIntegralRoll += IntegralRoll; |
715 | MeanIntegralRoll += IntegralRoll; |
Line 717... | Line 716... | ||
717 | MittelIntegralNick2 += IntegralNick2; |
716 | MeanIntegralPitch2 += IntegralPitch2; |
718 | MittelIntegralRoll2 += IntegralRoll2; |
717 | MeanIntegralRoll2 += IntegralRoll2; |
719 | 718 | ||
720 | if(Looping_Nick || Looping_Roll) |
719 | if(Looping_Pitch || Looping_Roll) |
721 | { |
720 | { |
722 | IntegralAccNick = 0; |
721 | IntegralAccPitch = 0; |
723 | IntegralAccRoll = 0; |
722 | IntegralAccRoll = 0; |
724 | MittelIntegralNick = 0; |
723 | MeanIntegralPitch = 0; |
725 | MittelIntegralRoll = 0; |
724 | MeanIntegralRoll = 0; |
726 | MittelIntegralNick2 = 0; |
725 | MeanIntegralPitch2 = 0; |
727 | MittelIntegralRoll2 = 0; |
726 | MeanIntegralRoll2 = 0; |
728 | Mess_IntegralNick2 = Mess_IntegralNick; |
727 | Reading_IntegralPitch2 = Reading_IntegralPitch; |
729 | Mess_IntegralRoll2 = Mess_IntegralRoll; |
728 | Reading_IntegralRoll2 = Reading_IntegralRoll; |
730 | ZaehlMessungen = 0; |
729 | ZaehlMessungen = 0; |
731 | LageKorrekturNick = 0; |
730 | AttitudeCorrectionPitch = 0; |
732 | LageKorrekturRoll = 0; |
731 | AttitudeCorrectionRoll = 0; |
733 | } |
732 | } |
734 | 733 | ||
Line 755... | Line 754... | ||
755 | if(tmp_long > AUSGLEICH) tmp_long = AUSGLEICH; |
754 | if(tmp_long > AUSGLEICH) tmp_long = AUSGLEICH; |
756 | if(tmp_long < -AUSGLEICH) tmp_long =-AUSGLEICH; |
755 | if(tmp_long < -AUSGLEICH) tmp_long =-AUSGLEICH; |
757 | if(tmp_long2 > AUSGLEICH) tmp_long2 = AUSGLEICH; |
756 | if(tmp_long2 > AUSGLEICH) tmp_long2 = AUSGLEICH; |
758 | if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH; |
757 | if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH; |
Line 759... | Line 758... | ||
759 | 758 | ||
760 | Mess_IntegralNick -= tmp_long; |
759 | Reading_IntegralPitch -= tmp_long; |
761 | Mess_IntegralRoll -= tmp_long2; |
760 | Reading_IntegralRoll -= tmp_long2; |
762 | } |
761 | } |
Line 763... | Line 762... | ||
763 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
762 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
764 | 763 | ||
765 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
764 | if(ZaehlMessungen >= ABGLEICH_ANZAHL) |
766 | { |
765 | { |
767 | static int cnt = 0; |
766 | static int cnt = 0; |
768 | static char last_n_p,last_n_n,last_r_p,last_r_n; |
767 | static char last_n_p,last_n_n,last_r_p,last_r_n; |
769 | static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt; |
768 | static long MeanIntegralPitch_old,MeanIntegralRoll_old; |
770 | if(!Looping_Nick && !Looping_Roll) |
769 | if(!Looping_Pitch && !Looping_Roll) |
771 | { |
770 | { |
772 | MittelIntegralNick /= ABGLEICH_ANZAHL; |
771 | MeanIntegralPitch /= ABGLEICH_ANZAHL; |
773 | MittelIntegralRoll /= ABGLEICH_ANZAHL; |
772 | MeanIntegralRoll /= ABGLEICH_ANZAHL; |
774 | IntegralAccNick = (ParamSet.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL; |
773 | IntegralAccPitch = (ParamSet.GyroAccFaktor * IntegralAccPitch) / ABGLEICH_ANZAHL; |
775 | IntegralAccRoll = (ParamSet.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL; |
774 | IntegralAccRoll = (ParamSet.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL; |
776 | IntegralAccZ = IntegralAccZ / ABGLEICH_ANZAHL; |
775 | IntegralAccZ = IntegralAccZ / ABGLEICH_ANZAHL; |
777 | #define MAX_I 0//(Poti2/10) |
776 | #define MAX_I 0//(Poti2/10) |
778 | // Nick ++++++++++++++++++++++++++++++++++++++++++++++++ |
777 | // Pitch ++++++++++++++++++++++++++++++++++++++++++++++++ |
779 | IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick); |
778 | IntegralErrorPitch = (long)(MeanIntegralPitch - (long)IntegralAccPitch); |
780 | ausgleichNick = IntegralFehlerNick / ParamSet.GyroAccAbgleich; |
779 | CorrectionPitch = IntegralErrorPitch / ParamSet.GyroAccTrim; |
781 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
780 | // Roll ++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 782... | Line 781... | ||
782 | IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll); |
781 | IntegralErrorRoll = (long)(MeanIntegralRoll - (long)IntegralAccRoll); |
783 | ausgleichRoll = IntegralFehlerRoll / ParamSet.GyroAccAbgleich; |
782 | CorrectionRoll = IntegralErrorRoll / ParamSet.GyroAccTrim; |
Line 784... | Line 783... | ||
784 | 783 | ||
785 | LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL; |
784 | AttitudeCorrectionPitch = CorrectionPitch / ABGLEICH_ANZAHL; |
786 | LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL; |
785 | AttitudeCorrectionRoll = CorrectionRoll / ABGLEICH_ANZAHL; |
787 | 786 | ||
788 | if((MaxStickNick > 15) || (MaxStickRoll > 15) || (abs(PPM_in[ParamSet.ChannelAssignment[CH_GIER]]) > 25)) |
787 | if((MaxStickPitch > 15) || (MaxStickRoll > 15) || (abs(PPM_in[ParamSet.ChannelAssignment[CH_YAW]]) > 25)) |
Line 789... | Line 788... | ||
789 | { |
788 | { |
790 | LageKorrekturNick /= 2; |
789 | AttitudeCorrectionPitch /= 2; |
791 | LageKorrekturNick /= 2; |
790 | AttitudeCorrectionPitch /= 2; |
792 | } |
791 | } |
793 | 792 | ||
794 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
793 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
795 | // Gyro-Drift ermitteln |
794 | // Gyro-Drift ermitteln |
796 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
795 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 797... | Line 796... | ||
797 | MittelIntegralNick2 /= ABGLEICH_ANZAHL; |
796 | MeanIntegralPitch2 /= ABGLEICH_ANZAHL; |
798 | MittelIntegralRoll2 /= ABGLEICH_ANZAHL; |
797 | MeanIntegralRoll2 /= ABGLEICH_ANZAHL; |
799 | tmp_long = IntegralNick2 - IntegralNick; |
798 | tmp_long = IntegralPitch2 - IntegralPitch; |
800 | tmp_long2 = IntegralRoll2 - IntegralRoll; |
799 | tmp_long2 = IntegralRoll2 - IntegralRoll; |
Line 801... | Line 800... | ||
801 | //DebugOut.Analog[25] = MittelIntegralRoll2 / 26; |
800 | //DebugOut.Analog[25] = MeanIntegralRoll2 / 26; |
802 | 801 | ||
Line 803... | Line 802... | ||
803 | IntegralFehlerNick = tmp_long; |
802 | IntegralErrorPitch = tmp_long; |
804 | IntegralFehlerRoll = tmp_long2; |
803 | IntegralErrorRoll = tmp_long2; |
805 | Mess_IntegralNick2 -= IntegralFehlerNick; |
804 | Reading_IntegralPitch2 -= IntegralErrorPitch; |
806 | Mess_IntegralRoll2 -= IntegralFehlerRoll; |
805 | Reading_IntegralRoll2 -= IntegralErrorRoll; |
807 | 806 | ||
808 | // IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2; |
807 | // IntegralErrorPitch = (IntegralErrorPitch * 1 + tmp_long) / 2; |
809 | // IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2; |
808 | // IntegralErrorRoll = (IntegralErrorRoll * 1 + tmp_long2) / 2; |
810 | 809 | ||
811 | 810 | ||
Line 812... | Line 811... | ||
812 | DebugOut.Analog[17] = IntegralAccNick / 26; |
811 | DebugOut.Analog[17] = IntegralAccPitch / 26; |
813 | DebugOut.Analog[18] = IntegralAccRoll / 26; |
812 | DebugOut.Analog[18] = IntegralAccRoll / 26; |
814 | DebugOut.Analog[19] = IntegralFehlerNick;// / 26; |
813 | DebugOut.Analog[19] = IntegralErrorPitch;// / 26; |
815 | DebugOut.Analog[20] = IntegralFehlerRoll;// / 26; |
814 | DebugOut.Analog[20] = IntegralErrorRoll;// / 26; |
816 | DebugOut.Analog[21] = MittelIntegralNick / 26; |
815 | DebugOut.Analog[21] = MeanIntegralPitch / 26; |
817 | DebugOut.Analog[22] = MittelIntegralRoll / 26; |
816 | DebugOut.Analog[22] = MeanIntegralRoll / 26; |
818 | //DebugOut.Analog[28] = ausgleichNick; |
817 | //DebugOut.Analog[28] = CorrectionPitch; |
819 | DebugOut.Analog[29] = ausgleichRoll; |
818 | DebugOut.Analog[29] = CorrectionRoll; |
820 | DebugOut.Analog[30] = LageKorrekturRoll * 10; |
819 | DebugOut.Analog[30] = AttitudeCorrectionRoll * 10; |
821 | 820 | ||
822 | #define FEHLER_LIMIT (ABGLEICH_ANZAHL * 4) |
821 | #define FEHLER_LIMIT (ABGLEICH_ANZAHL * 4) |
823 | #define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16) |
822 | #define FEHLER_LIMIT2 (ABGLEICH_ANZAHL * 16) |
824 | #define BEWEGUNGS_LIMIT 20000 |
823 | #define BEWEGUNGS_LIMIT 20000 |
825 | // Nick +++++++++++++++++++++++++++++++++++++++++++++++++ |
824 | // Pitch +++++++++++++++++++++++++++++++++++++++++++++++++ |
826 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
825 | cnt = 1;// + labs(IntegralErrorPitch) / 4096; |
827 | if(labs(MittelIntegralNick_Alt - MittelIntegralNick) < BEWEGUNGS_LIMIT) |
826 | if(labs(MeanIntegralPitch_old - MeanIntegralPitch) < BEWEGUNGS_LIMIT) |
828 | { |
827 | { |
829 | if(IntegralFehlerNick > FEHLER_LIMIT2) |
828 | if(IntegralErrorPitch > FEHLER_LIMIT2) |
830 | { |
829 | { |
831 | if(last_n_p) |
830 | if(last_n_p) |
832 | { |
831 | { |
833 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
832 | cnt += labs(IntegralErrorPitch) / FEHLER_LIMIT2; |
834 | ausgleichNick = IntegralFehlerNick / 8; |
833 | CorrectionPitch = IntegralErrorPitch / 8; |
835 | if(ausgleichNick > 5000) ausgleichNick = 5000; |
834 | if(CorrectionPitch > 5000) CorrectionPitch = 5000; |
836 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
835 | AttitudeCorrectionPitch += CorrectionPitch / ABGLEICH_ANZAHL; |
837 | } |
836 | } |
838 | else last_n_p = 1; |
837 | else last_n_p = 1; |
839 | } else last_n_p = 0; |
838 | } else last_n_p = 0; |
840 | if(IntegralFehlerNick < -FEHLER_LIMIT2) |
839 | if(IntegralErrorPitch < -FEHLER_LIMIT2) |
841 | { |
840 | { |
842 | if(last_n_n) |
841 | if(last_n_n) |
843 | { |
842 | { |
844 | cnt += labs(IntegralFehlerNick) / FEHLER_LIMIT2; |
843 | cnt += labs(IntegralErrorPitch) / FEHLER_LIMIT2; |
Line 845... | Line 844... | ||
845 | ausgleichNick = IntegralFehlerNick / 8; |
844 | CorrectionPitch = IntegralErrorPitch / 8; |
846 | if(ausgleichNick < -5000) ausgleichNick = -5000; |
845 | if(CorrectionPitch < -5000) CorrectionPitch = -5000; |
Line 847... | Line 846... | ||
847 | LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL; |
846 | AttitudeCorrectionPitch += CorrectionPitch / ABGLEICH_ANZAHL; |
848 | } |
847 | } |
849 | else last_n_n = 1; |
848 | else last_n_n = 1; |
850 | } else last_n_n = 0; |
849 | } else last_n_n = 0; |
851 | } else cnt = 0; |
850 | } else cnt = 0; |
852 | if(cnt > ParamSet.DriftComp) cnt = ParamSet.DriftComp; |
851 | if(cnt > ParamSet.DriftComp) cnt = ParamSet.DriftComp; |
853 | if(IntegralFehlerNick > FEHLER_LIMIT) AdNeutralNick += cnt; |
852 | if(IntegralErrorPitch > FEHLER_LIMIT) AdNeutralPitch += cnt; |
854 | if(IntegralFehlerNick < -FEHLER_LIMIT) AdNeutralNick -= cnt; |
853 | if(IntegralErrorPitch < -FEHLER_LIMIT) AdNeutralPitch -= cnt; |
855 | 854 | ||
856 | // Roll +++++++++++++++++++++++++++++++++++++++++++++++++ |
855 | // Roll +++++++++++++++++++++++++++++++++++++++++++++++++ |
857 | cnt = 1;// + labs(IntegralFehlerNick) / 4096; |
856 | cnt = 1;// + labs(IntegralErrorPitch) / 4096; |
858 | 857 | ||
859 | ausgleichRoll = 0; |
858 | CorrectionRoll = 0; |
860 | if(labs(MittelIntegralRoll_Alt - MittelIntegralRoll) < BEWEGUNGS_LIMIT) |
859 | if(labs(MeanIntegralRoll_old - MeanIntegralRoll) < BEWEGUNGS_LIMIT) |
861 | { |
860 | { |
862 | if(IntegralFehlerRoll > FEHLER_LIMIT2) |
861 | if(IntegralErrorRoll > FEHLER_LIMIT2) |
863 | { |
862 | { |
864 | if(last_r_p) |
863 | if(last_r_p) |
865 | { |
864 | { |
866 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
865 | cnt += labs(IntegralErrorRoll) / FEHLER_LIMIT2; |
867 | ausgleichRoll = IntegralFehlerRoll / 8; |
866 | CorrectionRoll = IntegralErrorRoll / 8; |
868 | if(ausgleichRoll > 5000) ausgleichRoll = 5000; |
867 | if(CorrectionRoll > 5000) CorrectionRoll = 5000; |
869 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
868 | AttitudeCorrectionRoll += CorrectionRoll / ABGLEICH_ANZAHL; |
870 | } |
869 | } |
871 | else last_r_p = 1; |
870 | else last_r_p = 1; |
872 | } else last_r_p = 0; |
871 | } else last_r_p = 0; |
873 | if(IntegralFehlerRoll < -FEHLER_LIMIT2) |
872 | if(IntegralErrorRoll < -FEHLER_LIMIT2) |
874 | { |
873 | { |
875 | if(last_r_n) |
874 | if(last_r_n) |
Line 876... | Line 875... | ||
876 | { |
875 | { |
877 | cnt += labs(IntegralFehlerRoll) / FEHLER_LIMIT2; |
876 | cnt += labs(IntegralErrorRoll) / FEHLER_LIMIT2; |
878 | ausgleichRoll = IntegralFehlerRoll / 8; |
877 | CorrectionRoll = IntegralErrorRoll / 8; |
879 | if(ausgleichRoll < -5000) ausgleichRoll = -5000; |
878 | if(CorrectionRoll < -5000) CorrectionRoll = -5000; |
880 | LageKorrekturRoll += ausgleichRoll / ABGLEICH_ANZAHL; |
879 | AttitudeCorrectionRoll += CorrectionRoll / ABGLEICH_ANZAHL; |
881 | } |
880 | } |
882 | else last_r_n = 1; |
881 | else last_r_n = 1; |
883 | } else last_r_n = 0; |
882 | } else last_r_n = 0; |
884 | } else |
883 | } else |
885 | { |
884 | { |
886 | cnt = 0; |
885 | cnt = 0; |
887 | } |
886 | } |
Line 888... | Line 887... | ||
888 | 887 | ||
889 | if(cnt > ParamSet.DriftComp) cnt = ParamSet.DriftComp; |
888 | if(cnt > ParamSet.DriftComp) cnt = ParamSet.DriftComp; |
890 | if(IntegralFehlerRoll > FEHLER_LIMIT) AdNeutralRoll += cnt; |
889 | if(IntegralErrorRoll > FEHLER_LIMIT) AdNeutralRoll += cnt; |
891 | if(IntegralFehlerRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt; |
890 | if(IntegralErrorRoll < -FEHLER_LIMIT) AdNeutralRoll -= cnt; |
892 | DebugOut.Analog[27] = ausgleichRoll; |
891 | DebugOut.Analog[27] = CorrectionRoll; |
893 | DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick); |
892 | DebugOut.Analog[23] = AdNeutralPitch;//10*(AdNeutralPitch - StartNeutralPitch); |
894 | DebugOut.Analog[24] = 10*(AdNeutralRoll - StartNeutralRoll); |
893 | DebugOut.Analog[24] = 10*(AdNeutralRoll - StartNeutralRoll); |
895 | } |
894 | } |
896 | else |
895 | else |
897 | { |
896 | { |
898 | LageKorrekturRoll = 0; |
897 | AttitudeCorrectionRoll = 0; |
899 | LageKorrekturNick = 0; |
898 | AttitudeCorrectionPitch = 0; |
900 | } |
899 | } |
901 | 900 | ||
902 | if(!IntegralFaktor) { LageKorrekturRoll = 0; LageKorrekturNick = 0;} // z.B. bei HH |
901 | if(!IntegralFactor) { AttitudeCorrectionRoll = 0; AttitudeCorrectionPitch = 0;} // z.B. bei HH |
Line 903... | Line 902... | ||
903 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
902 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
904 | MittelIntegralNick_Alt = MittelIntegralNick; |
903 | MeanIntegralPitch_old = MeanIntegralPitch; |
905 | MittelIntegralRoll_Alt = MittelIntegralRoll; |
904 | MeanIntegralRoll_old = MeanIntegralRoll; |
906 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
905 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
907 | IntegralAccNick = 0; |
906 | IntegralAccPitch = 0; |
908 | IntegralAccRoll = 0; |
907 | IntegralAccRoll = 0; |
909 | IntegralAccZ = 0; |
908 | IntegralAccZ = 0; |
910 | MittelIntegralNick = 0; |
909 | MeanIntegralPitch = 0; |
911 | MittelIntegralRoll = 0; |
910 | MeanIntegralRoll = 0; |
912 | MittelIntegralNick2 = 0; |
911 | MeanIntegralPitch2 = 0; |
913 | MittelIntegralRoll2 = 0; |
912 | MeanIntegralRoll2 = 0; |
914 | ZaehlMessungen = 0; |
913 | ZaehlMessungen = 0; |
915 | } |
914 | } |
Line 916... | Line 915... | ||
916 | //DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor); |
915 | //DebugOut.Analog[31] = StickRoll / (26*IntegralFactor); |
917 | 916 | ||
918 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
917 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
919 | // Gieren |
918 | // Gieren |
920 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
919 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
921 | if(abs(StickGier) > 20) // war 35 |
920 | if(abs(StickYaw) > 20) // war 35 |
922 | { |
921 | { |
Line 923... | Line 922... | ||
923 | if(!(ParamSet.GlobalConfig & CFG_COMPASS_FIX)) NeueKompassRichtungMerken = 1; |
922 | if(!(ParamSet.GlobalConfig & CFG_COMPASS_FIX)) StoreNewCompassCourse = 1; |
924 | } |
923 | } |
925 | tmp_int = (long) ParamSet.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo y = ax + bx² |
924 | tmp_int = (long) ParamSet.Yaw_P * ((long)StickYaw * abs(StickYaw)) / 512L; // expo y = ax + bx² |
926 | tmp_int += (ParamSet.Gier_P * StickGier) / 4; |
925 | tmp_int += (ParamSet.Yaw_P * StickYaw) / 4; |
927 | sollGier = tmp_int; |
926 | SetPointYaw = tmp_int; |
928 | Mess_Integral_Gier -= tmp_int; |
927 | Reading_Integral_Yaw -= tmp_int; |
Line 929... | Line 928... | ||
929 | if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000; // begrenzen |
928 | if(Reading_Integral_Yaw > 50000) Reading_Integral_Yaw = 50000; // begrenzen |
930 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
929 | if(Reading_Integral_Yaw <-50000) Reading_Integral_Yaw =-50000; |
931 | 930 | ||
932 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
931 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
933 | // Kompass |
932 | // Kompass |
934 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
933 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
935 | if(ParamSet.GlobalConfig & CFG_COMPASS_ACTIVE) |
934 | if(ParamSet.GlobalConfig & CFG_COMPASS_ACTIVE) |
936 | { |
935 | { |
937 | int w,v; |
936 | int w,v; |
938 | static uint8_t updKompass = 0; |
937 | static uint8_t updCompass = 0; |
939 | 938 | ||
940 | if (!updKompass--) // Aufruf mit ~10 Hz |
939 | if (!updCompass--) // Aufruf mit ~10 Hz |
941 | { |
940 | { |
942 | KompassValue = MM3_heading(); // get current compass reading |
941 | CompassHeading = MM3_heading(); // get current compass reading |
943 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
942 | CompassOffCourse = ((540 + CompassHeading - CompassCourse) % 360) - 180; |
944 | updKompass = 50; |
943 | updCompass = 50; |
Line 945... | Line 944... | ||
945 | } |
944 | } |
946 | 945 | ||
947 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
946 | w = abs(IntegralPitch /512); // mit zunehmender Neigung den Einfluss drosseln |
948 | v = abs(IntegralRoll /512); |
947 | v = abs(IntegralRoll /512); |
949 | if(v > w) w = v; // grösste Neigung ermitteln |
948 | if(v > w) w = v; // grösste Neigung ermitteln |
950 | if(w < 35 && NeueKompassRichtungMerken) |
949 | if(w < 35 && StoreNewCompassCourse) |
951 | { |
950 | { |
952 | KompassStartwert = KompassValue; |
951 | CompassCourse = CompassHeading; |
953 | NeueKompassRichtungMerken = 0; |
952 | StoreNewCompassCourse = 0; |
954 | } |
953 | } |
955 | w = (w * Parameter_KompassWirkung) / 64; // auf die Wirkung normieren |
954 | w = (w * Parameter_CompassYawEffect) / 64; // auf die Wirkung normieren |
956 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
955 | w = Parameter_CompassYawEffect - w; // Wirkung ggf drosseln |
957 | if(w > 0) |
956 | if(w > 0) |
958 | { |
957 | { |
959 | Mess_Integral_Gier += (KompassRichtung * w) / 32; // nach Kompass ausrichten |
958 | Reading_Integral_Yaw -= (CompassOffCourse * w) / 32; // nach Kompass ausrichten |
960 | } |
959 | } |
961 | } |
960 | } |
Line 962... | Line 961... | ||
962 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
961 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
963 | 962 | ||
964 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
963 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
965 | // Debugwerte zuordnen |
964 | // Debugwerte zuordnen |
Line 989... | Line 988... | ||
989 | DebugOut.Analog[22] = motor_rx[5]; |
988 | DebugOut.Analog[22] = motor_rx[5]; |
990 | DebugOut.Analog[23] = motor_rx[6]; |
989 | DebugOut.Analog[23] = motor_rx[6]; |
991 | DebugOut.Analog[24] = motor_rx[7]; |
990 | DebugOut.Analog[24] = motor_rx[7]; |
992 | DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7]; |
991 | DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7]; |
993 | */ |
992 | */ |
994 | // DebugOut.Analog[9] = MesswertNick; |
993 | // DebugOut.Analog[9] = ReadingPitch; |
995 | // DebugOut.Analog[9] = SollHoehe; |
994 | // DebugOut.Analog[9] = SetPointHight; |
996 | // DebugOut.Analog[10] = Mess_Integral_Gier / 128; |
995 | // DebugOut.Analog[10] = Reading_Integral_Yaw / 128; |
997 | // DebugOut.Analog[11] = KompassStartwert; |
996 | // DebugOut.Analog[11] = CompassCourse; |
998 | // DebugOut.Analog[10] = Parameter_Gyro_I; |
997 | // DebugOut.Analog[10] = Parameter_Gyro_I; |
999 | // DebugOut.Analog[10] = ParamSet.Gyro_I; |
998 | // DebugOut.Analog[10] = ParamSet.Gyro_I; |
1000 | // DebugOut.Analog[9] = KompassRichtung; |
999 | // DebugOut.Analog[9] = CompassOffCourse; |
1001 | // DebugOut.Analog[10] = GasMischanteil; |
1000 | // DebugOut.Analog[10] = GasMixingFraction; |
1002 | // DebugOut.Analog[3] = HoeheD * 32; |
1001 | // DebugOut.Analog[3] = HoeheD * 32; |
1003 | // DebugOut.Analog[4] = hoehenregler; |
1002 | // DebugOut.Analog[4] = hoehenregler; |
1004 | } |
1003 | } |
Line 1005... | Line 1004... | ||
1005 | 1004 | ||
1006 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1005 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1007 | // Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen |
1006 | // Drehgeschwindigkeit und -winkel zu einem Istwert zusammenfassen |
1008 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1007 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1009 | //DebugOut.Analog[26] = MesswertNick; |
1008 | //DebugOut.Analog[26] = ReadingPitch; |
Line 1010... | Line 1009... | ||
1010 | //DebugOut.Analog[28] = MesswertRoll; |
1009 | //DebugOut.Analog[28] = ReadingRoll; |
1011 | 1010 | ||
1012 | if(Looping_Nick) MesswertNick = MesswertNick * GyroFaktor; |
1011 | if(Looping_Pitch) ReadingPitch = ReadingPitch * GyroFactor; |
1013 | else MesswertNick = IntegralNick * IntegralFaktor + MesswertNick * GyroFaktor; |
1012 | else ReadingPitch = IntegralPitch * IntegralFactor + ReadingPitch * GyroFactor; |
1014 | if(Looping_Roll) MesswertRoll = MesswertRoll * GyroFaktor; |
1013 | if(Looping_Roll) ReadingRoll = ReadingRoll * GyroFactor; |
1015 | else MesswertRoll = IntegralRoll * IntegralFaktor + MesswertRoll * GyroFaktor; |
1014 | else ReadingRoll = IntegralRoll * IntegralFactor + ReadingRoll * GyroFactor; |
1016 | MesswertGier = MesswertGier * (2 * GyroFaktor) + Integral_Gier * IntegralFaktor / 2; |
1015 | ReadingYaw = ReadingYaw * (2 * GyroFactor) + Integral_Yaw * IntegralFactor / 2; |
1017 | 1016 | ||
1018 | DebugOut.Analog[25] = IntegralRoll * IntegralFaktor; |
1017 | DebugOut.Analog[25] = IntegralRoll * IntegralFactor; |
Line 1019... | Line 1018... | ||
1019 | DebugOut.Analog[31] = StickRoll;// / (26*IntegralFaktor); |
1018 | DebugOut.Analog[31] = StickRoll;// / (26*IntegralFactor); |
1020 | DebugOut.Analog[28] = MesswertRoll; |
1019 | DebugOut.Analog[28] = ReadingRoll; |
1021 | 1020 | ||
1022 | // Maximalwerte abfangen |
1021 | // Maximalwerte abfangen |
1023 | #define MAX_SENSOR 2048 |
1022 | #define MAX_SENSOR 2048 |
1024 | if(MesswertNick > MAX_SENSOR) MesswertNick = MAX_SENSOR; |
1023 | if(ReadingPitch > MAX_SENSOR) ReadingPitch = MAX_SENSOR; |
1025 | if(MesswertNick < -MAX_SENSOR) MesswertNick = -MAX_SENSOR; |
1024 | if(ReadingPitch < -MAX_SENSOR) ReadingPitch = -MAX_SENSOR; |
1026 | if(MesswertRoll > MAX_SENSOR) MesswertRoll = MAX_SENSOR; |
1025 | if(ReadingRoll > MAX_SENSOR) ReadingRoll = MAX_SENSOR; |
Line 1027... | Line 1026... | ||
1027 | if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR; |
1026 | if(ReadingRoll < -MAX_SENSOR) ReadingRoll = -MAX_SENSOR; |
1028 | if(MesswertGier > MAX_SENSOR) MesswertGier = MAX_SENSOR; |
1027 | if(ReadingYaw > MAX_SENSOR) ReadingYaw = MAX_SENSOR; |
1029 | if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR; |
1028 | if(ReadingYaw < -MAX_SENSOR) ReadingYaw = -MAX_SENSOR; |
1030 | 1029 | ||
Line 1039... | Line 1038... | ||
1039 | int tmp_int; |
1038 | int tmp_int; |
1040 | if(ParamSet.GlobalConfig & CFG_HEIGHT_SWITCH) // Regler wird über Schalter gesteuert |
1039 | if(ParamSet.GlobalConfig & CFG_HEIGHT_SWITCH) // Regler wird über Schalter gesteuert |
1041 | { |
1040 | { |
1042 | if(Parameter_MaxHoehe < 50) |
1041 | if(Parameter_MaxHoehe < 50) |
1043 | { |
1042 | { |
1044 | SollHoehe = HoehenWert - 20; // Parameter_MaxHoehe ist der PPM-Wert des Schalters |
1043 | SetPointHight = ReadingHight - 20; // Parameter_MaxHoehe ist der PPM-Wert des Schalters |
1045 | HoehenReglerAktiv = 0; |
1044 | HightControlActive = 0; |
1046 | } |
1045 | } |
1047 | else |
1046 | else |
1048 | HoehenReglerAktiv = 1; |
1047 | HightControlActive = 1; |
1049 | } |
1048 | } |
1050 | else |
1049 | else |
1051 | { |
1050 | { |
1052 | SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)ParamSet.Hoehe_Verstaerkung - 20; |
1051 | SetPointHight = ((int) ExternHightValue + (int) Parameter_MaxHoehe) * (int)ParamSet.Hight_Gain - 20; |
1053 | HoehenReglerAktiv = 1; |
1052 | HightControlActive = 1; |
1054 | } |
1053 | } |
Line 1055... | Line 1054... | ||
1055 | 1054 | ||
1056 | if(Notlandung) SollHoehe = 0; |
1055 | if(EmergencyLanding) SetPointHight = 0; |
1057 | h = HoehenWert; |
1056 | h = ReadingHight; |
1058 | if((h > SollHoehe) && HoehenReglerAktiv) // zu hoch --> drosseln |
1057 | if((h > SetPointHight) && HightControlActive) // zu hoch --> drosseln |
1059 | { h = ((h - SollHoehe) * (int) Parameter_Hoehe_P) / 16; // Differenz bestimmen --> P-Anteil |
1058 | { h = ((h - SetPointHight) * (int) Parameter_Hoehe_P) / 16; // Differenz bestimmen --> P-Anteil |
1060 | h = GasMischanteil - h; // vom Gas abziehen |
1059 | h = GasMixingFraction - h; // vom Gas abziehen |
1061 | h -= (HoeheD * Parameter_Luftdruck_D)/8; // D-Anteil |
1060 | h -= (HoeheD * Parameter_Luftdruck_D)/8; // D-Anteil |
1062 | tmp_int = ((Mess_Integral_Hoch / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32; |
1061 | tmp_int = ((Reading_Integral_Top / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32; |
1063 | if(tmp_int > 50) tmp_int = 50; |
1062 | if(tmp_int > 50) tmp_int = 50; |
1064 | else if(tmp_int < -50) tmp_int = -50; |
1063 | else if(tmp_int < -50) tmp_int = -50; |
1065 | h -= tmp_int; |
1064 | h -= tmp_int; |
1066 | hoehenregler = (hoehenregler*15 + h) / 16; |
1065 | hoehenregler = (hoehenregler*15 + h) / 16; |
1067 | if(hoehenregler < ParamSet.Hoehe_MinGas) // nicht unter MIN |
1066 | if(hoehenregler < ParamSet.Hight_MinGas) // nicht unter MIN |
1068 | { |
1067 | { |
1069 | if(GasMischanteil >= ParamSet.Hoehe_MinGas) hoehenregler = ParamSet.Hoehe_MinGas; |
1068 | if(GasMixingFraction >= ParamSet.Hight_MinGas) hoehenregler = ParamSet.Hight_MinGas; |
1070 | if(GasMischanteil < ParamSet.Hoehe_MinGas) hoehenregler = GasMischanteil; |
1069 | if(GasMixingFraction < ParamSet.Hight_MinGas) hoehenregler = GasMixingFraction; |
1071 | } |
1070 | } |
1072 | if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas |
1071 | if(hoehenregler > GasMixingFraction) hoehenregler = GasMixingFraction; // nicht mehr als Gas |
1073 | GasMischanteil = hoehenregler; |
1072 | GasMixingFraction = hoehenregler; |
1074 | } |
1073 | } |
1075 | } |
1074 | } |
1076 | if(GasMischanteil > MAX_GAS - 20) GasMischanteil = MAX_GAS - 20; |
1075 | if(GasMixingFraction > MAX_GAS - 20) GasMixingFraction = MAX_GAS - 20; |
1077 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1076 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1078 | // + Mischer und PI-Regler |
1077 | // + Mischer und PI-Regler |
1079 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1078 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1080 | DebugOut.Analog[7] = GasMischanteil; |
1079 | DebugOut.Analog[7] = GasMixingFraction; |
1081 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1080 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1082 | // Gier-Anteil |
1081 | // Gier-Anteil |
1083 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1082 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1084 | #define MUL_G 1.0 |
1083 | #define MUL_G 1.0 |
1085 | GierMischanteil = MesswertGier - sollGier; // Regler für Gier |
1084 | YawMixingFraction = ReadingYaw - SetPointYaw; // Regler für Gier |
Line 1086... | Line 1085... | ||
1086 | // GierMischanteil = 0; |
1085 | // YawMixingFraction = 0; |
1087 | 1086 | ||
1088 | if(GierMischanteil > (GasMischanteil / 2)) GierMischanteil = GasMischanteil / 2; |
1087 | if(YawMixingFraction > (GasMixingFraction / 2)) YawMixingFraction = GasMixingFraction / 2; |
1089 | if(GierMischanteil < -(GasMischanteil / 2)) GierMischanteil = -(GasMischanteil / 2); |
1088 | if(YawMixingFraction < -(GasMixingFraction / 2)) YawMixingFraction = -(GasMixingFraction / 2); |
1090 | if(GierMischanteil > ((MAX_GAS - GasMischanteil))) GierMischanteil = ((MAX_GAS - GasMischanteil)); |
1089 | if(YawMixingFraction > ((MAX_GAS - GasMixingFraction))) YawMixingFraction = ((MAX_GAS - GasMixingFraction)); |
1091 | if(GierMischanteil < -((MAX_GAS - GasMischanteil))) GierMischanteil = -((MAX_GAS - GasMischanteil)); |
1090 | if(YawMixingFraction < -((MAX_GAS - GasMixingFraction))) YawMixingFraction = -((MAX_GAS - GasMixingFraction)); |
1092 | 1091 | ||
1093 | if(GasMischanteil < 20) GierMischanteil = 0; |
1092 | if(GasMixingFraction < 20) YawMixingFraction = 0; |
1094 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1093 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1095 | // Nick-Achse |
1094 | // Pitch-Achse |
1096 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1095 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1097 | DiffNick = MesswertNick - (StickNick - GPS_Nick); // Differenz bestimmen |
1096 | DiffPitch = ReadingPitch - (StickPitch - GPS_Pitch); // Differenz bestimmen |
1098 | if(IntegralFaktor) SummeNick += IntegralNick * IntegralFaktor - (StickNick - GPS_Nick); // I-Anteil bei Winkelregelung |
1097 | if(IntegralFactor) SumPitch += IntegralPitch * IntegralFactor - (StickPitch - GPS_Pitch); // I-Anteil bei Winkelregelung |
1099 | else SummeNick += DiffNick; // I-Anteil bei HH |
1098 | else SumPitch += DiffPitch; // I-Anteil bei HH |
1100 | if(SummeNick > 16000) SummeNick = 16000; |
1099 | if(SumPitch > 16000) SumPitch = 16000; |
1101 | if(SummeNick < -16000) SummeNick = -16000; |
1100 | if(SumPitch < -16000) SumPitch = -16000; |
1102 | pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick |
1101 | pd_ergebnis = DiffPitch + Ki * SumPitch; // PI-Regler für Pitch |
1103 | // Motor Vorn |
1102 | // Motor Vorn |
1104 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1103 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64; |
Line 1105... | Line 1104... | ||
1105 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1104 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1106 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1105 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1107 | 1106 | ||
1108 | motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; // Mischer |
1107 | MotorValue = GasMixingFraction + pd_ergebnis + YawMixingFraction; // Mischer |
1109 | if ((motorwert < 0)) motorwert = 0; |
1108 | if ((MotorValue < 0)) MotorValue = 0; |
1110 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1109 | else if(MotorValue > MAX_GAS) MotorValue = MAX_GAS; |
1111 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1110 | if (MotorValue < MIN_GAS) MotorValue = MIN_GAS; |
1112 | Motor_Vorne = motorwert; |
1111 | Motor_Front = MotorValue; |
1113 | // Motor Heck |
1112 | // Motor Heck |
1114 | motorwert = GasMischanteil - pd_ergebnis + GierMischanteil; |
1113 | MotorValue = GasMixingFraction - pd_ergebnis + YawMixingFraction; |
1115 | if ((motorwert < 0)) motorwert = 0; |
1114 | if ((MotorValue < 0)) MotorValue = 0; |
1116 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1115 | else if(MotorValue > MAX_GAS) MotorValue = MAX_GAS; |
1117 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1116 | if (MotorValue < MIN_GAS) MotorValue = MIN_GAS; |
1118 | Motor_Hinten = motorwert; |
1117 | Motor_Rear = MotorValue; |
1119 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1118 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1120 | // Roll-Achse |
1119 | // Roll-Achse |
1121 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1120 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1122 | DiffRoll = MesswertRoll - (StickRoll - GPS_Roll); // Differenz bestimmen |
1121 | DiffRoll = ReadingRoll - (StickRoll - GPS_Roll); // Differenz bestimmen |
1123 | if(IntegralFaktor) SummeRoll += IntegralRoll * IntegralFaktor - (StickRoll - GPS_Roll);// I-Anteil bei Winkelregelung |
1122 | if(IntegralFactor) SumRoll += IntegralRoll * IntegralFactor - (StickRoll - GPS_Roll);// I-Anteil bei Winkelregelung |
1124 | else SummeRoll += DiffRoll; // I-Anteil bei HH |
1123 | else SumRoll += DiffRoll; // I-Anteil bei HH |
1125 | if(SummeRoll > 16000) SummeRoll = 16000; |
1124 | if(SumRoll > 16000) SumRoll = 16000; |
1126 | if(SummeRoll < -16000) SummeRoll = -16000; |
1125 | if(SumRoll < -16000) SumRoll = -16000; |
1127 | pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll |
1126 | pd_ergebnis = DiffRoll + Ki * SumRoll; // PI-Regler für Roll |
1128 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64; |
1127 | tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64; |
1129 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1128 | if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int; |
1130 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
1129 | if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int; |
Line 1131... | Line 1130... | ||
1131 | // Motor Links |
1130 | // Motor Links |
1132 | motorwert = GasMischanteil + pd_ergebnis - GierMischanteil; |
1131 | MotorValue = GasMixingFraction + pd_ergebnis - YawMixingFraction; |
1133 | #define GRENZE Poti1 |
1132 | #define GRENZE Poti1 |
1134 | 1133 | ||
1135 | if ((motorwert < 0)) motorwert = 0; |
1134 | if ((MotorValue < 0)) MotorValue = 0; |
1136 | else if(motorwert > MAX_GAS) motorwert = MAX_GAS; |
1135 | else if(MotorValue > MAX_GAS) MotorValue = MAX_GAS; |
Line 1137... | Line 1136... | ||
1137 | if (motorwert < MIN_GAS) motorwert = MIN_GAS; |
1136 | if (MotorValue < MIN_GAS) MotorValue = MIN_GAS; |
1138 | Motor_Links = motorwert; |
1137 | Motor_Left = MotorValue; |
1139 | // Motor Rechts |
1138 | // Motor Rechts |
1140 | motorwert = GasMischanteil - pd_ergebnis - GierMischanteil; |
1139 | MotorValue = GasMixingFraction - pd_ergebnis - YawMixingFraction; |
1141 | 1140 | ||
1142 | if ((motorwert < 0)) motorwert = 0; |
1141 | if ((MotorValue < 0)) MotorValue = 0; |