Rev 1378 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1378 | Rev 1550 | ||
---|---|---|---|
Line 90... | Line 90... | ||
90 | int ErsatzKompassInGrad; // Kompasswert in Grad |
90 | int ErsatzKompassInGrad; // Kompasswert in Grad |
91 | int GierGyroFehler = 0; |
91 | int GierGyroFehler = 0; |
92 | char GyroFaktor,GyroFaktorGier; |
92 | char GyroFaktor,GyroFaktorGier; |
93 | char IntegralFaktor,IntegralFaktorGier; |
93 | char IntegralFaktor,IntegralFaktorGier; |
94 | int DiffNick,DiffRoll; |
94 | int DiffNick,DiffRoll; |
95 | int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0; |
95 | //int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0, Poti5 = 0, Poti6 = 0, Poti7 = 0, Poti8 = 0; |
- | 96 | unsigned char Poti[9] = {0,0,0,0,0,0,0,0}; |
|
96 | volatile unsigned char SenderOkay = 0; |
97 | volatile unsigned char SenderOkay = 0; |
97 | volatile unsigned char SenderRSSI = 0; |
98 | volatile unsigned char SenderRSSI = 0; |
98 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
99 | int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
99 | char MotorenEin = 0; |
100 | char MotorenEin = 0; |
100 | long HoehenWert = 0; |
101 | long HoehenWert = 0; |
Line 146... | Line 147... | ||
146 | unsigned char Parameter_NaviGpsACC; |
147 | unsigned char Parameter_NaviGpsACC; |
147 | unsigned char Parameter_NaviOperatingRadius; |
148 | unsigned char Parameter_NaviOperatingRadius; |
148 | unsigned char Parameter_NaviWindCorrection; |
149 | unsigned char Parameter_NaviWindCorrection; |
149 | unsigned char Parameter_NaviSpeedCompensation; |
150 | unsigned char Parameter_NaviSpeedCompensation; |
150 | unsigned char Parameter_ExternalControl; |
151 | unsigned char Parameter_ExternalControl; |
- | 152 | unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5; |
|
151 | struct mk_param_struct EE_Parameter; |
153 | struct mk_param_struct EE_Parameter; |
152 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
154 | signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
153 | int MaxStickNick = 0,MaxStickRoll = 0; |
155 | int MaxStickNick = 0,MaxStickRoll = 0; |
154 | unsigned int modell_fliegt = 0; |
156 | unsigned int modell_fliegt = 0; |
155 | volatile unsigned char MikroKopterFlags = 0; |
157 | volatile unsigned char FCFlags = 0; |
156 | long GIER_GRAD_FAKTOR = 1291; |
158 | long GIER_GRAD_FAKTOR = 1291; |
157 | signed int KopplungsteilNickRoll,KopplungsteilRollNick; |
159 | signed int KopplungsteilNickRoll,KopplungsteilRollNick; |
158 | unsigned char RequiredMotors = 4; |
- | |
159 | unsigned char Motor[MAX_MOTORS]; |
- | |
160 | signed int tmp_motorwert[MAX_MOTORS]; |
160 | signed int tmp_motorwert[MAX_MOTORS]; |
161 | unsigned char LoadHandler = 0; |
161 | unsigned char LoadHandler = 0; |
162 | #define LIMIT_MIN(value, min) {if(value < min) value = min;} |
162 | #define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
163 | #define LIMIT_MAX(value, max) {if(value > max) value = max;} |
163 | #define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
164 | #define LIMIT_MIN_MAX(value, min, max) {if(value < min) value = min; else if(value > max) value = max;} |
164 | #define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
Line 165... | Line 165... | ||
165 | 165 | ||
166 | int MotorSmoothing(int neu, int alt) |
166 | int MotorSmoothing(int neu, int alt) |
167 | { |
167 | { |
168 | int motor; |
168 | int motor; |
Line 257... | Line 257... | ||
257 | ExternHoehenValue = 0; |
257 | ExternHoehenValue = 0; |
258 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; |
258 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; |
259 | GierGyroFehler = 0; |
259 | GierGyroFehler = 0; |
260 | SendVersionToNavi = 1; |
260 | SendVersionToNavi = 1; |
261 | LED_Init(); |
261 | LED_Init(); |
262 | MikroKopterFlags |= FLAG_CALIBRATE; |
262 | FCFlags |= FCFLAG_CALIBRATE; |
263 | FromNaviCtrl_Value.Kalman_K = -1; |
263 | FromNaviCtrl_Value.Kalman_K = -1; |
264 | FromNaviCtrl_Value.Kalman_MaxDrift = 0; |
264 | FromNaviCtrl_Value.Kalman_MaxDrift = 0; |
265 | FromNaviCtrl_Value.Kalman_MaxFusion = 32; |
265 | FromNaviCtrl_Value.Kalman_MaxFusion = 32; |
266 | Poti1 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110; |
- | |
- | 266 | ||
267 | Poti2 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110; |
267 | for(i=0;i<8;i++) |
- | 268 | { |
|
268 | Poti3 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110; |
269 | Poti[i] = PPM_in[EE_Parameter.Kanalbelegung[K_POTI1 + i]] + 110; |
269 | Poti4 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110; |
- | |
- | 270 | } |
|
270 | SenderOkay = 100; |
271 | SenderOkay = 100; |
271 | if(ServoActive) |
272 | if(ServoActive) |
272 | { |
273 | { |
273 | HEF4017R_ON; |
274 | HEF4017R_ON; |
274 | DDRD |=0x80; // enable J7 -> Servo signal |
275 | DDRD |=0x80; // enable J7 -> Servo signal |
Line 281... | Line 282... | ||
281 | //############################################################################ |
282 | //############################################################################ |
282 | { |
283 | { |
283 | static signed long tmpl,tmpl2,tmpl3,tmpl4; |
284 | static signed long tmpl,tmpl2,tmpl3,tmpl4; |
284 | static signed int oldNick, oldRoll, d2Roll, d2Nick; |
285 | static signed int oldNick, oldRoll, d2Roll, d2Nick; |
285 | signed long winkel_nick, winkel_roll; |
286 | signed long winkel_nick, winkel_roll; |
286 | - | ||
- | 287 | unsigned char i; |
|
287 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
288 | MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
288 | // MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier; |
289 | // MesswertGierBias = (signed int) AdNeutralGierBias - AdWertGier; |
289 | MesswertNick = (signed int) AdWertNickFilter / 8; |
290 | MesswertNick = (signed int) AdWertNickFilter / 8; |
290 | MesswertRoll = (signed int) AdWertRollFilter / 8; |
291 | MesswertRoll = (signed int) AdWertRollFilter / 8; |
291 | RohMesswertNick = MesswertNick; |
292 | RohMesswertNick = MesswertNick; |
Line 422... | Line 423... | ||
422 | if(RohMesswertNick > 256) MesswertNick += 1 * (RohMesswertNick - 256); |
423 | if(RohMesswertNick > 256) MesswertNick += 1 * (RohMesswertNick - 256); |
423 | else if(RohMesswertNick < -256) MesswertNick += 1 * (RohMesswertNick + 256); |
424 | else if(RohMesswertNick < -256) MesswertNick += 1 * (RohMesswertNick + 256); |
424 | if(RohMesswertRoll > 256) MesswertRoll += 1 * (RohMesswertRoll - 256); |
425 | if(RohMesswertRoll > 256) MesswertRoll += 1 * (RohMesswertRoll - 256); |
425 | else if(RohMesswertRoll < -256) MesswertRoll += 1 * (RohMesswertRoll + 256); |
426 | else if(RohMesswertRoll < -256) MesswertRoll += 1 * (RohMesswertRoll + 256); |
426 | } |
427 | } |
- | 428 | for(i=0;i<8;i++) |
|
427 | 429 | { |
|
428 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
- | |
- | 430 | int tmp; |
|
429 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
431 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_POTI1 + i]] + 110; |
430 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
- | |
431 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
- | |
432 | if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255; |
432 | if(tmp > 255) tmp = 255; else if(tmp < 0) tmp = 0; |
433 | if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255; |
433 | if(tmp != Poti[i]) |
- | 434 | { |
|
434 | if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255; |
435 | Poti[i] += (tmp - Poti[i]) / 8; |
435 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
436 | if(Poti[i] > tmp) Poti[i]--; |
- | 437 | else Poti[i]++; |
|
- | 438 | } |
|
- | 439 | } |
|
436 | } |
440 | } |
Line 437... | Line 441... | ||
437 | 441 | ||
438 | //############################################################################ |
442 | //############################################################################ |
439 | // Messwerte beim Ermitteln der Nullage |
443 | // Messwerte beim Ermitteln der Nullage |
440 | void CalibrierMittelwert(void) |
444 | void CalibrierMittelwert(void) |
441 | //############################################################################ |
445 | //############################################################################ |
- | 446 | { |
|
442 | { |
447 | unsigned char i; |
443 | if(PlatinenVersion == 13) SucheGyroOffset(); |
448 | if(PlatinenVersion == 13) SucheGyroOffset(); |
444 | // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern |
449 | // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern |
445 | ANALOG_OFF; |
450 | ANALOG_OFF; |
446 | MesswertNick = AdWertNick; |
451 | MesswertNick = AdWertNick; |
Line 449... | Line 454... | ||
449 | Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick; |
454 | Mittelwert_AccNick = ACC_AMPLIFY * (long)AdWertAccNick; |
450 | Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll; |
455 | Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdWertAccRoll; |
451 | Mittelwert_AccHoch = (long)AdWertAccHoch; |
456 | Mittelwert_AccHoch = (long)AdWertAccHoch; |
452 | // ADC einschalten |
457 | // ADC einschalten |
453 | ANALOG_ON; |
458 | ANALOG_ON; |
454 | if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--; |
- | |
455 | if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--; |
- | |
456 | if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--; |
- | |
457 | if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--; |
- | |
458 | if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255; |
459 | for(i=0;i<8;i++) |
- | 460 | { |
|
- | 461 | int tmp; |
|
459 | if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255; |
462 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_POTI1 + i]] + 110; |
460 | if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255; |
463 | LIMIT_MIN_MAX(tmp, 0, 255); |
461 | if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255; |
464 | if(Poti[i] > tmp) Poti[i]--; else if(Poti[i] < tmp) Poti[i]++; |
462 | 465 | } |
|
463 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
466 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
464 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
467 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
465 | } |
468 | } |
Line 466... | Line 469... | ||
466 | 469 | ||
Line 470... | Line 473... | ||
470 | //############################################################################ |
473 | //############################################################################ |
471 | { |
474 | { |
472 | unsigned char i; |
475 | unsigned char i; |
473 | if(!MotorenEin) |
476 | if(!MotorenEin) |
474 | { |
477 | { |
475 | MikroKopterFlags &= ~(FLAG_MOTOR_RUN | FLAG_FLY); |
478 | FCFlags &= ~(FCFLAG_MOTOR_RUN | FCFLAG_FLY); |
476 | for(i=0;i<MAX_MOTORS;i++) |
479 | for(i=0;i<MAX_MOTORS;i++) |
477 | { |
480 | { |
478 | if(!PC_MotortestActive) MotorTest[i] = 0; |
481 | if(!PC_MotortestActive) MotorTest[i] = 0; |
479 | Motor[i] = MotorTest[i]; |
482 | Motor[i].SetPoint = MotorTest[i]; |
480 | } |
483 | } |
481 | if(PC_MotortestActive) PC_MotortestActive--; |
484 | if(PC_MotortestActive) PC_MotortestActive--; |
482 | } |
485 | } |
483 | else MikroKopterFlags |= FLAG_MOTOR_RUN; |
486 | else FCFlags |= FCFLAG_MOTOR_RUN; |
Line 484... | Line 487... | ||
484 | 487 | ||
485 | DebugOut.Analog[12] = Motor[0]; |
488 | DebugOut.Analog[12] = Motor[0].SetPoint; |
486 | DebugOut.Analog[13] = Motor[1]; |
489 | DebugOut.Analog[13] = Motor[1].SetPoint; |
487 | DebugOut.Analog[14] = Motor[3]; |
490 | DebugOut.Analog[14] = Motor[2].SetPoint; |
Line 488... | Line 491... | ||
488 | DebugOut.Analog[15] = Motor[2]; |
491 | DebugOut.Analog[15] = Motor[3].SetPoint; |
489 | 492 | ||
490 | //Start I2C Interrupt Mode |
493 | //Start I2C Interrupt Mode |
491 | twi_state = 0; |
494 | twi_state = 0; |
Line 498... | Line 501... | ||
498 | //############################################################################ |
501 | //############################################################################ |
499 | // Trägt ggf. das Poti als Parameter ein |
502 | // Trägt ggf. das Poti als Parameter ein |
500 | void ParameterZuordnung(void) |
503 | void ParameterZuordnung(void) |
501 | //############################################################################ |
504 | //############################################################################ |
502 | { |
505 | { |
503 | #define CHK_POTI_MM(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; if(b <= min) b = min; else if(b >= max) b = max;} |
- | |
504 | #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; } |
506 | #define CHK_POTI(b,a) {if(a < 248) b = a; else b = Poti[255 - a];} |
505 | CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe,0,255); |
507 | #define CHK_POTI_MM(b,a,min,max) {CHK_POTI(b,a); LIMIT_MIN_MAX(b, min, max);} |
- | 508 | ||
506 | CHK_POTI_MM(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100); |
509 | CHK_POTI_MM(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100); |
507 | CHK_POTI_MM(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100); |
510 | CHK_POTI_MM(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100); |
508 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255); |
- | |
509 | CHK_POTI(Parameter_Hoehe_GPS_Z,EE_Parameter.Hoehe_GPS_Z,0,255); |
- | |
510 | CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255); |
- | |
511 | CHK_POTI_MM(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255); |
511 | CHK_POTI_MM(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255); |
512 | CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255); |
- | |
513 | CHK_POTI(Parameter_Gyro_D,EE_Parameter.Gyro_D,0,255); |
- | |
514 | CHK_POTI(Parameter_Gyro_Gier_P,EE_Parameter.Gyro_Gier_P,10,255); |
- | |
515 | CHK_POTI(Parameter_Gyro_Gier_I,EE_Parameter.Gyro_Gier_I,0,255); |
- | |
516 | CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255); |
- | |
517 | CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255); |
- | |
518 | CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255); |
- | |
519 | CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255); |
- | |
520 | CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255); |
- | |
521 | CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255); |
- | |
522 | CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255); |
- | |
523 | CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255); |
- | |
524 | CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255); |
- | |
525 | CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255); |
- | |
526 | CHK_POTI(Parameter_ServoRollControl,EE_Parameter.ServoRollControl,0,255); |
- | |
527 | CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255); |
- | |
528 | CHK_POTI(Parameter_AchsKopplung1, EE_Parameter.AchsKopplung1,0,255); |
- | |
529 | CHK_POTI(Parameter_AchsKopplung2, EE_Parameter.AchsKopplung2,0,255); |
- | |
530 | CHK_POTI(Parameter_CouplingYawCorrection,EE_Parameter.CouplingYawCorrection,0,255); |
- | |
531 | // CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255); |
- | |
532 | CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255); |
- | |
533 | CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255); |
512 | CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,1,255); |
534 | CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255); |
513 | CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,1,255); |
- | 514 | CHK_POTI(Parameter_Servo3,EE_Parameter.Servo3); |
|
- | 515 | CHK_POTI(Parameter_Servo4,EE_Parameter.Servo4); |
|
- | 516 | CHK_POTI(Parameter_Servo5,EE_Parameter.Servo5); |
|
- | 517 | CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe); |
|
- | 518 | CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe); |
|
- | 519 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung); |
|
- | 520 | CHK_POTI(Parameter_Hoehe_GPS_Z,EE_Parameter.Hoehe_GPS_Z); |
|
- | 521 | CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung); |
|
- | 522 | CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I); |
|
- | 523 | CHK_POTI(Parameter_Gyro_D,EE_Parameter.Gyro_D); |
|
- | 524 | CHK_POTI(Parameter_Gyro_Gier_P,EE_Parameter.Gyro_Gier_P); |
|
- | 525 | CHK_POTI(Parameter_Gyro_Gier_I,EE_Parameter.Gyro_Gier_I); |
|
- | 526 | CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor); |
|
- | 527 | CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1); |
|
- | 528 | CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2); |
|
- | 529 | CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3); |
|
- | 530 | CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4); |
|
- | 531 | CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5); |
|
- | 532 | CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6); |
|
- | 533 | CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7); |
|
- | 534 | CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8); |
|
- | 535 | CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl); |
|
- | 536 | CHK_POTI(Parameter_ServoRollControl,EE_Parameter.ServoRollControl); |
|
- | 537 | CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit); |
|
- | 538 | CHK_POTI(Parameter_AchsKopplung1, EE_Parameter.AchsKopplung1); |
|
- | 539 | CHK_POTI(Parameter_AchsKopplung2, EE_Parameter.AchsKopplung2); |
|
- | 540 | CHK_POTI(Parameter_CouplingYawCorrection,EE_Parameter.CouplingYawCorrection); |
|
- | 541 | // CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255); |
|
- | 542 | CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability); |
|
535 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl,0,255); |
543 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl); |
536 | Ki = 10300 / (Parameter_I_Faktor + 1); |
544 | Ki = 10300 / (Parameter_I_Faktor + 1); |
537 | MAX_GAS = EE_Parameter.Gas_Max; |
545 | MAX_GAS = EE_Parameter.Gas_Max; |
538 | MIN_GAS = EE_Parameter.Gas_Min; |
546 | MIN_GAS = EE_Parameter.Gas_Min; |
539 | } |
547 | } |
Line 540... | Line -... | ||
540 | - | ||
541 | 548 | ||
542 | //############################################################################ |
549 | //############################################################################ |
543 | // |
550 | // |
544 | void MotorRegler(void) |
551 | void MotorRegler(void) |
545 | //############################################################################ |
552 | //############################################################################ |
Line 574... | Line 581... | ||
574 | { |
581 | { |
575 | if(RcLostTimer) RcLostTimer--; |
582 | if(RcLostTimer) RcLostTimer--; |
576 | else |
583 | else |
577 | { |
584 | { |
578 | MotorenEin = 0; |
585 | MotorenEin = 0; |
579 | MikroKopterFlags &= ~FLAG_NOTLANDUNG; |
586 | FCFlags &= ~FCFLAG_NOTLANDUNG; |
580 | } |
587 | } |
581 | ROT_ON; |
588 | ROT_ON; |
582 | if(modell_fliegt > 1000) // wahrscheinlich in der Luft --> langsam absenken |
589 | if(modell_fliegt > 1000) // wahrscheinlich in der Luft --> langsam absenken |
583 | { |
590 | { |
584 | GasMischanteil = EE_Parameter.NotGas; |
591 | GasMischanteil = EE_Parameter.NotGas; |
585 | MikroKopterFlags |= FLAG_NOTLANDUNG; |
592 | FCFlags |= FCFLAG_NOTLANDUNG; |
586 | PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
593 | PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
587 | PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
594 | PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
588 | PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
595 | PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0; |
589 | PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
596 | PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0; |
590 | PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0; |
597 | PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0; |
Line 595... | Line 602... | ||
595 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
602 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
596 | // Emfang gut |
603 | // Emfang gut |
597 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
604 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
598 | if(SenderOkay > 140) |
605 | if(SenderOkay > 140) |
599 | { |
606 | { |
600 | MikroKopterFlags &= ~FLAG_NOTLANDUNG; |
607 | FCFlags &= ~FCFLAG_NOTLANDUNG; |
601 | RcLostTimer = EE_Parameter.NotGasZeit * 50; |
608 | RcLostTimer = EE_Parameter.NotGasZeit * 50; |
602 | if(GasMischanteil > 40 && MotorenEin) |
609 | if(GasMischanteil > 40 && MotorenEin) |
603 | { |
610 | { |
604 | if(modell_fliegt < 0xffff) modell_fliegt++; |
611 | if(modell_fliegt < 0xffff) modell_fliegt++; |
605 | } |
612 | } |
Line 612... | Line 619... | ||
612 | NeueKompassRichtungMerken = 1; |
619 | NeueKompassRichtungMerken = 1; |
613 | sollGier = 0; |
620 | sollGier = 0; |
614 | Mess_Integral_Gier = 0; |
621 | Mess_Integral_Gier = 0; |
615 | // Mess_Integral_Gier2 = 0; |
622 | // Mess_Integral_Gier2 = 0; |
616 | } |
623 | } |
617 | } else MikroKopterFlags |= FLAG_FLY; |
624 | } else FCFlags |= FCFLAG_FLY; |
Line 618... | Line 625... | ||
618 | 625 | ||
619 | if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) |
626 | if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) |
620 | { |
627 | { |
621 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
628 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 646... | Line 653... | ||
646 | beeptime = 1000; |
653 | beeptime = 1000; |
647 | } |
654 | } |
648 | else |
655 | else |
649 | { |
656 | { |
650 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
657 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
- | 658 | LipoDetection(0); |
|
- | 659 | LIBFC_ReceiverInit(); |
|
651 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
660 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
652 | { |
661 | { |
653 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
662 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
654 | } |
663 | } |
655 | ServoActive = 0; |
664 | ServoActive = 0; |
Line 685... | Line 694... | ||
685 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
694 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
686 | // Gas ist unten |
695 | // Gas ist unten |
687 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
696 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
688 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120) |
697 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120) |
689 | { |
698 | { |
- | 699 | // Motoren Starten |
|
- | 700 | if(!MotorenEin) |
|
690 | // Starten |
701 | { |
691 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) |
702 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) |
692 | { |
703 | { |
693 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
704 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
694 | // Einschalten |
705 | // Einschalten |
695 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
706 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
696 | if(++delay_einschalten > 200) |
707 | if(++delay_einschalten > 200) |
697 | { |
708 | { |
698 | delay_einschalten = 200; |
709 | delay_einschalten = 0; |
699 | modell_fliegt = 1; |
710 | modell_fliegt = 1; |
700 | MotorenEin = 1; |
711 | MotorenEin = 1; |
701 | sollGier = 0; |
712 | sollGier = 0; |
702 | Mess_Integral_Gier = 0; |
713 | Mess_Integral_Gier = 0; |
703 | Mess_Integral_Gier2 = 0; |
714 | Mess_Integral_Gier2 = 0; |
704 | Mess_IntegralNick = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccNick; |
715 | Mess_IntegralNick = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccNick; |
705 | Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll; |
716 | Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll; |
706 | Mess_IntegralNick2 = IntegralNick; |
717 | Mess_IntegralNick2 = IntegralNick; |
707 | Mess_IntegralRoll2 = IntegralRoll; |
718 | Mess_IntegralRoll2 = IntegralRoll; |
708 | SummeNick = 0; |
719 | SummeNick = 0; |
709 | SummeRoll = 0; |
720 | SummeRoll = 0; |
710 | MikroKopterFlags |= FLAG_START; |
721 | FCFlags |= FCFLAG_START; |
711 | } |
722 | } |
712 | } |
723 | } |
713 | else delay_einschalten = 0; |
724 | else delay_einschalten = 0; |
714 | //Auf Neutralwerte setzen |
- | |
- | 725 | } |
|
715 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
726 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
716 | // Auschalten |
727 | // Auschalten |
717 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
728 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 729 | else // only if motors are running |
|
- | 730 | { |
|
718 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) |
731 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) |
719 | { |
732 | { |
720 | if(++delay_ausschalten > 200) // nicht sofort |
733 | if(++delay_ausschalten > 200) // nicht sofort |
721 | { |
734 | { |
722 | MotorenEin = 0; |
735 | MotorenEin = 0; |
723 | delay_ausschalten = 200; |
736 | delay_ausschalten = 0; |
724 | modell_fliegt = 0; |
737 | modell_fliegt = 0; |
725 | } |
738 | } |
726 | } |
739 | } |
727 | else delay_ausschalten = 0; |
740 | else delay_ausschalten = 0; |
- | 741 | } |
|
728 | } |
742 | } |
729 | } |
743 | } |
730 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
744 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
731 | // neue Werte von der Funke |
745 | // neue Werte von der Funke |
732 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
746 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 733... | Line 747... | ||
733 | 747 | ||
734 | if(!NewPpmData-- || (MikroKopterFlags & FLAG_NOTLANDUNG)) |
748 | if(!NewPpmData-- || (FCFlags & FCFLAG_NOTLANDUNG)) |
735 | { |
749 | { |
736 | static int stick_nick,stick_roll; |
750 | static int stick_nick,stick_roll; |
737 | ParameterZuordnung(); |
751 | ParameterZuordnung(); |
738 | stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4; |
752 | stick_nick = (stick_nick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4; |
Line 781... | Line 795... | ||
781 | { |
795 | { |
782 | MaxStickRoll = abs(StickRoll)/STICK_GAIN; |
796 | MaxStickRoll = abs(StickRoll)/STICK_GAIN; |
783 | if(MaxStickRoll > 100) MaxStickRoll = 100; |
797 | if(MaxStickRoll > 100) MaxStickRoll = 100; |
784 | } |
798 | } |
785 | else MaxStickRoll--; |
799 | else MaxStickRoll--; |
786 | if(MikroKopterFlags & FLAG_NOTLANDUNG) {MaxStickNick = 0; MaxStickRoll = 0;} |
800 | if(FCFlags & FCFLAG_NOTLANDUNG) {MaxStickNick = 0; MaxStickRoll = 0;} |
Line 787... | Line 801... | ||
787 | 801 | ||
788 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
802 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
789 | // Looping? |
803 | // Looping? |
790 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
804 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 833... | Line 847... | ||
833 | 847 | ||
834 | 848 | ||
835 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
849 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
836 | // Bei Empfangsausfall im Flug |
850 | // Bei Empfangsausfall im Flug |
837 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
851 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
838 | if(MikroKopterFlags & FLAG_NOTLANDUNG) |
852 | if(FCFlags & FCFLAG_NOTLANDUNG) |
839 | { |
853 | { |
840 | StickGier = 0; |
854 | StickGier = 0; |
841 | StickNick = 0; |
855 | StickNick = 0; |
Line 1174... | Line 1188... | ||
1174 | //DebugOut.Analog[16] = Mittelwert_AccHoch; |
1188 | //DebugOut.Analog[16] = Mittelwert_AccHoch; |
1175 | //DebugOut.Analog[17] = FromNaviCtrl_Value.Distance; |
1189 | //DebugOut.Analog[17] = FromNaviCtrl_Value.Distance; |
1176 | DebugOut.Analog[18] = VarioMeter; |
1190 | DebugOut.Analog[18] = VarioMeter; |
1177 | DebugOut.Analog[19] = WinkelOut.CalcState; |
1191 | DebugOut.Analog[19] = WinkelOut.CalcState; |
1178 | DebugOut.Analog[20] = ServoNickValue; |
1192 | DebugOut.Analog[20] = ServoNickValue; |
- | 1193 | DebugOut.Analog[22] = Capacity.ActualCurrent; |
|
- | 1194 | DebugOut.Analog[23] = Capacity.UsedCapacity; |
|
1179 | // DebugOut.Analog[22] = FromNaviCtrl_Value.GpsZ; |
1195 | // DebugOut.Analog[22] = FromNaviCtrl_Value.GpsZ; |
1180 | // DebugOut.Analog[24] = MesswertNick/2; |
1196 | // DebugOut.Analog[24] = MesswertNick/2; |
1181 | // DebugOut.Analog[25] = MesswertRoll/2; |
1197 | // DebugOut.Analog[25] = MesswertRoll/2; |
1182 | // DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift; |
1198 | // DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift; |
1183 | // DebugOut.Analog[28] = (int)FromNaviCtrl_Value.Kalman_MaxFusion; |
1199 | // DebugOut.Analog[28] = (int)FromNaviCtrl_Value.Kalman_MaxFusion; |
1184 | // DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K; |
1200 | // DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K; |
1185 | //DebugOut.Analog[28] = I2CError; |
1201 | //DebugOut.Analog[28] = I2CError; |
1186 | // DebugOut.Analog[29] = FromNaviCtrl_Value.SerialDataOkay; |
1202 | DebugOut.Analog[29] = FromNaviCtrl_Value.SerialDataOkay; |
1187 | DebugOut.Analog[30] = GPS_Nick; |
1203 | DebugOut.Analog[30] = GPS_Nick; |
1188 | DebugOut.Analog[31] = GPS_Roll; |
1204 | DebugOut.Analog[31] = GPS_Roll; |
1189 | } |
1205 | } |
Line 1190... | Line 1206... | ||
1190 | 1206 | ||
Line 1317... | Line 1333... | ||
1317 | tmp_int = (int)(IntegralNick/GIER_GRAD_FAKTOR); // nick angle in deg |
1333 | tmp_int = (int)(IntegralNick/GIER_GRAD_FAKTOR); // nick angle in deg |
1318 | tmp_int2 = (int)(IntegralRoll/GIER_GRAD_FAKTOR); // roll angle in deg |
1334 | tmp_int2 = (int)(IntegralRoll/GIER_GRAD_FAKTOR); // roll angle in deg |
1319 | CosAttitude = (int16_t)ihypot(tmp_int, tmp_int2); // phytagoras gives effective attitude angle in deg |
1335 | CosAttitude = (int16_t)ihypot(tmp_int, tmp_int2); // phytagoras gives effective attitude angle in deg |
1320 | LIMIT_MAX(CosAttitude, 60); // limit effective attitude angle |
1336 | LIMIT_MAX(CosAttitude, 60); // limit effective attitude angle |
1321 | CosAttitude = c_cos_8192(CosAttitude); // cos of actual attitude |
1337 | CosAttitude = c_cos_8192(CosAttitude); // cos of actual attitude |
1322 | if(HoehenReglerAktiv && !(MikroKopterFlags & FLAG_NOTLANDUNG)) |
1338 | if(HoehenReglerAktiv && !(FCFlags & FCFLAG_NOTLANDUNG)) |
1323 | { |
1339 | { |
1324 | #define HEIGHT_TRIM_UP 0x01 |
1340 | #define HEIGHT_TRIM_UP 0x01 |
1325 | #define HEIGHT_TRIM_DOWN 0x02 |
1341 | #define HEIGHT_TRIM_DOWN 0x02 |
1326 | static unsigned char HeightTrimmingFlag = 0x00; |
1342 | static unsigned char HeightTrimmingFlag = 0x00; |
Line 1340... | Line 1356... | ||
1340 | { |
1356 | { |
1341 | // alternative height control |
1357 | // alternative height control |
1342 | // PD-Control with respect to hoover point |
1358 | // PD-Control with respect to hoover point |
1343 | // the thrust loss out of horizontal attitude is compensated |
1359 | // the thrust loss out of horizontal attitude is compensated |
1344 | // the setpoint will be fine adjusted with the gas stick position |
1360 | // the setpoint will be fine adjusted with the gas stick position |
1345 | if(MikroKopterFlags & FLAG_FLY) // trim setpoint only when flying |
1361 | if(FCFlags & FCFLAG_FLY) // trim setpoint only when flying |
1346 | { // gas stick is above hoover point |
1362 | { // gas stick is above hoover point |
1347 | if(StickGas > (StickGasHoover + HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtUpperLimit) |
1363 | if(StickGas > (StickGasHoover + HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtUpperLimit) |
1348 | { |
1364 | { |
1349 | if(HeightTrimmingFlag & HEIGHT_TRIM_DOWN) |
1365 | if(HeightTrimmingFlag & HEIGHT_TRIM_DOWN) |
1350 | { |
1366 | { |
Line 1388... | Line 1404... | ||
1388 | if(StickGasHoover < 70) StickGasHoover = 70; |
1404 | if(StickGasHoover < 70) StickGasHoover = 70; |
1389 | else if(StickGasHoover > 150) StickGasHoover = 150; |
1405 | else if(StickGasHoover > 150) StickGasHoover = 150; |
1390 | } |
1406 | } |
1391 | } |
1407 | } |
1392 | if(BaroExpandActive) SollHoehe = HoehenWert; // update setpoint to current altitude if Expanding is active |
1408 | if(BaroExpandActive) SollHoehe = HoehenWert; // update setpoint to current altitude if Expanding is active |
1393 | } //if MikroKopterFlags & MKFLAG_FLY |
1409 | } //if FCFlags & MKFCFLAG_FLY |
1394 | else |
1410 | else |
1395 | { |
1411 | { |
1396 | SollHoehe = HoehenWert - 400; |
1412 | SollHoehe = HoehenWert - 400; |
1397 | if(EE_Parameter.Hoehe_StickNeutralPoint) StickGasHoover = EE_Parameter.Hoehe_StickNeutralPoint; |
1413 | if(EE_Parameter.Hoehe_StickNeutralPoint) StickGasHoover = EE_Parameter.Hoehe_StickNeutralPoint; |
1398 | else StickGasHoover = 120; |
1414 | else StickGasHoover = 120; |
Line 1463... | Line 1479... | ||
1463 | FilterHCGas = GasMischanteil; |
1479 | FilterHCGas = GasMischanteil; |
1464 | } |
1480 | } |
Line 1465... | Line 1481... | ||
1465 | 1481 | ||
1466 | // Hoover gas estimation by averaging gas control output on small z-velocities |
1482 | // Hoover gas estimation by averaging gas control output on small z-velocities |
1467 | // this is done only if height contol option is selected in global config and aircraft is flying |
1483 | // this is done only if height contol option is selected in global config and aircraft is flying |
1468 | if((MikroKopterFlags & FLAG_FLY) && !(MikroKopterFlags & FLAG_NOTLANDUNG)) |
1484 | if((FCFlags & FCFLAG_FLY) && !(FCFlags & FCFLAG_NOTLANDUNG)) |
1469 | { |
1485 | { |
1470 | if(HooverGasFilter == 0) HooverGasFilter = HOOVER_GAS_AVERAGE * (unsigned long)(GasMischanteil); // init estimation |
1486 | if(HooverGasFilter == 0) HooverGasFilter = HOOVER_GAS_AVERAGE * (unsigned long)(GasMischanteil); // init estimation |
1471 | if(abs(VarioMeter) < 100) // only on small vertical speed |
1487 | if(abs(VarioMeter) < 100) // only on small vertical speed |
1472 | { |
1488 | { |
Line 1590... | Line 1606... | ||
1590 | tmp_int += ((long)pd_ergebnis_roll * Mixer.Motor[i][2]) / 64L; |
1606 | tmp_int += ((long)pd_ergebnis_roll * Mixer.Motor[i][2]) / 64L; |
1591 | tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
1607 | tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
1592 | tmp_motorwert[i] = MotorSmoothing(tmp_int,tmp_motorwert[i]); // Filter |
1608 | tmp_motorwert[i] = MotorSmoothing(tmp_int,tmp_motorwert[i]); // Filter |
1593 | tmp_int = tmp_motorwert[i] / STICK_GAIN; |
1609 | tmp_int = tmp_motorwert[i] / STICK_GAIN; |
1594 | CHECK_MIN_MAX(tmp_int,MIN_GAS,MAX_GAS); |
1610 | CHECK_MIN_MAX(tmp_int,MIN_GAS,MAX_GAS); |
1595 | Motor[i] = tmp_int; |
1611 | Motor[i].SetPoint = tmp_int; |
1596 | } |
1612 | } |
1597 | else Motor[i] = 0; |
1613 | else Motor[i].SetPoint = 0; |
1598 | } |
1614 | } |
1599 | /* |
- | |
1600 | if(Poti1 > 20) Motor1 = 0; |
- | |
1601 | if(Poti1 > 90) Motor6 = 0; |
- | |
1602 | if(Poti1 > 140) Motor2 = 0; |
- | |
1603 | //if(Poti1 > 200) Motor7 = 0; |
- | |
1604 | */ |
- | |
1605 | } |
1615 | } |